Hi everyone,
I have a very simple question about moving a rectangular ROI in an image using the keyboard. The idea is to set the correct position where a second image has to be pasted (in the first one). Sometimes by using arrow keys I can move the selection to x and y negative coordinate obtaining the correct positioning of the pasted image. However some other times after pasting the image and pressing the arrows, I can only move the selection (and not the pasted image) until the border without reaching negative values. Thanks for the help Mario Mario Faretta Department of Experimental Oncology European Institute of Oncology via Adamello 16 20139 Milan Italy Phone: +390294375027 email: [hidden email] --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
HI Michael,
thanks for the useful info. The operations I described should occur during a macro execution: the macro pastes an image into a calculated position, then, by calling the waitForUser() function, the macro execution is suspended. The user can consequently correct the positioning if necessary before the macro goes on. I am not an expert so I was wondering if in these conditions the ROI.endPaste is automatically called. Thanks again for the help Mario I am not a programmer On 2016-08-18 18:05, Michael Schmid wrote: > Hi Mario, > > after pasting an image or image part, you should be able to move the > pasted contents it until > - you select a different image or a panel such as B&C > (Brightness&Contrast) [the Threshold panel seems to do no harm], or > - you do something that deletes the ROI, e.g. by clicking outside of > it, or > - there is something that modifies or could potentially modify your > image. > > Technically speaking, for the last point, e.g. everything that > implements the PlugInFilter interface causes a call to Roi.endPaste. > This includes not only image modification operations but also many > read-only operations, such as image analysis and saving. > > If you lose the capability to move the ROI contents after a paste > operation without any obvious reason, what ImageJ & Java version and > operating system do you have? > (I have not seen such a problem with my computer so far, using ImageJ > 1.51f; Java 1.6.0_65 [64-bit]; Mac OS X 10.6.8) > > Michael > ________________________________________________________________ > On 2016-08-18 12:47, mfaretta wrote: >> Hi everyone, >> I have a very simple question about moving a rectangular ROI in an >> image >> using the keyboard. >> The idea is to set the correct position where a second image has to be >> pasted (in the first one). >> Sometimes by using arrow keys I can move the selection to x and y >> negative coordinate obtaining the correct positioning of the pasted >> image. >> However some other times after pasting the image and pressing the >> arrows, I can only move the selection (and not the pasted image) until >> the border without reaching negative values. >> Thanks for the help >> Mario >> >> Mario Faretta >> Department of Experimental Oncology >> European Institute of Oncology >> via Adamello 16 >> 20139 Milan >> Italy >> Phone: +390294375027 >> email: [hidden email] >> >> >> --- >> This email has been checked for viruses by Avast antivirus software. >> https://www.avast.com/antivirus >> >> -- >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Mario,
when a macro is running, the paste operation does not allow moving the pasted contents after the paste operation. I guess that this is meant to avoid accidentally shifting the contents when a user presses an arrow key. This also applies during the 'wait for user' dialog. I see two ways out: (1) stop your macro, and ask the user to continue with another macro after pasting and adjusting the position (e.g. with one of the F1...F12 keys) (2) Instead of 'Paste', use an overlay. The user can shift overlays during the 'wait for user' dialog. Then determine the position of the overlay, remove it, create a rectangle there and paste the image into that place. Unfortunately, it seems there is no Overlay.getBounds(index, x, y, width, height) macro command, you would have to decode the getInfo("overlay") string, which is not very nice. Here is a proof-of-concept macro: run("Blobs (25K)"); w=getWidth(); h=getHeight(); newImage("PasteGoesHere", "8-bit white", 300, 300, 1); selectWindow("blobs.gif"); selectWindow("PasteGoesHere"); run("Add Image...", "image=blobs.gif x=10 y=10 opacity=100"); Overlay.activateSelection(Overlay.size-1); waitForUser("Move the overlay, then press OK"); getInfo("overlay"); Michael ________________________________________________________________ On 2016-08-18 18:57, Mario Faretta wrote: > HI Michael, > thanks for the useful info. > The operations I described should occur during a macro execution: the > macro pastes an image into a calculated position, then, by calling the > waitForUser() function, the macro execution is suspended. The user can > consequently correct the positioning if necessary before the macro goes > on. I am not an expert so I was wondering if in these conditions the > ROI.endPaste is automatically called. > Thanks again for the help > Mario > > I am not a programmer > On 2016-08-18 18:05, Michael Schmid wrote: >> Hi Mario, >> >> after pasting an image or image part, you should be able to move the >> pasted contents it until >> - you select a different image or a panel such as B&C >> (Brightness&Contrast) [the Threshold panel seems to do no harm], or >> - you do something that deletes the ROI, e.g. by clicking outside of >> it, or >> - there is something that modifies or could potentially modify your >> image. >> >> Technically speaking, for the last point, e.g. everything that >> implements the PlugInFilter interface causes a call to Roi.endPaste. >> This includes not only image modification operations but also many >> read-only operations, such as image analysis and saving. >> >> If you lose the capability to move the ROI contents after a paste >> operation without any obvious reason, what ImageJ & Java version and >> operating system do you have? >> (I have not seen such a problem with my computer so far, using ImageJ >> 1.51f; Java 1.6.0_65 [64-bit]; Mac OS X 10.6.8) >> >> Michael >> ________________________________________________________________ >> On 2016-08-18 12:47, mfaretta wrote: >>> Hi everyone, >>> I have a very simple question about moving a rectangular ROI in an image >>> using the keyboard. >>> The idea is to set the correct position where a second image has to be >>> pasted (in the first one). >>> Sometimes by using arrow keys I can move the selection to x and y >>> negative coordinate obtaining the correct positioning of the pasted >>> image. >>> However some other times after pasting the image and pressing the >>> arrows, I can only move the selection (and not the pasted image) until >>> the border without reaching negative values. >>> Thanks for the help >>> Mario >>> >>> Mario Faretta >>> Department of Experimental Oncology >>> European Institute of Oncology >>> via Adamello 16 >>> 20139 Milan >>> Italy >>> Phone: +390294375027 >>> email: [hidden email] >>> >>> >>> --- >>> This email has been checked for viruses by Avast antivirus software. >>> https://www.avast.com/antivirus >>> >>> -- >>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Mario,
thanks to a hint from Wayne, it can be done without an Overlay.getBounds macro command. Here is an example: // This macro allows the user to interactively move an image // as an overlay and then pastes the image to the position // selected by the user run("Blobs (25K)"); run("Copy"); newImage("PasteGoesHere", "8-bit black", 300, 300, 1); run("Invert LUT"); //to make it fit the Blobs selectWindow("PasteGoesHere"); run("Add Image...", "image=blobs.gif x=10 y=10 opacity=100"); Overlay.activateSelection(Overlay.size-1); waitForUser("Move the overlay, then press OK"); Overlay.activateSelection(Overlay.size-1); Overlay.removeSelection(Overlay.size-1); run("Paste"); run("Select None"); In contrast to moving a pasted image (which is not possible while a macro is running), you will see a rectangle around the overlay. I you like, you can make the rectangle transparent with run("Overlay Options...", "stroke=#00ffffff width=0 fill=none apply"); Note that you could resize the overlay image with the handles, but the the macro won't paste a resized image. If you have an 8-bit or RGB image, you could use 'flatten image' to create an image with the inserted overlay instead of 'Paste', then you can also resize the image. Michael ________________________________________________________________ On 2016-08-18 20:47, Michael Schmid wrote: > Hi Mario, > > when a macro is running, the paste operation does not allow moving the > pasted contents after the paste operation. I guess that this is meant to > avoid accidentally shifting the contents when a user presses an arrow > key. This also applies during the 'wait for user' dialog. > > I see two ways out: > (1) stop your macro, and ask the user to continue with another macro > after pasting and adjusting the position (e.g. with one of the F1...F12 > keys) > (2) Instead of 'Paste', use an overlay. The user can shift overlays > during the 'wait for user' dialog. Then determine the position of the > overlay, remove it, create a rectangle there and paste the image into > that place. Unfortunately, it seems there is no Overlay.getBounds(index, > x, y, width, height) macro command, you would have to decode the > getInfo("overlay") string, which is not very nice. > > Here is a proof-of-concept macro: > run("Blobs (25K)"); > w=getWidth(); > h=getHeight(); > newImage("PasteGoesHere", "8-bit white", 300, 300, 1); > selectWindow("blobs.gif"); > selectWindow("PasteGoesHere"); > run("Add Image...", "image=blobs.gif x=10 y=10 opacity=100"); > Overlay.activateSelection(Overlay.size-1); > waitForUser("Move the overlay, then press OK"); > getInfo("overlay"); > > Michael > ________________________________________________________________ > > On 2016-08-18 18:57, Mario Faretta wrote: >> HI Michael, >> thanks for the useful info. >> The operations I described should occur during a macro execution: the >> macro pastes an image into a calculated position, then, by calling the >> waitForUser() function, the macro execution is suspended. The user can >> consequently correct the positioning if necessary before the macro goes >> on. I am not an expert so I was wondering if in these conditions the >> ROI.endPaste is automatically called. >> Thanks again for the help >> Mario >> >> I am not a programmer >> On 2016-08-18 18:05, Michael Schmid wrote: >>> Hi Mario, >>> >>> after pasting an image or image part, you should be able to move the >>> pasted contents it until >>> - you select a different image or a panel such as B&C >>> (Brightness&Contrast) [the Threshold panel seems to do no harm], or >>> - you do something that deletes the ROI, e.g. by clicking outside of >>> it, or >>> - there is something that modifies or could potentially modify your >>> image. >>> >>> Technically speaking, for the last point, e.g. everything that >>> implements the PlugInFilter interface causes a call to Roi.endPaste. >>> This includes not only image modification operations but also many >>> read-only operations, such as image analysis and saving. >>> >>> If you lose the capability to move the ROI contents after a paste >>> operation without any obvious reason, what ImageJ & Java version and >>> operating system do you have? >>> (I have not seen such a problem with my computer so far, using ImageJ >>> 1.51f; Java 1.6.0_65 [64-bit]; Mac OS X 10.6.8) >>> >>> Michael >>> ________________________________________________________________ >>> On 2016-08-18 12:47, mfaretta wrote: >>>> Hi everyone, >>>> I have a very simple question about moving a rectangular ROI in an >>>> image >>>> using the keyboard. >>>> The idea is to set the correct position where a second image has to be >>>> pasted (in the first one). >>>> Sometimes by using arrow keys I can move the selection to x and y >>>> negative coordinate obtaining the correct positioning of the pasted >>>> image. >>>> However some other times after pasting the image and pressing the >>>> arrows, I can only move the selection (and not the pasted image) until >>>> the border without reaching negative values. >>>> Thanks for the help >>>> Mario >>>> >>>> Mario Faretta >>>> Department of Experimental Oncology >>>> European Institute of Oncology >>>> via Adamello 16 >>>> 20139 Milan >>>> Italy >>>> Phone: +390294375027 >>>> email: [hidden email] >>>> >>>> >>>> --- >>>> This email has been checked for viruses by Avast antivirus software. >>>> https://www.avast.com/antivirus >>>> >>>> -- >>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html >> >> -- >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Dear Michael,
thanks a lot for the useful info. If someone is interested, I also found another solution to bypass the problem. I created an image of an "arrow keyboard" with some "buttons" corresponding to the arrow keys: if this image is active and the user press one the button (sensed by the getCursorLoc) the macro execute the cut and paste of the target image with an effect identical to moving the original ROI. If the image is active the macro is in a sort of pausing. When the user closes the "keyboard image" then the final coordinates were stored and the macro goes on to the next step. Thanks again for the help Mario Mario Faretta Department of Experimental Oncology European Institute of Oncology via Adamello 16 20139 Milan Italy Phone: +390294375027 email: [hidden email] ------ Original Message ------ From: "Michael Schmid" <[hidden email]> To: [hidden email] Sent: 8/19/2016 10:31:36 AM Subject: Re: Basic question about ROI positioning by Keyboard Arrows >Hi Mario, > >thanks to a hint from Wayne, it can be done without an >Overlay.getBounds macro command. Here is an example: > > // This macro allows the user to interactively move an image > // as an overlay and then pastes the image to the position > // selected by the user > > run("Blobs (25K)"); > run("Copy"); > newImage("PasteGoesHere", "8-bit black", 300, 300, 1); > run("Invert LUT"); //to make it fit the Blobs > selectWindow("PasteGoesHere"); > run("Add Image...", "image=blobs.gif x=10 y=10 opacity=100"); > Overlay.activateSelection(Overlay.size-1); > waitForUser("Move the overlay, then press OK"); > Overlay.activateSelection(Overlay.size-1); > Overlay.removeSelection(Overlay.size-1); > run("Paste"); > run("Select None"); > >In contrast to moving a pasted image (which is not possible while a >macro is running), you will see a rectangle around the overlay. I you >like, you can make the rectangle transparent with > run("Overlay Options...", "stroke=#00ffffff width=0 fill=none >apply"); > >Note that you could resize the overlay image with the handles, but the >the macro won't paste a resized image. If you have an 8-bit or RGB >image, you could use 'flatten image' to create an image with the >inserted overlay instead of 'Paste', then you can also resize the >image. > > >Michael >________________________________________________________________ >On 2016-08-18 20:47, Michael Schmid wrote: >>Hi Mario, >> >>when a macro is running, the paste operation does not allow moving the >>pasted contents after the paste operation. I guess that this is meant >>to >>avoid accidentally shifting the contents when a user presses an arrow >>key. This also applies during the 'wait for user' dialog. >> >>I see two ways out: >>(1) stop your macro, and ask the user to continue with another macro >>after pasting and adjusting the position (e.g. with one of the >>F1...F12 >>keys) >>(2) Instead of 'Paste', use an overlay. The user can shift overlays >>during the 'wait for user' dialog. Then determine the position of the >>overlay, remove it, create a rectangle there and paste the image into >>that place. Unfortunately, it seems there is no >>Overlay.getBounds(index, >>x, y, width, height) macro command, you would have to decode the >>getInfo("overlay") string, which is not very nice. >> >>Here is a proof-of-concept macro: >> run("Blobs (25K)"); >> w=getWidth(); >> h=getHeight(); >> newImage("PasteGoesHere", "8-bit white", 300, 300, 1); >> selectWindow("blobs.gif"); >> selectWindow("PasteGoesHere"); >> run("Add Image...", "image=blobs.gif x=10 y=10 opacity=100"); >> Overlay.activateSelection(Overlay.size-1); >> waitForUser("Move the overlay, then press OK"); >> getInfo("overlay"); >> >>Michael >>________________________________________________________________ >> >>On 2016-08-18 18:57, Mario Faretta wrote: >>>HI Michael, >>>thanks for the useful info. >>>The operations I described should occur during a macro execution: the >>>macro pastes an image into a calculated position, then, by calling >>>the >>>waitForUser() function, the macro execution is suspended. The user >>>can >>>consequently correct the positioning if necessary before the macro >>>goes >>>on. I am not an expert so I was wondering if in these conditions the >>>ROI.endPaste is automatically called. >>>Thanks again for the help >>>Mario >>> >>>I am not a programmer >>>On 2016-08-18 18:05, Michael Schmid wrote: >>>>Hi Mario, >>>> >>>>after pasting an image or image part, you should be able to move the >>>>pasted contents it until >>>>- you select a different image or a panel such as B&C >>>>(Brightness&Contrast) [the Threshold panel seems to do no harm], or >>>>- you do something that deletes the ROI, e.g. by clicking outside of >>>>it, or >>>>- there is something that modifies or could potentially modify your >>>>image. >>>> >>>>Technically speaking, for the last point, e.g. everything that >>>>implements the PlugInFilter interface causes a call to Roi.endPaste. >>>>This includes not only image modification operations but also many >>>>read-only operations, such as image analysis and saving. >>>> >>>>If you lose the capability to move the ROI contents after a paste >>>>operation without any obvious reason, what ImageJ & Java version and >>>>operating system do you have? >>>>(I have not seen such a problem with my computer so far, using >>>>ImageJ >>>>1.51f; Java 1.6.0_65 [64-bit]; Mac OS X 10.6.8) >>>> >>>>Michael >>>>________________________________________________________________ >>>>On 2016-08-18 12:47, mfaretta wrote: >>>>>Hi everyone, >>>>>I have a very simple question about moving a rectangular ROI in an >>>>>image >>>>>using the keyboard. >>>>>The idea is to set the correct position where a second image has to >>>>>be >>>>>pasted (in the first one). >>>>>Sometimes by using arrow keys I can move the selection to x and y >>>>>negative coordinate obtaining the correct positioning of the pasted >>>>>image. >>>>>However some other times after pasting the image and pressing the >>>>>arrows, I can only move the selection (and not the pasted image) >>>>>until >>>>>the border without reaching negative values. >>>>>Thanks for the help >>>>>Mario >>>>> >>>>>Mario Faretta >>>>>Department of Experimental Oncology >>>>>European Institute of Oncology >>>>>via Adamello 16 >>>>>20139 Milan >>>>>Italy >>>>>Phone: +390294375027 >>>>>email: [hidden email] >>>>> >>>>> >>>>>--- >>>>>This email has been checked for viruses by Avast antivirus >>>>>software. >>>>>https://www.avast.com/antivirus >>>>> >>>>>-- >>>>>ImageJ mailing list: http://imagej.nih.gov/ij/list.html >>> >>>-- >>>ImageJ mailing list: http://imagej.nih.gov/ij/list.html > >-- >ImageJ mailing list: http://imagej.nih.gov/ij/list.html --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |