Hi @ptrblck ,
Thanks very much for your proposition. Actually, I fell into the same situation: extracting 3D patch from MRI.
Here is the original dimension of my MRI: 169 * 208 * 179. I set the patch_size = 21, and stride_size = 10. Using your code: patches = x.unfold(1, size, stride).unfold(2, size, stride).unfold(3, size, stride), I finally got pathces as shape:
[15, 19, 16, 21, 21, 21] (In total,4560 pathces with size 212121)
I just wanna know can we have a formula to calculate the resulting number of patches based on the patch_size and stride_size??? How torch.unfold deals with the boarding of the images? padding with 0 or discard it if it’s not enough for a patch?
You do not give too much information on how the unfold in the documentation.
Thanks very much!!!