Skip to main content

Hello,


I try to split(5000,5000,3) image to (4,2500,2500,3) and merge it. Here my code:



geometry = [
[
[
38.752152,
37.208675
],
[
39.224913,
37.208675
],
[
39.224913,
36.686262
],
[
38.752152,
36.686262
],
[
38.752152,
37.208675
]
]
]

step_x = round(size[0]/2500+1)
step_y = round(size[1]/2500+1)
combinedImage = numpy.zeros((step_x*2500,step_y*2500,3))

points_x = numpy.linspace(x_min,x_max,step_x)
points_x = points_x[::-1]
points_y = numpy.linspace(y_min,y_max,step_y)
points_y = points_y[::-1]
size_x = len(points_x)
size_y = len(points_y)
for y in range(size_x-2,-1,-1):
for x in range(size_y-2,-1,-1):
tmpGeometry = [[[points_x[x],points_y[y]],[points_x[x],points_y[y+1]],[points_x[x+1],points_y[y]],[points_x[x+1],points_y[y+1]]]]
x_min, y_min = numpy.min(tmpGeometry, axis = 1)[0]
x_max, y_max = numpy.max(tmpGeometry, axis = 1)[0]
sentinelhub.setGeometry(geometry)
sentinelhub.setBBox(x_min,y_min,x_max,y_max)
image = sentinelhub.sendRequest()
combinedImage[2500*y:2500*(y+1),2500*x:2500*(x+1)] = image

print((x,y))

cv2.imwrite("combinedImageyx4.jpg",combinedImage)


but as you see its order is wrong ? What can I do for it ? right part should be at left, and left part should be at right.

Hi,


Thanks for the query but I do not understand what you are try to achieve here. Can you please provide some more information on what packages you are using and your inputs and expected outputs.


Thanks


@william.ray thanks for your reply, I solved the problem by changin the codes by that:


images = []
rows = []

for y in range(size_y-1):

rows = []
for x in range(size_x-1):
tmpGeometry = [[[points_x[x],points_y[y]],[points_x[x],points_y[y+1]],[points_x[x+1],points_y[y]],[points_x[x+1],points_y[y+1]]]]
x_min, y_min = numpy.min(tmpGeometry, axis = 1)[0]
x_max, y_max = numpy.max(tmpGeometry, axis = 1)[0]
sentinelhub.setBBox(x_min,y_min,x_max,y_max)
image = sentinelhub.getCombinedImage()
rows.append(image)



rows = numpy.concatenate(rows, axis = 1)
images.append(rows)
images = images[::-1]
images = numpy.concatenate(images,axis =0)

Reply