How a binary image can be divided into four equal parts using loop ?
Mostrar comentarios más antiguos
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 comentarios
Image Analyst
el 23 de Feb. de 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
el 24 de Feb. de 2018
Image Analyst
el 25 de Feb. de 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?
Respuesta aceptada
Más respuestas (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
el 7 de Dic. de 2018
0 votos
How can I diagnolly divide the image into 4 quadrants using the centroid of the blob ?
Categorías
Más información sobre Data Type Identification en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!







