Matlab code to split an image into a square grid of square blocks
Show older comments
Hello everyone,
I am having a hard time writing a matlab code that splits an image into a square grid of square blocks of side equal to
where
then shuffle the grid using randperm. So it is based on user input of how much the image should be cut down to, say the user inputs SplitImage(Image, r). All help is appreciated.
then shuffle the grid using randperm. So it is based on user input of how much the image should be cut down to, say the user inputs SplitImage(Image, r). All help is appreciated.
Accepted Answer
More Answers (1)
Walter Roberson
on 9 Oct 2019
1 vote
See mat2cell() to do the splitting into cell arrays. Then randomize the cell array order, and then cell2mat() to restore.
You will have problems if your block size is not an exact divisor of the array size unless you take special care that all rows and columns in the randomized blocks add up to consistent sizes.
1 Comment
Abigail Thomas
on 9 Oct 2019
Categories
Find more on Image Arithmetic 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!