calculate the enclosed area within an image

6 visualizaciones (últimos 30 días)
YJ
YJ el 29 de Ag. de 2014
Respondida: Image Analyst el 29 de Ag. de 2014
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)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Respuesta aceptada

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

Más respuestas (0)

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by