Counting black pixels in a binary image

How can I write a code to count the black pixels and the white pixels in a binary image?

 Respuesta aceptada

Turlough Hughes
Turlough Hughes el 15 de Dic. de 2019
Let's say you have a binary image B. You can get the number of black pixels by:
numBlack=nnz(~B);
and the number of white pixels by:
numWhite=nnz(B);

2 comentarios

Turlough Hughes
Turlough Hughes el 15 de Dic. de 2019
Fatema, did this help/work?
fatema ali
fatema ali el 15 de Dic. de 2019
Yes it did, thank you.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Image Processing Toolbox en Centro de ayuda y File Exchange.

Preguntada:

el 15 de Dic. de 2019

Comentada:

el 15 de Dic. de 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by