How to calculate distance in centimeters using IMDISTLINE?

3 visualizaciones (últimos 30 días)
karishma
karishma el 4 de Oct. de 2013
Comentada: Image Analyst el 8 de Sept. de 2022
i want to find out height of a sleeping infant. for that i want to find out the distance in cm. using 'imdistline' i'm getting the distance in pixels but how to convert that in cm?

Respuesta aceptada

Image Analyst
Image Analyst el 4 de Oct. de 2013
Editada: Image Analyst el 4 de Oct. de 2013
Put a ruler, a tape measure, a standard sheet of paper, or anything else of known length into the scene. Then snap a picture of it and use imdistline() to find the length in pixels. For example, let's say you laid down a sheet of A4 paper and measured it's distance as 2100 pixels. Knowing that it is 21 cm long, you get a spatial calibration factor of 21/2100, which you multiply your distances in pixels by to get the distance in cm. Multiply by that calibration factor squared to convert the area in pixels to the area in square centimeters.
calibrationFactor = 21/2100;
distanceInCm = distanceInPixels * calibrationFactor;
areaInSquareCm = areaInPixels * calibrationFactor ^ 2;
It's in the FAQ.
See my demo attached below for a really nice demo.
  5 comentarios
Kanwarpal
Kanwarpal el 7 de Sept. de 2022
hi.. how can i find distance in pixels?
Image Analyst
Image Analyst el 8 de Sept. de 2022
@Kanwarpal evidently you have not tried my demo attached above, because that will do it.

Iniciar sesión para comentar.

Más respuestas (2)

Roche de Guzman
Roche de Guzman el 30 de En. de 2021
global h; h = imdistline; % activates the fx for drawing and measuring line
setLabelTextFormatter(h,'measure'); % message
addNewPositionCallback(h,@ShowDistance); % new position callback
%% Custom fx
function ShowDistance(pos)
global h xc yc; % sets line handles and x and y conversion factors to global
X = pos(:,1)*xc; Y = pos(:,2)*yc; % converts x and y positions from px to target unit
d = norm(diff([X Y])); % distance in target unit
setLabelTextFormatter(h,[num2str(d,'%.1f') ' target unit']); % updates measurement
end
  1 comentario
Image Analyst
Image Analyst el 30 de En. de 2021
I like how you put in so many comments. I wish everyone would do that.

Iniciar sesión para comentar.


Matt J
Matt J el 4 de Oct. de 2013
Multiply by the length (in cm) of one pixel.
  9 comentarios
Image Analyst
Image Analyst el 12 de Feb. de 2015
Editada: Image Analyst el 12 de Feb. de 2015
I don't see how. POST YOUR IMAGE IN A NEW QUESTION , not here , and perhaps I'd change my mind or give you other suggestions.
leylin fatqiyah
leylin fatqiyah el 12 de Feb. de 2015
this is my image https://www.mathworks.com/matlabcentral/answers/177673-how-to-measuring-curve-line-of-an-image
thank you

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by