I would like to split an images into smaller images of 1024x1024. I would like to have an overlap of 100 pixels in the top/bottom and left/right of the patches.
[]
I am using padding and torch.unfold to create even sized patches.
def create_patches(image, patch_size): # Pad right and bottom to fit patch_size padding_right = patch_size - image.shape[2]%patch_size padding_bottom = patch_size - image.shape[1]%patch_size image = F.pad(image, (0, 0, padding_right, padding_bottom)) return image.unfold(0, 3, 3).unfold(1, patch_size, patch_size).unfold(2, patch_size, patch_size)
How can I make the patches to overlap?