Can a selection be spatially translated by specifying the delta_X and delta_Y?

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

Can a selection be spatially translated by specifying the delta_X and delta_Y?

Neil Fazel
I often start with a large image, crop it down to a smaller image, then create selections (e.g. using the Wand Tool) on the smaller image and do my analysis there. When I'm done, it would be nice to take the selection created on the smaller image and restore it on the original (larger) image.

I tried Edit -> Selection -> Restore Selection; it transfers the selection and rescales it properly, but since it doesn't know how I cropped the image, it can't position the selection correctly. I guess it's up to me to then re-position the selection. Is there a way to shift a (possibly composite) selection horizontally by delta_X and vertically by delta_Y?

I could use the arrow bars to move the selection, but it's slow. I'm looking for something like Image -> Transform -> Translate... but for selections.

Thanks,
Neil

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

Re: Can a selection be spatially translated by specifying the delta_X and delta_Y?

Michael Schmid
Hi Neil,

you can easily write a macro for this:

//Get the current x, y of the selection
  getSelectionBounds(x, y, width, height);

//Ask the user how far to move it
  Dialog.create("Translate Selection");
  Dialog.addNumber("Delta_X", 10, 0, 5, "pixels");
  Dialog.addNumber("Delta_Y", 10, 0, 5, "pixels");
  Dialog.show();
  dx=Dialog.getNumber();
  dy=Dialog.getNumber();
       
//To move the selection
  setSelectionLocation(x+dx, y+dy);

Michael
________________________________________________________________
On Jun 24, 2014, at 19:51, Neil Fazel wrote:

> I often start with a large image, crop it down to a smaller image, then create selections (e.g. using the Wand Tool) on the smaller image and do my analysis there. When I'm done, it would be nice to take the selection created on the smaller image and restore it on the original (larger) image.
>
> I tried Edit -> Selection -> Restore Selection; it transfers the selection and rescales it properly, but since it doesn't know how I cropped the image, it can't position the selection correctly. I guess it's up to me to then re-position the selection. Is there a way to shift a (possibly composite) selection horizontally by delta_X and vertically by delta_Y?
>
> I could use the arrow bars to move the selection, but it's slow. I'm looking for something like Image -> Transform -> Translate... but for selections.
>
> Thanks,
> Neil
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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

Re: Can a selection be spatially translated by specifying the delta_X and delta_Y?

Neil Fazel
In reply to this post by Neil Fazel
Hi Michael,

    Thanks for the tip! setSelectionLocation() is just what I was looking for.

Best regards,
Neil

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

Re: Can a selection be spatially translated by specifying the delta_X and delta_Y?

Neil Fazel
In reply to this post by Neil Fazel
I thought I also add that while looking up setSelectionLocation(x, y) in the macro language manual, I came across a mention of the existing macro RoiManagerMoveSelections.txt, which uses setSelectionLocation() to translate a selection using the ROI manager. (It's in the ImageJ/macros directory.)

Neil

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