Login  Register

Re: arrow measurement

Posted by Rasband, Wayne (NIH/NIMH) [E] on Jun 19, 2010; 4:36am
URL: http://imagej.273.s1.nabble.com/arrow-measurement-tp3687888p3687889.html

On Jun 18, 2010, at 7:31 PM, rustyconc wrote:

> Hi,
>
> I'm looking for a way to measure locations and angles in an image.
> Ideally, I would be able to click and drag an arrow from one location to
> another to create an arrow or line selection.  The measures I'm after would
> be start position and angle.  Length would likely also be useful in the
> future, and end position could also work since a little trig could calculate
> the angle.
>
> Using the line select tool doesn't work for this, since the start and end
> locations are swapped in the results table, depending on their relative
> locations.  What I need is the first clicked location to consistently show
> up in one column in the results window, and the second clicked location in
> another column.  To help with alignment, it is critical for the line to be
> visible while selecting the second point (so just selecting two points won't
> work).  
>
> I've done a few searches and haven't come up with anything that works well.
> Any suggestions?

You can do this with a simple macro. This macro, when your press "1", displays the starting coordinates and angle of a line or arrow selection.

-wayne

  macro "Measure Arrow [1]" {
     if (selectionType!=5)
        exit("Line or arrow selection required");
     getLine(x1, y1, x2, y2, lineWidth);
     dx = x2-x1;
     dy = y1-y2;
     angle = (180.0/PI)*atan2(dy, dx);
     n = nResults;
     setResult("X", n, x1);
     setResult("Y", n, y1);
     setResult("Angle", n, angle);
     updateResults;
  }