How a binary image can be divided into four equal parts using loop ?
Afficher commentaires plus anciens
I have a binary image . I want to divide this into 4 equal parts using a loop and want to store each part individually. later I want to find out the no of white pixels in each parts.
3 commentaires
Image Analyst
le 23 Fév 2018
How is the splitting going to be done? Along and perpendicular to the major axis with the 4 corner point at the centroid of the blob? Just splitting into 4 equal quadrants regardless of where where your binary blobs lie? Can you post your image and show where you want to do the splitting?
Zara Khan
le 24 Fév 2018
Image Analyst
le 25 Fév 2018
OK, but does this mean that the center of the quadrants will be located at the center of the blob, or at the center of the image? And I presume that edges parallel with the edges of the image are okay? And that it's okay if each quadrant does not have the same number of pixels in it?
Réponse acceptée
Plus de réponses (2)
I'm not sure why or even how you'd use a loop.
[height, width, ncols] = size(yourimage);
splitimages = mat2cell(yourimage, [height height]/2, [width width]/2, ncols)
Your four images are splitimages{1}, splitimages{2}, splitimages{3}, and splitimages{4}.
To find the number of white pixels in each subimage:
numwhitepixels = cellfun(@(subimg) sum(sum(all(subimg == 1, 3))), splitimages); %assuming images of type double, where white == 1
edit: stupidly forgot the image argument to mat2cell!
sumaiya khan
le 7 Déc 2018
0 votes
How can I diagnolly divide the image into 4 quadrants using the centroid of the blob ?
Catégories
En savoir plus sur Data Type Identification dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!







