Hi ImageJ Mailing list,
Please could someone help me out a little? I've written a plugin to control hardware in Micro-manager. I have the need to add an overlay to the images displayed in IJ. Using the macro language I have previously written tools that add an overlay to just the active image, but in this instance I'd like to add an overlay to all images that are open and have it added to new images as they are captured. Please could someone give me a clue about how to go about this? So far I have this: <snip> ImagePlus imp = IJ.getImage(); int width = imp.getWidth(); int height = imp.getHeight(); GeneralPath path = new GeneralPath(); path.moveTo(width/2 -20, height/2); path.lineTo(width/2 + 20, height /2); path.moveTo(width/2, height/2 +20); path.lineTo(width/2, height /2 -20); Roi roi = new ShapeRoi(path); roi.setStrokeColor(Color.red); Overlay overlay = new Overlay(roi); imp.setOverlay(overlay); </snip> This performs the basic function I'm after, but I'd like to be able to somehow make this function add the overlay to new images that are acquired or displayed live. I have a checkbox in my plugin's GUI that I'd like to use to turn this feature on or off. I'm not quite sure how to get this to behave in this way. Any ideas or suggestions greatly appreciated. Thank you in advance! Best regards, Ed |
Hi...
Maybe you can use the following function: WindowManager.toFront(YourImagePlusObject.getWindow()); regards, Markus Am 07.10.2011 12:28, schrieb edsimmons: > Hi ImageJ Mailing list, > > Please could someone help me out a little? > > I've written a plugin to control hardware in Micro-manager. I have the need > to add an overlay to the images displayed in IJ. > > Using the macro language I have previously written tools that add an overlay > to just the active image, but in this instance I'd like to add an overlay to > all images that are open and have it added to new images as they are > captured. > > Please could someone give me a clue about how to go about this? > > So far I have this: > > <snip> > ImagePlus imp = IJ.getImage(); > int width = imp.getWidth(); > int height = imp.getHeight(); > GeneralPath path = new GeneralPath(); > path.moveTo(width/2 -20, height/2); > path.lineTo(width/2 + 20, height /2); > path.moveTo(width/2, height/2 +20); > path.lineTo(width/2, height /2 -20); > Roi roi = new ShapeRoi(path); > roi.setStrokeColor(Color.red); > Overlay overlay = new Overlay(roi); > imp.setOverlay(overlay); > </snip> > > This performs the basic function I'm after, but I'd like to be able to > somehow make this function add the overlay to new images that are acquired > or displayed live. I have a checkbox in my plugin's GUI that I'd like to use > to turn this feature on or off. I'm not quite sure how to get this to behave > in this way. > > Any ideas or suggestions greatly appreciated. > > Thank you in advance! > > Best regards, > Ed > > > -- > View this message in context: http://imagej.588099.n2.nabble.com/Using-the-overlay-from-a-plugin-tp6868832p6868832.html > Sent from the ImageJ mailing list archive at Nabble.com. |
In reply to this post by edsimmons
Hi Ed,
On Fri, 7 Oct 2011, edsimmons wrote: > Using the macro language I have previously written tools that add an > overlay to just the active image, but in this instance I'd like to add > an overlay to all images that are open and have it added to new images > as they are captured. For the existing ImagePlus instances, you can use WindowManager's getIDList() and getImage(id) methods. For an example, see http://fiji.sc/GenericDialogPlus.java#l64 For new images, you can add an ImageListener: http://fiji.sc/javadoc/ij/ImagePlus.html#addImageListener(ij.ImageListener) Ciao, Johannes |
Hi Ed,
[re-Cc:ing the ImageJ list] On Fri, 7 Oct 2011, Ed Simmons wrote: > On 7 October 2011 19:32, Johannes Schindelin <[hidden email]>wrote: > > > On Fri, 7 Oct 2011, edsimmons wrote: > > > > > Using the macro language I have previously written tools that add an > > > overlay to just the active image, but in this instance I'd like to > > > add an overlay to all images that are open and have it added to new > > > images as they are captured. > > > > For the existing ImagePlus instances, you can use WindowManager's > > getIDList() and getImage(id) methods. For an example, see > > http://fiji.sc/GenericDialogPlus.java#l64 > > > > For new images, you can add an ImageListener: > > http://fiji.sc/javadoc/ij/ImagePlus.html#addImageListener(ij.ImageListener) > > Thanks for the suggestions, I've succeeded in adding an ImageListener > and can trigger the drawing of the overlay on any image that is opened > with IJ. Good. > However this fails to draw the overlay on the one place I really need > it, on the live image view from MicroManager. Do you have any idea what > would need to be done differently to allow this? I did not realise that > this approach would have this result... > > The plugin I've written is a plugin to MM not ImageJ if this makes a > difference. It makes a difference... :-) The live image is an ImagePlus, but apparently the ImageWindow is not registered with the WindowManager, so might be the reason why you do not get it from the existing images. From the source: fiji.sc/cgi-bin/gitweb.cgi?p=micromanager1.4/.git;a=blob;f=mmstudio/src/org/micromanager/MMStudioMainFrame.java;h=d7932700dcde2c8071b381cf594ef1c7b6e35f63;hb=refs/heads/svn/git-svn#l3089 You can get a reference to the live image window (if there is any, it can be null) using the getImageWin() method of MMStudioMainFrame: fiji.sc/cgi-bin/gitweb.cgi?p=micromanager1.4/.git;a=blob;f=mmstudio/src/org/micromanager/MMStudioMainFrame.java;h=d7932700dcde2c8071b381cf594ef1c7b6e35f63;hb=refs/heads/svn/git-svn#l294 To get the current instance of the GUI (which is available as 'gui' in Beanshell, but is not offered via the ScriptingInterface), call the static method getInstance(): fiji.sc/cgi-bin/gitweb.cgi?p=micromanager1.4/.git;a=blob;f=mmstudio/src/org/micromanager/MMStudioMainFrame.java;h=d7932700dcde2c8071b381cf594ef1c7b6e35f63;hb=refs/heads/svn/git-svn#l2454 Ciao, Johannes |
Free forum by Nabble | Edit this page |