Ruled Line

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

Ruled Line

Alex Cummins
>Is there a way to draw a line wrapping around an object then placing tick
>marks at specific location. And finally taking that line and
>straightening it out maintaining the placement of the tick marks.
The final product being a straight line with the tick marks that can be
saved alone and or cut and pasted into a separate document.
Thank you
Alex
>
>

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

Re: Ruled Line

Jerome Mutterer-3
Dear Alex,
The following macro tool does this.
Draw the wrapping line first, and add it to the ROI manager pressing T,
then you can add tick marks using the custom tool.
All lines end in the ROI manager, so to get your 'final product', you could
create an empty copy of your image, draw all rois on it, restore the first
roi and run the straighten command.
Sincerely,

Jerome

macro "tick marks Tool - C00cT0f16T" {
if (roiManager('count')<1) exit("add at least one ROI the the roiManager");
roiManager("Show All");
getCursorLoc(x, y, z, flags);
roiManager('select',0);
run("Interpolate", "interval=1 adjust");
getSelectionCoordinates(xp, yp);
while (flags&16!=0) {
Overlay.clear;
getCursorLoc(x, y, z, flags);
d=getWidth;
for (i=0;i<xp.length;i++) {
di =  sqrt ((x-xp[i])*(x-xp[i])+(y-yp[i])*(y-yp[i]));
if (di<d) { d=di; cp = i;
}
Overlay.drawLine(x, y, xp[cp], yp[cp]);
Overlay.show;
wait(50);
}
makeLine(x, y, xp[cp], yp[cp]);
roiManager('add');
roiManager('select',0);
}

/////


On 15 September 2015 at 11:15, Cummins, Alex (NIH/NIMH) [E] <
[hidden email]> wrote:

>
> >Is there a way to draw a line wrapping around an object then placing tick
> >marks at specific location. And finally taking that line and
> >straightening it out maintaining the placement of the tick marks.
> The final product being a straight line with the tick marks that can be
> saved alone and or cut and pasted into a separate document.
> Thank you
> Alex
> >
> >
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html




--
Jerome Mutterer
CNRS - Institut de biologie moléculaire des plantes
12, rue du Général Zimmer
67084 Strasbourg Cedex
www.ibmp.cnrs.fr

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

Re: Ruled Line

Jerome Mutterer-3
Dear Alex,
I'm sorry I deleted a curly brace while cleaning the code, so the macro in
the previous mail doesn't work. Please rather try this version, in which I
added a second tool that outputs the final line with the ticks:
https://gist.github.com/mutterer/6c19cf27938c81256f64

You can also see it in action there:
http://youtu.be/QdSwDSB2JkA

Sincerely,
Jerome


On 16 September 2015 at 15:26, Jerome Mutterer <
[hidden email]> wrote:

> Dear Alex,
> The following macro tool does this.
> Draw the wrapping line first, and add it to the ROI manager pressing T,
> then you can add tick marks using the custom tool.
> All lines end in the ROI manager, so to get your 'final product', you
> could create an empty copy of your image, draw all rois on it, restore the
> first roi and run the straighten command.
> Sincerely,
>
> Jerome
>
> macro "tick marks Tool - C00cT0f16T" {
> if (roiManager('count')<1) exit("add at least one ROI the the roiManager");
> roiManager("Show All");
> getCursorLoc(x, y, z, flags);
> roiManager('select',0);
> run("Interpolate", "interval=1 adjust");
> getSelectionCoordinates(xp, yp);
> while (flags&16!=0) {
> Overlay.clear;
> getCursorLoc(x, y, z, flags);
> d=getWidth;
> for (i=0;i<xp.length;i++) {
> di =  sqrt ((x-xp[i])*(x-xp[i])+(y-yp[i])*(y-yp[i]));
> if (di<d) { d=di; cp = i;
> }
> Overlay.drawLine(x, y, xp[cp], yp[cp]);
> Overlay.show;
> wait(50);
> }
> makeLine(x, y, xp[cp], yp[cp]);
> roiManager('add');
> roiManager('select',0);
> }
>
> /////
>
>
> On 15 September 2015 at 11:15, Cummins, Alex (NIH/NIMH) [E] <
> [hidden email]> wrote:
> >
> > >Is there a way to draw a line wrapping around an object then placing
> tick
> > >marks at specific location. And finally taking that line and
> > >straightening it out maintaining the placement of the tick marks.
> > The final product being a straight line with the tick marks that can be
> > saved alone and or cut and pasted into a separate document.
> > Thank you
> > Alex
> > >
> > >
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
>
>
>
> --
> Jerome Mutterer
> CNRS - Institut de biologie moléculaire des plantes
> 12, rue du Général Zimmer
> 67084 Strasbourg Cedex
> www.ibmp.cnrs.fr
>



--
Jerome Mutterer
CNRS - Institut de biologie moléculaire des plantes
12, rue du Général Zimmer
67084 Strasbourg Cedex
www.ibmp.cnrs.fr

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