dovahcrow/patchify.py

Does unpatchify average between overlapping patches?

ritulahoti opened this issue · 6 comments

How do the unpatchify works for overlapping patches?
Does it average the values in overlapped area or it takes the value of the next patch as it is?
Thanks.

Hi @ritulahoti it won't do average. If the patches are overlapped, patchify will de-overlapping and recover the original image if this condition holds The required condition to successfully recover the image using unpatchify is to have (width - patch_width) mod step_size = 0 when calling patchify. (as mentioned in readme)

Hi, thanks for a quick response.
I'm trying to patchify an image and unpatchify the segmentation maps of the generated patches. So, for given two overlapping patches with varying probability values within, what values does the overlapping section get? (Conditions are being met)

Alright, I got it.
However, in my segmentation experiment, after applying unpatchify, the output shows a shifted results. Although its de-overlapping, the segmentation results should not shift, right?

Also, any help on how can I average the overlapping regions value?

Alright, I got it.
However, in my segmentation experiment, after applying unpatchify, the output shows a shifted results. Although its de-overlapping, the segmentation results should not shift, right?

Also, any help on how can I average the overlapping regions value?

This must be a bug if the result is shifted. Would you mind providing your image size and the step size/patch size you used?

For averaging the overlapping values, unfortunately, I think you need to change the code in thedef unpatchify since I didn't design this functionality into the library.

Sure.
Image size: (160,160,144), patch size: (64,64,64), step=32
Thanks.