I want to extract color image patches from a 512x512 color image, and save them as individual image patches in a folder. How can I reconstruct my original image from these image patches? I have read and looked at afew of the similar questions and they do not solve my problem.
I have done abit of reading up and decided to use the view_as_windows function from SKimage to carry out my image patching. I also managed to save my patches to png files.
Currently using SKimage view_as_window to extract patches from a color image sized 512x512 patch_img = view_as_windows(input_img, (128, 128, 3), step=64) when revealing the details of the output array, I noticed that patch_img has a shape of (7, 7, 1, 128, 128, 3) and a dtype of unint8. To save each patch as an individual image I use the following code.
for i in range(0, len(patch_img)): #range should be 0 to 6
for x in range(0, len(patch_img)):
fname= 'IMG_test_{}_{}.png'.format(i, x)
#cv2.imwrite(fname, crop_img[i,x,0,:,:,:])
When loading the entire folder with the saved images using CV2, I am unable to get back the same shape and dtype of patch_img, instead, I get a shape (49, 128, 128, 3). How can I fix this.
Edit: Fixed the shape using savedimg = savedimg.reshape(7,7,128 128, 3)
Also, how can I then use the saved image patches to reconstruct the original image?