calculate the enclosed area within an image

4 views (last 30 days)
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)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Accepted Answer

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

More Answers (0)

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!