How to calculate the surface area of an object in an image?

조회 수: 27 (최근 30일)
Ahmed Alsmaeil
Ahmed Alsmaeil 2021년 8월 20일
댓글: Image Analyst 2021년 8월 20일
Dear all,
I want to calculate the surface area of the object in this image. I appreciate the help!
  댓글 수: 1
DGM
DGM 2021년 8월 20일
Think about it. You'll need a reference. Do you have a reference? What is it? Are the lines in the image a reference?
You can reduce the image to a logical mask. That will give you the sectional area. (bwarea, regionprops)
If you actually want the surface area of a 3D solid, you're going to have to make some assumptions. A simple assumption would be that the object is rotationally-symmetric. The rest is basic math.
So do you have a reference? Is surface area required, or is sectional area sufficient?

댓글을 달려면 로그인하십시오.

채택된 답변

DGM
DGM 2021년 8월 20일
This will calculate both the sectional area and the surface area in pixel-equivalent units. You'll have to scale them according to whatever reference you have.
inpict = rgb2gray(imread('62-high.png'));
% generate binary image of object alone
m = ~imbinarize(inpict,'adaptive','foregroundpolarity','dark','sensitivity',0.50);
m = bwareafilt(imclearborder(m),1);
st = strel('disk',20);
m = imerode(~bwareafilt(imerode(~m,st),1),st);
imshow(m)
% calculate areas
d = sum(m,1);
d = d(d~=0);
Asurf = sum(pi*d) % assuming rotational symmetry
Asect = sum(m,'all')
  댓글 수: 2
Ahmed Alsmaeil
Ahmed Alsmaeil 2021년 8월 20일
Thank you so much for the help. this works just fine. I'll redo the calculations with my scaling factor.
Image Analyst
Image Analyst 2021년 8월 20일
Like I said below, just make sure you multiply Asect by (cmPerPixel ^2) and not cmPerPixel because you're getting an area measurement, not a distance measurement.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2021년 8월 20일
You really need to get better photos. Can't you at least increase the illumination or exposure time? And it would be best to put the object on black velvet or some contrasting uniform background.
That said, you cannot get the surface area unless you make some assumptions. You can segment the object (coccoon or whatever it is), and then if you assume it has a spherical cross section, you can find the area from pi*diameter for each column thorough the object then sum up the area for each column.
You'll need to calibrate the image to cm or mm first. So take a photo of a scale/ruler and spatially calibrate to get a value of cm per pixels. Then you can multiply the pixel measurements by that calibration factor to get the distance or area in cm or cm^2. See my attached demo.
  댓글 수: 1
Ahmed Alsmaeil
Ahmed Alsmaeil 2021년 8월 20일
Thank you so much. I do have the scale and will input them in the code. Appreciate the demo and help!!

댓글을 달려면 로그인하십시오.

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by