Counting black pixels in a binary image
9 views (last 30 days)
Show older comments
fatema ali
on 15 Dec 2019
Commented: fatema ali
on 15 Dec 2019
How can I write a code to count the black pixels and the white pixels in a binary image?
0 Comments
Accepted Answer
Turlough Hughes
on 15 Dec 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 Comments
More Answers (0)
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!