You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
This will reconstruct the original image that was patchified in previous code.
Help!unpatchify yields distorted images
In order forunpatchify to work, patchies should be created with equal step size.e.g. if the original image has width 3 and the patch has width 2, you cannot really create equal step size patches with step size 2.(first patch [elem0, elem1] and second patch [elem2, elem3], in which elem3 is out of bound).
The required condition to successfully recover the image using unpatchifyis to have(width - patch_width) mod step_size = 0 when callingpatchify.
Full running examples
2D image patchify and merge
importnumpyasnpfrompatchifyimportpatchify,unpatchifyimage=np.array([[1,2,3,4], [5,6,7,8], [9,10,11,12]])patches=patchify(image, (2,2),step=1)# split image into 2*3 small 2*2 patches.assertpatches.shape== (2,3,2,2)reconstructed_image=unpatchify(patches,image.shape)assert (reconstructed_image==image).all()