image center.
the code as follows.
function).
Jerome.
> Jerome,
>
> I incorporated your algorithm into a macro for a researcher in Germany,
> and it works beautifully! Thank you. I need one more element, which is
> the ability to have the grid randomly set rather than always starting in
> the same place. I know there is the random function, but I am having
> difficulty applying it to this situation. I want the starting point of the
> grid to be random, but I do not want the ditance between lines to vary, and
> the starting point must vary with the image's calibration, so that the
> range of starting points is within one step value, i.e., step = distance
> between lines. Do you have any insights?
>
> Here is my code so far:
>
> // ********** begin macro **********
>
> drawLines(30, 100);
>
> function drawLines(angle, step) {
> max = maxOf(getWidth,getHeight);
> a = PI*angle/180;
>
> xc=getWidth/2;
> yc=getHeight/2;
> Overlay.remove;
>
> for (i=-1*floor(max/step);i<max/step;i++) {
> Overlay.moveTo(xc- max*cos(a)+i*step*sin(a),
> yc+max*sin(a)+i*step*cos(a));
> Overlay.lineTo(xc+ max*cos(a)+i*step*sin(a),
> yc-max*sin(a)+i*step*cos(a)); }
> Overlay.show;
> }
>
> // ********** end macro **********
>
> Thank you so much,
>
> Chris Coulon
> gaiag.net
>
> On May 9, 2014, at 9:00 AM, Jerome Mutterer <
>
[hidden email]> wrote:
>
> > Dear Chris,
> > You're right, these are good ideas. Here's an updated version, where the
> > grid is centerd on the image.
> > The angle can be set in the tool's option dialog, and manually adjusted
> if
> > you drag the mouse more than 20 pixels.
> > Sincerely,
> > Jerome.
> >
> > // a tool that overlays a grid on the image with adjustable angle and
> step.
> > var step =50;
> > var angle =45;
> > macro "Grid Tool - C00cT1f1aG" {
> > max = maxOf(getWidth,getHeight);
> > getCursorLoc(x0, y0, z, flags);
> > while (flags&16!=0) {
> > getCursorLoc(x, y, z, flags);
> > distance = sqrt((x-x0)*(x-x0)+(y-y0)*(y-y0));
> > if (distance>20) { a = atan2(x-x0, y-y0);}
> > else { a = PI*angle/180;}
> > showStatus("step:"+step+" px; angle:"+d2s(180*a/PI,2)+" degrees");
> > xc=getWidth/2;
> > yc=getHeight/2;
> > Overlay.remove;
> > for (i=-1*floor(max/step);i<max/step;i++) {
> > Overlay.moveTo(xc- max*cos(a)+i*step*sin(a),
> yc+max*sin(a)+i*step*cos(a));
> > Overlay.lineTo(xc+ max*cos(a)+i*step*sin(a),
> yc-max*sin(a)+i*step*cos(a));
> > Overlay.moveTo(xc- max*sin(a)+i*step*cos(a), yc-
> max*cos(a)-i*step*sin(a));
> > Overlay.lineTo(xc+ max*sin(a)+i*step*cos(a), yc+
> max*cos(a)-i*step*sin(a));
> > }
> > Overlay.show;
> > wait(50);
> > }
> > }
> >
> > macro "Grid Tool Options" {
> > Dialog.create("Grid");
> > Dialog.addNumber("Step (in pixels):", step);
> > Dialog.addNumber("Angle (in degrees):", angle);
> > Dialog.show();
> > step = Dialog.getNumber();
> > angle = Dialog.getNumber();
> > }
> >
> >
> >
> >
> > On 9 May 2014 15:47, christopher of the family hunt coulon <
> >
[hidden email]> wrote:
> >>
> >> Thanks Jerome!
> >>
> >> Interesting approach. I like the rotation feature -- I could have used
> > that in a project last year! :-) However, I think for a practical tool
> > for most purposes, it would be best for the user to enter the angle they
> > would like for the grid, then the grid would cover the entire image. In
> > this instance -- I realize this is only a proof of concept -- the grid's
> > origin is the clicked point, and it is rotated about the point of origin;
> > not too useful as a tool for the whole image, but it would work for a
> > smaller ROI. Cool idea! :-)
> >>
> >> Chris Coulon
> >> gaiag.net
> >>
> >> On May 9, 2014, at 1:30 AM, Jerome Mutterer <
> >
[hidden email]> wrote:
> >>
> >>> Dear Chris,
> >>>
> >>> the following macro tool allows you to paint an overlay grid.
> >>> The angle is adjusted as you're dragging the mouse.
> >>> The grid step is the tool's option.
> >>>
> >>> Jerome
> >>>
> >>>
> >>> // a tool that overlays a grid on the image with adjustable angle and
> > step.
> >>> var step =50;
> >>> macro "Grid Tool - C00cT1f1aG" {
> >>> max = maxOf(getWidth,getHeight);
> >>> getCursorLoc(x0, y0, z, flags);
> >>> while (flags&16!=0) {
> >>> getCursorLoc(x, y, z, flags);
> >>> a = atan2(x-x0, y-y0);
> >>> showStatus("step:"+step+" px; angle:"+d2s(180*a/PI,2)+" degrees");
> >>> Overlay.remove;
> >>> for (i=0;i<max/step;i++) {
> >>> Overlay.moveTo(x0+i*step*sin(a), y0+i*step*cos(a));
> >>> Overlay.lineTo(x0+ max*cos(a)+i*step*sin(a),
> > y0-max*sin(a)+i*step*cos(a));
> >>> Overlay.moveTo(x0+i*step*cos(a), y0-i*step*sin(a));
> >>> Overlay.lineTo(x0+ max*sin(a)+i*step*cos(a), y0+
> > max*cos(a)-i*step*sin(a));
> >>> }
> >>> Overlay.show;
> >>> wait(10);
> >>> }
> >>> }
> >>> macro "Grid Tool Options" {
> >>> step = getNumber("Step (in pixels):", step);
> >>> }
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> On 6 May 2014 10:05, Straatman, Kees (Dr.) <
[hidden email]>
> wrote:
> >>>>
> >>>> Dear Chris,
> >>>>
> >>>> Try Image > Selection > Rotate
> >>>>
> >>>> Best wishes
> >>>>
> >>>> Kees
> >>>>
> >>>>
> >>>> Dr Ir K.R. Straatman
> >>>> Senior Experimental Officer
> >>>> Centre for Core Biotechnology Services
> >>>> University of Leicester
> >>>>
> >>>
> >
>
http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/lite/aif> >>>>
> >>>> -----Original Message-----
> >>>> From: ImageJ Interest Group [mailto:
[hidden email]] On Behalf Of
> >>> christopher of the family hunt coulon
> >>>> Sent: 05 May 2014 23:09
> >>>> To:
[hidden email]
> >>>> Subject: Rotate grid?
> >>>>
> >>>> Is there a way to rotate a nondestructive grid by an arbitrary angle?
> > I
> >>> couldn't find any way to do this via a web search and would like to
> > avoid
> >>> working this out if it has already been done.
> >>>>
> >>>> Thanks in advance,
> >>>>
> >>>> Chris Coulon
> >>>> --
> >>>> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html> >>>>
> >>>> --
> >>>> 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
> >>> T 0367155339
> >>> www.ibmp.cnrs.fr
> >>>
> >>> --
> >>> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html> >>
> >> --
> >> 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
> > T 0367155339
> > www.ibmp.cnrs.fr
> >
> > --
> > ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>