MATLAB: How to count image binary

digital image processingimageimage processingImage Processing Toolboximage segmentation

Hi all
if i have binary image, how to calculate the white pixel, and black pixel?

Best Answer

Let's say input binary image is image_bw
result=bwareafilt(image_bw,1,'Largest');
count_w=sum(result);
fprintf('The white pixel count is: %d',count_w);