How to calculate area in a binary image?

32 ビュー (過去 30 日間)
Asmalina Mohamed Saat
Asmalina Mohamed Saat 2020 年 9 月 17 日
コメント済み: Image Analyst 2020 年 10 月 13 日
I have two questions to ask:
1) How to calculate area at the white region in binary image?
2) How to convert the answer of area unit that get from matlab into cm^2 or mm^2 (SI UNIT)?
here I attach the original image and binary image (this image is marine growth on the fiberglass plate)

採用された回答

Deepak Meena
Deepak Meena 2020 年 9 月 22 日
Hi Asmalina,
1) To find the area in pixel size we just need to find the number of white pixel which would be
area = bwarea(bw);%bw is your binary threshold image
The unit would be pixel
2) To find the area in real world units , you need to find out how big one pixel is in appropraite units, if you working with DICOM image refer to this answer.
Another way is we can find the percentage of white area so if you have the plate area , you can find out the actual white area then.
to find out the percentage area:
percentageWhite = nnz(bw) / numel(bw);
  5 件のコメント
Image Analyst
Image Analyst 2020 年 9 月 25 日
The file format on disk doesn't matter (though hopefully it's not a lossy bad format like JPG). Once it's read into MATLAB, it's just a regular numerical array. It doesn't matter what format it was on disk before that. So you either have the calibration data in the metadata of the image, in which case you can simply start using it, or you don't which means you'll have to create it, such as by drawing a known distance on the image.
Asmalina Mohamed Saat
Asmalina Mohamed Saat 2020 年 10 月 1 日
編集済み: Asmalina Mohamed Saat 2020 年 10 月 1 日
i have another questions;
1)can I used this way to get the distance or area in real world units (SI unit)?
calibrationFactor = length of the image in cm/length of the image in pixel;
distanceInCm = distanceInPixels * calibrationFactor;
areaInSquareCm = areaInPixels * calibrationFactor ^ 2
2) what is distanceInPixels, is it same value with length of the image in pixel?
3) is it areaInPixels is the value i get after i used this formula
(area = bwarea(bw);%bw is your binary threshold image)?

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2020 年 9 月 22 日
See my attached spatial calibration demo.
  12 件のコメント
Asmalina Mohamed Saat
Asmalina Mohamed Saat 2020 年 10 月 13 日
and number of white pixel?, it's will be same unit with total number of pixel (square cm) or only in cm?
Image Analyst
Image Analyst 2020 年 10 月 13 日
The number of white pixels is, of course, unitless. It's just simply a count, like 235 or 14983 or whatever. It can have an area in pixels or square cm but the count is obviously just a number and has no units at all.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGet Started with Image Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by