calculate the enclosed area within an image

6 ビュー (過去 30 日間)
YJ
YJ 2014 年 8 月 29 日
回答済み: Image Analyst 2014 年 8 月 29 日
I have a set of experiment images and need to analyse base on that.
with image, I have to calculate the area that are enclosed, which is 1 and 2, and neglect the area of 3,4 as it touches the boundary.
So is there way find the black area that touches the boundary?
Here is what I have done so far.
I am thinking of finding a area of 3 and 4 by setting a condition and subtract them from total black area (1,2,3,4).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Area calculation%
a=imread ('rose.jpg'); % read image
b= reb2gray (a); %chagne to gray image
c= im2bw(b) % change to black and white image
total = bwarea(c)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

採用された回答

Image Analyst
Image Analyst 2014 年 8 月 29 日
Not quite. You have to invert c and call imclearborder
regions1and2 = imclearborder(~c);
area = bwarea(regions1and2); % or sum(regions1and2(:)) - slightly different calculation.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by