how to calculate irregular shape area in the image
Show older comments
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
Walter Roberson
on 28 Dec 2011
http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers
Sean de Wolski
on 28 Dec 2011
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?
norfaizayu
on 31 Dec 2011
Mansi N
on 15 May 2017
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 ?
Walter Roberson
on 15 May 2017
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.
Image Analyst
on 15 May 2017
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.
Piya
on 11 Apr 2019
What is the unit of area
Image Analyst
on 12 Apr 2019
Pixels.
Answers (3)
Florin Neacsu
on 4 Jan 2012
1 vote
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
norfaizayu
on 5 Jan 2012
Florin Neacsu
on 5 Jan 2012
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.
norfaizayu
on 6 Jan 2012
Florin Neacsu
on 9 Jan 2012
Hello,
Yes disk works. Try something like :
se=strel('disk',4);
norfaizayu
on 26 Jan 2012
Walter Roberson
on 26 Jan 2012
Number of pixels in the area, multiplied by the real-world area represented by one pixel -- which you would need external information to calculate.
Walter Roberson
on 26 Jan 2012
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
norfaizayu
on 26 Jan 2012
Image Analyst
on 26 Jan 2012
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.
Walter Roberson
on 26 Jan 2012
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
Image Analyst
on 28 Dec 2011
0 votes
You might be able to adapt my BlobsDemo tutorial to your image:
11 Comments
norfaizayu
on 28 Dec 2011
Walter Roberson
on 28 Dec 2011
http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers
norfaizayu
on 1 Jan 2012
Image Analyst
on 1 Jan 2012
I can't see it. I clicked around 6 things on that page and still can't see it. Try tinypic.com instead.
norfaizayu
on 3 Jan 2012
Walter Roberson
on 3 Jan 2012
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.
norfaizayu
on 3 Jan 2012
norfaizayu
on 3 Jan 2012
norfaizayu
on 4 Jan 2012
Sean de Wolski
on 4 Jan 2012
How about a threshold, a borderclearing, and a sum?
norfaizayu
on 5 Jan 2012
Gyaneshwar dubacharla
on 22 Jan 2016
0 votes
how to find area from contour plots????
1 Comment
Image Analyst
on 22 Jan 2016
Contour() returns the coordinates. You could then use polyarea() or poly2mask() followed by regionprops().
Categories
Find more on Image Arithmetic 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!