MATLAB: How to calculate sum of black pixel in binary image

image analysisImage Processing Toolbox

I need to find sum of all black pixels present in my input image. How can I do it in simple way thanks in advance

Best Answer

Try this:
numBlackPixels = sum(yourImage == 0);