MATLAB Answers

0

How can i measure length interactively in axes in gui?

Asked by Abarairenji on 6 Aug 2012
Latest activity Answered by Image Analyst
on 7 Jan 2014
I need to use interactive rulers for one of my axes in my gui. I need to measure length of a line i draw interactively in image. And see its length. All of my pictures are 20cm x 20cm so i know the lenght of my image so it will be easier. But i dont know how can i do it interactively in my gui creating ruler button. Thanks for helps...
Respectfully yours; Abarairenji

  0 Comments

Sign in to comment.

2 Answers

Answer by Image Analyst
on 7 Jan 2014
 Accepted Answer

Use imdistline() in the Image Processing Toolbox.

  0 Comments

Sign in to comment.


Answer by Caleb
on 8 Aug 2012

You should be able to use something like this:
figure;
axis manual
ruler = imline(gca);
% Get original position
pos = getPosition(ruler);
% Get updated position as the ruler is moved around
id = addNewPositionCallback(ruler,@(pos) title(mat2str(pos,3)));
You can use the getPosition function to get the original position and as you stretch it or drag it around, you use addNewPositionCallback to get the updated position. From here you can calculate the length using Pythagorean's theorem.

  1 Comment

You need Image Processing Toolbox.

Sign in to comment.