How can I count the pixels in a black and white image?

1 vue (au cours des 30 derniers jours)
Mara Pereira
Mara Pereira le 8 Juil 2020
How can I count the pixels in a black and white image?

Réponses (1)

Image Analyst
Image Analyst le 8 Juil 2020
Try this:
numberOfPixels = numel(binaryImage)
numberOfWhitePixels = nnz(binaryImage)
numberOfBlackPixels = numberOfPixels - numberOfWhitePixels

Community Treasure Hunt

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

Start Hunting!

Translated by