how to calculate irregular shape area in the image

hi..i have i project that need me to detect and extract the irregular shape in the image.then i should to calculate the area in the unit cm.can you help me,how can i detect the irregular shape in the image automatic and how can i calculate that irregular shape area.i hope you can help me.Thank you.

8 Comments

http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers
Assuming cm is centimeters, I don't know how you could extract an area in it because centimeters are a meaure of length not area. Do you mean cm^2?
owh..sorry..yes i mean cm^2..do you now how can i get the total area that i already extract it?
sir i have a doubt ....in order to find the area ....first the image has to be clear of all noise and other irregularities right sir ? ....after all these rectifications is it necessary the image has to be segmented before finding the area ?
The image only has to be free of noise and irregularities that would change the area to within the accuracy you need.
For example, whether a particular pixel reading is 82 or 83 (because gaussian noise caused the reading to be higher than it "really" should be) does not matter if your threshold for inclusion of the location is (say) 39.
You might not need to segment, depending on what you are doing. Image Analyst indicates that segmentation is needed much less frequently than most people tend to expect.
To find the area you may need to segment your image. If you just want to define the area's vertices somehow, like with roipoly() or imfreehand(), then you can get the area with polyarea(). However if the area is defined by something like intensity, texture, or whatever, then you need to segment the image. Segmentation means undergoing a series of steps such as filtering or morphology or something until you eventually get to an image that can be thresholded to form a binary image (your segmented image). With that binary image you can then label it with bwlabel() or bwconncomp() and then call regionprops(). Or you can call bwarea() for a different definition of area, weighted by how the boundary winds around, whereas regionprops() gives area as a simple count of pixels in the blobs.
What is the unit of area

Sign in to comment.

Answers (3)

Hi,
Given your example I would suggest this approach:
after your edge detection:
create structural element of radius 4 (or 5 or whatever works for you)
dilate your edge map
erode (with the same strel)
imclearborder
create metric to eliminate "noise" (you can do something similar to circle detection : perimeter/area)
determine the area (in pixels; you need to know the spatial resolution of your initial image to obtain it in cm2).
Hope this helps.
Regards, Florin

10 Comments

what's do you mean about structural element of radius 4?my image irregular shape.is it suitable? emm...can you help me to create the source code?thank you.
Hello,
In the code you gave us, you actually use a structural element. The command strel creates one. Look at the help of that command and create a circular strel of radius 4 or 5.
circular strel of radius 4 or 5?i cannot find it..can u find it to me?i just find strel 'disk' only..
Hello,
Yes disk works. Try something like :
se=strel('disk',4);
do you know how to calculate area for irregular shape in cm2?
Number of pixels in the area, multiplied by the real-world area represented by one pixel -- which you would need external information to calculate.
There is nothing in the image you posted earlier that would allow anyone calculate the real-world area represented by one pixel.
If your original picture (from the camera) is in JPEG or TIFF mode, there is a possibility that your camera recorded EXIF information that included the camera aperture (not uncommon) and the focus distance (not so common). Sometimes the EXIF information has enough information to estimate real-world distances... but more often it does not.
You need a scale of some sort in the image, or else you need to have some real-world physical distances measured. There is no way to calculate real-world distances from an image alone.
http://www.mathworks.com/matlabcentral/answers/18380-getting-x-and-y-for-3d
so how i can solve my problem?i need it urgent.i do not know the real area for 1 pixel..
Have you imaged your known object yet? When you have, call improfile() to interactively get the length by calculating the two line endpoints that improfile will provide to you. Then you conversion factor is your real world length (e.g. 10 mm) divided by the number of pixels that the distance is.
Urgency does not make the impossible possible.
Perhaps, though, it would be appropriate to ask about your accuracy goals. If your accuracy goals are not especially high, then you could make use of the average of the real-world measurements that have been studied; see http://uclue.com/?xq=4504

Sign in to comment.

You might be able to adapt my BlobsDemo tutorial to your image:

11 Comments

how about i want to detect and extract automatic for cataract in the eye.do you have any idea to detect and extract that cataract automatically?I use the source code below but it cannot extract the irregular shape for cataract in the eye accurate.And i want to ask the function of [junk threshold]?
Below is my source code:
I = imread('C:\Users\WISH\Desktop\image catarcts\images1.jpg');
bw=im2bw(I);
edge_sobel= edge(bw,'sobel');
se90 = strel('line', 3, 90);
se0 = strel('line', 3, 0);
edge_sobeldil = imdilate(edge_sobel, [se90 se0]);
BWdfill = imfill(edge_sobeldil,'holes');
BWnobord = imclearborder(BWdfill, 4);
seD = strel('diamond',1);
BWfinal = imerode(BWnobord,seD);
BWfinal = imerode(BWfinal,seD);
BWoutline = bwperim(BWfinal);
Segout = I;
Segout(BWoutline) = 255;
http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers
[URL=http://imageshack.us/photo/my-images/834/images1zpw.jpg/][IMG]http://img834.imageshack.us/img834/6446/images1zpw.jpg[/IMG][/URL]
Uploaded with [URL=http://imageshack.us]ImageShack.us[/URL]
i'm already upload the image at above url..i hope.i can get my solution for this problem.thank you.
I can't see it. I clicked around 6 things on that page and still can't see it. Try tinypic.com instead.
i cannot upload the picture in tinypic.com...can you give another choice?
Corrected URL:
http://img834.imageshack.us/img834/6446/images1zpw.jpg
norfiazayu, please do not include the [URL] and so on. This forum does not recognize [URL] tags anywhere, and the comments section (here) does not recognize any formatting codes at all.
http://s1195.photobucket.com/albums/aa399/faizayu/
oppss..sorry...these is my new link for my image that refer to my source code.i hope you can help me to get the source code.
walter Roberson: can you help me?any suggestion you can give me for the source code?
Image Analyst:how about you?can you help me?
How about a threshold, a borderclearing, and a sum?
i cannot do the threshold..always error.what's mean for threshold?border clearing already there.sum for what?i didn't get the source code for area.can u help me?

Sign in to comment.

how to find area from contour plots????

1 Comment

Contour() returns the coordinates. You could then use polyarea() or poly2mask() followed by regionprops().

Sign in to comment.

Asked:

on 28 Dec 2011

Commented:

on 12 Apr 2019

Community Treasure Hunt

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

Start Hunting!