How a binary image can be divided into four equal parts using loop ?
Mostra commenti meno recenti
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 Commenti
Image Analyst
il 23 Feb 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
il 24 Feb 2018
Image Analyst
il 25 Feb 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?
Risposta accettata
Più risposte (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
il 7 Dic 2018
0 voti
How can I diagnolly divide the image into 4 quadrants using the centroid of the blob ?
Categorie
Scopri di più su Data Type Identification in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!







