Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I count the number of white pixels in a binary image with MATLAB?

How can I count the number of white pixels in a binary image with MATLAB?

like image 279
Wassim AZIRAR Avatar asked May 20 '10 15:05

Wassim AZIRAR


People also ask

How do you find the pixels of an image in MATLAB?

To determine the values of one or more pixels in an image and return the values in a variable, use the impixel function. You can specify the pixels by passing their coordinates as input arguments or you can select the pixels interactively using a mouse.


1 Answers

The function NNZ should do the trick, since "white" is represented as 1 and "black" as 0 in a binary image img:

nWhite = nnz(img);
like image 87
gnovice Avatar answered Nov 08 '22 01:11

gnovice