How to split an image into N sub-images?

Hi,

I have an image dataset with different sizes.
Instead of resizing, I want to split every image into N sub-images with the same size (320*320).
Certainly, N will be different for each image, and maybe there will be a need for zero-padding.
For example, if the size of the image is 1920x1080, Height will be split into 6 parts, and the width will be split into 3 with zero padding to keep the size of 320. So there will be 18 sub-images in this case. For another image with a different size, it will be different.
But I don’t know how to do this in practice.

Hi Nima,
This topic has already discussed in multiple posts. To get your solution faster you can check them . in this post and this post

1 Like