MATLAB Answers

0

How do I save the distance using imdist function and then perform additional calculations?

Asked by Rashid Taskin on 13 Aug 2018
Latest activity Edited by Rashid Taskin on 14 Aug 2018

I'm trying to use the imdist function after plotting a graph. I'm not entirely sure how I can use the imdist to save the distance that I'm interested in and then perform additional calculations.

My code is as follows:

 hold on
plot(x, y, 'b.')
plot(x1, y1, 'r.')
 hold off
 h = imdistline;
 fcn = makeConstrainToRectFcn('imline',...
                              get(gca,'XLim'),get(gca,'YLim'));
 setDragConstraintFcn(h,fcn); 

Any help will be appreciated. Thanks!

  0 Comments

Sign in to comment.

1 Answer

Answer by Stephen Cobeldick on 13 Aug 2018
 Accepted Answer

" I'm not entirely sure how I can use the imdist to save the distance that I'm interested in and then perform additional calculations."

Read the imdistline help. It explains at the top that the "function returns h, a handle to an imdistline object". Then it lists all of the functions of that object. You will probably be interested in wait and getDistance.

  2 Comments

Hi Stephen, Thanks for the help. It actually did work.

    position= wait(h);  %double click in ROI to get distance 
    dist= getDistance(h); 
    disp(dist); 

Sign in to comment.