I've successfully divided my image into tiles, which I am aiming to process. However, afterwards, I'd like to join them and form the processed image, the same way the original image was in dimensions. I've the following code already working. Upon loading an image into the variable 'image' of resolution 1000x775;
# define the tile size
tilesize_r = 128
tilesize_c = 128
# divide the image into 128x128 tiles
for r in range(0,image.shape[0] - tilesize_r, tilesize_r):
for c in range(0,image.shape[1] - tilesize_c, tilesize_c):
tile = image[r:r+tilesize_r,c:c+tilesize_c]
tile_name = 'image{}tile{}.jpg'.format(ind, tilecount) #naming of it, does not matter
tile_path = os.path.join(abs_tile_images_dir, tile_name) #path of it, does not matter either
cv2.imwrite(tile_path, tile)
tilecount+=1
So, in the end, I have the list of images as:
image0tile0.jpg
image0tile1.jpg
.
.
.
image0tile41.jpg
and so on. I'd like to join these again, what shall I do? I assume I need to construct the same loop, but this time I shall gather all the tiles that have the same "imageN" part first, and then loop over them, and join them based on the "tileN". Am I getting close?
image
array. Then write theimage
array out as an image.