How to split a large image into many small images?
Show older comments
Hi, I am working on CNN and I have dataset of large images. I want to split each image into many small images to perform training. Could you please tell me how to do it? To be exact, I want 24 small samples from one 1080 x 1920 image.
Further, is it possible to perform splitting in a imageDatastore? To be exact, I want 24 small samples from one 1080 x 1920 image.
Thanks

2 Comments
Image Analyst
on 17 Jun 2021
I don't believe imageDatastore() does any image processing -- it's just basically a fancy way of doing dir().
Do you want the samples to be tiled and non-overlapping? Or do you want them taken from random locations?
What I'm confused about is if you're going to use all these small sub-images as training images, how are you going to create your ground truth labels from them?
Syed JABBAR SHAH
on 17 Jun 2021
Accepted Answer
More Answers (2)
David Willingham
on 17 Jun 2021
1 vote
Hi Syed,
I'd encourge you to use blockedImage along with blockedImagedatastore, it will help you perform the block operations for you.
David Willingham
Sulaymon Eshkabilov
on 17 Jun 2021
0 votes
Here is a nice discussion on how to split images with nlfilter() suggested by Rik:
1 Comment
DGM
on 17 Jun 2021
To reinforce the distinction, nlfilter() is a rectangular sliding-window filter, whereas blockproc() works on non-overlapping blocks.
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!