how can i calculate the area of ​​the white part of this image?

1 回表示 (過去 30 日間)
Inês
Inês 2020 年 1 月 5 日
編集済み: Meg Noah 2020 年 1 月 6 日
01NT.bmp
  3 件のコメント
Image Analyst
Image Analyst 2020 年 1 月 6 日
Didn't we do this already? That image looks familiar. I believe I remember telling you to get a binary image
binaryImage = grayImage > lowThreshold & grayImage <= highThreshold;
Then count the number of pixels in the mask with nnz(), bwarea(), or sum():
numberOfPixels = nnz(binaryImage);
Inês
Inês 2020 年 1 月 6 日
I mean white with intensity 1.
It is the first time that i make this question. Thank you for answer me

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

採用された回答

Meg Noah
Meg Noah 2020 年 1 月 6 日
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);
  2 件のコメント
Inês
Inês 2020 年 1 月 6 日
It was a good help, thank you!
Meg Noah
Meg Noah 2020 年 1 月 6 日
編集済み: Meg Noah 2020 年 1 月 6 日
You're quite welcome.You can do unique(imarray(:)) or histogram(imarray(:)) to find what the values are in the image.

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by