calculate the enclosed area within an image

4 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by