segmenting an image into number of equal size images
Show older comments
can anybody give me an algorithm for segmenting an image into certain number of equal size image and also for calculating properties for each segmented images?
3 Comments
Image Analyst
on 1 Apr 2012
We should really add this to the FAQ. This "how do I divide an image into blocks/subimages" question is getting almost as common as the "how do I save a figure" questions.
M@lik Ali
on 16 Jul 2012
yes i think must add this to FAQ.
Jeff Dozier
on 9 Aug 2013
Check the function bestblk([M N],maxsiz). It finds dimensions <= maxsiz that are divisors of M & N. If it can't find a divisor > M/10, then it minimizes the amount of padding (and then does the same for N).
Accepted Answer
More Answers (1)
Aaditya Kalsi
on 1 Apr 2012
0 votes
One way to do this is to decide on a metric to segment the image into. Also, the method I am writing is general and the resulting segments will not completely reconstruct the image, rather extract out N important segments.
Easy Algorithm:
1. Assume a 5x5 (you may choose a different size) block. Select this iteratively and move through the entire image. If you have the Image Processing Toolbox, you may do this by BLOCKPROC.
2. Calculate Variance for each block. You may do this by using VAR() on the block's elements listed out like a vector. Assuming your block is B, then B(:) will list out its elements as a vector.
3. Keep the blocks with the M highest variance values.
Variance is a good starting guess for interesting regions. This however highly depends on your application.
Categories
Find more on Color Segmentation 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!