Line measuring

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

Line measuring

Alex Cummins
I would like to draw a freeform line. Then add 1mm tic marks. And then straighten that line or reform it as needed without distorting the line length or tic marks.
Is this something I can easily do?

Alex

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Line measuring

Michael Schmid
On Sep 6, 2012, at 15:03, Alex Cummins wrote:

> I would like to draw a freeform line. Then add 1mm tic marks. And then straighten that line or reform it as needed without distorting the line length or tic marks.
> Is this something I can easily do?
>
> Alex
________________________________________________________________

Hi Alex,

assuming that 'straighten the line' means straightening the image along the line, as shown in
  http://rsb.info.nih.gov/ij/docs/guide/146-27.html#sub:Straighten...

It's easier if you first straighten the line and then add the tick marks.
- Draw the line (right-cklick the line tool and select 'Freehand line')
- Double-click the line tool, set a large width, and 'Spline Fit'
- Edit>Selection>Straighten

For the tick marks, you can write a short macro, something along this line (assumes you have a scaled image with mm units):

//creates a non-destructive overlay with the ticks
getPixelSize(unit, pixelWidth, pixelHeight);
firstTickPosition = 0.5; // in mm from left side of image
tickLength = 5; //pixels
tickPosFromTop = 10; //pixels
nTicks = 5;
for (i=0; i< nTicks; i++) {
  x = (i+ firstTickPosition)/pixelWidth;
  makeLine(x, tickPosFromTop, x, tickPosFromTop+ tickLength);
  run("Add Selection...", "stroke=black width=3");
}

Michael

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html