arrow measurement

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

arrow measurement

rustyconc
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?

Thanks in advance,
Russell
Reply | Threaded
Open this post in threaded view
|

Re: arrow measurement

Rasband, Wayne (NIH/NIMH) [E]
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;
  }
Reply | Threaded
Open this post in threaded view
|

Re: arrow measurement

rustyconc
Thanks very much Wayne - exactly what I was looking for.

Regards,
Russell