MATLAB: How can i calculate the area of ​​the white part of this image

Image Processing Toolboximage segmentationthis is a work of medical image processing segmentation and i need to know how can i calculate the area of ​​the white part of this image?

01NT.bmp

Best Answer

Here are two ways:
[imarray,cmap] = imread('01NT.bmp');
im225 = zeros(size(imarray));
im255 = zeros(size(imarray));
im225(imarray==225) = 1;
im255(imarray==255) = 1;
fprintf(1,'Number of white pixels == 255: %d\n',sum(im255(:)));
fprintf(1,'Number of grey pixels == 225: %d\n',sum(im225(:)));
fprintf(1,'\nBlob-by-blob area of white (value=255)\n');
a = bwlabel(im255,8);
stats = regionprops(a,im255,'All');
totalArea = 0;
for iblob = 1:length(stats)
fprintf(1,'Area(%d) = %d\n',iblob,stats(iblob).Area);
totalArea = totalArea + stats(iblob).Area;
end
fprintf(1,'Number of pixels == 255 (white): %d\n\n',totalArea);
fprintf(1,'\nBlob-by-blob area of grey (value=225)\n');
a = bwlabel(im225,8);
stats = regionprops(a,im255,'All');
totalArea = 0;
for iblob = 1:length(stats)
fprintf(1,'Area(%d) = %d\n',iblob,stats(iblob).Area);
totalArea = totalArea + stats(iblob).Area;
end
fprintf(1,'Number of pixels == 255 (grey): %d\n\n',totalArea);