Can I calculate the amount of black and white pixels inside a freehand region?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Koen van Assen
el 1 de Mzo. de 2018
Respondida: Amy Haskins
el 1 de Mzo. de 2018
I have created a binary image. What I want to do is select a certain region of it with freehand and then find the total number of white and black pixels, as well as the total amount of pixels in that particular region. Is this possible?
hFH = imfreehand();
Image1=hFH.createMask();
numberOfPixels1 = sum(Image1(:)) %this gives the total number of pixels in the freehand region
nBlack1 = sum(Image1(:)==0); %But how about the number of black pixels because this does not work
0 comentarios
Respuesta aceptada
Amy Haskins
el 1 de Mzo. de 2018
The mask just tells you which pixels are in the region. To count the black pixels within the mask, you need to look at both in the region and the value in the original image. Something like this:
nBlack1 = sum(sum(Image1 & ~origImage))
0 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!