This will reconstruct the original image that was patchified in previous code.
Help! unpatchify yields distorted images
In order for unpatchify 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 unpatchify
is to have (width - patch_width) mod step_size = 0 when calling patchify.
patchify
patchfy can split images into small overlappable patches by given patch cell size, and merge patches into original image.
This library provides two functions:
patchify,unpatchify.Installation
Usage
Split image to patches
patchify(image_to_patch, patch_shape, step=1)2D image:
3D image:
Merge patches into original image
unpatchify(patches_to_merge, merged_image_size)This will reconstruct the original image that was patchified in previous code.
Help!
unpatchifyyields distorted imagesIn order for
unpatchifyto 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 unpatchify is to have
(width - patch_width) mod step_size = 0when callingpatchify.Full running examples
2D image patchify and merge
3D image patchify and merge