How can I count the number of white pixels in a binary image with 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.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With