MATLAB: Bwarea & area, white/black ratio

bwarearegionpropswhite/black ratio

Hi,
Can someone please explain me what is the difference of bwarea & area.
I have an image which is black and white (after segmentation and fill) & I wish to calculate the area of an object (as I understand done by bwarea) relative to the image area (imageArea = regionprops(image_name, 'Area')), more or less calculating the white/black ratio.
Any other ideas is welcome.
Thanks.

Best Answer

They use different algorithms. regionprops gives the number of pixels while bwarea gives some kind of weighted area that depends on the shape of the boundary. This is described in the documentation for bwarea
The white to black ratio is
totalPixels = numel(binaryImages);
numWhitePixels = sum(binaryImage(:));
numBlackPixels = totalPixels - numWhitePixels;
ratio = numWhitePixels / numBlackPixels;