Overlay question

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Overlay question

Cammer, Michael-2
Perhaps I missed this in the recent discussions of overlays, but I have a question I hope someone can help with.


When I put text overlay on a slice in a stack but typig the text and adding the overlay from the menu, the overlay is only displayed on one slice.


However, in a macro when I use a command such as

    Overlay.drawString(outputstrings[i-1], 260, 290);

the overlay is displayed on the entire stack, not just the one slice.


Also, based on the recorder, I tried

    Overlay.drawString(outputstrings[i-1], 260, 290, 0.0);

but this is the same.


Help greatly appreciated.


Best regards-

Michael Cammer, Sr Research Scientist, DART Microscopy Laboratory

NYU Langone Health, 540 First Avenue, SK2 Microscopy Suite, New York, NY  10016

[hidden email]<mailto:[hidden email]>  http://nyulmc.org/micros  http://microscopynotes.com/

Voice direct only, no text or messages:  1-914-309-3270 and 1-646-501-0567


------------------------------------------------------------
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email.
=================================

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

Re: Overlay question

Wayne Rasband-2
> On Nov 15, 2018, at 10:35 PM, Cammer, Michael <[hidden email]> wrote:
>
> Perhaps I missed this in the recent discussions of overlays, but I have a question I hope someone can help with.
>
> When I put text overlay on a slice in a stack but typig the text and adding the overlay from the menu, the overlay is only displayed on one slice.
>
> However, in a macro when I use a command such as
>
>    Overlay.drawString(outputstrings[i-1], 260, 290);
>
> the overlay is displayed on the entire stack, not just the one slice.

Use Overlay.setPosition(slice) to specify which slice the text is displayed on. Here is an example:

  newImage("Untitled", "8-bit noise", 500, 500, 5);
  setFont("SansSerif", 40, " antialiased");
  setColor("cyan");
  Overlay.drawString("This text only appears\non the third slice.", 20, 200);
  Overlay.setPosition(3)
  Overlay.show();
  setSlice(3);

Use Overlay.setPosition(0) to have the text displayed on the entire stack.

> Also, based on the recorder, I tried
>
>    Overlay.drawString(outputstrings[i-1], 260, 290, 0.0);
>
> but this is the same.

The fourth argument is the angle.

-wayne

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

Re: Overlay question

Kenneth Sloan-3
Please allow me to hijack this thread to thank Wayne (and others) for help on my Overlay questions.

As it turned out, I could not use the standard BrushTool - but their help made it easier for
me to implement my own code to annotate a stack (create an Overlay from an image, edit the Overlay
and finally extract the edited image).

What I learned: the Overlay feature is very useful, and *can* be used by several different non-cooperating
processes simultaneously, but this requires great care in writing each individual piece of code.  It is
all too easy to assume (and I am guilty of this, as well) that your code is the only game in town.

As I say - the necessary mechanisms for sharing Overlays all seem to be in place; the problem is in
making sure that user-level plugins/macros don't step on each other's toes.

In my case, I originally thought that I wanted two distinct Objects to manipulate an Overlay on a stack.  When this
proved difficult, I took the easy way out and duplicated the stack.  As it happens, this actually lead to an improvement
in the interface I was building.  I eventually saw a way to make it happen on one stack - but by that time I
had realized that the two-stack solution was preferable.  So...lazy me...I filed this away in my "lessons learned"
folder.  I'll try realHard to write cleaner code...next time.

In particular:

a) don't blindly use setOverlay() without first checking to see if an Overlay already exists - either
manipulate an existing Overlay or save it and restore it when you are done.
b) attach NAMES to Rois that you create/manipulate
c) use the NAMES to identify the Roi you want to manipulate - do not depend on TYPE or POSITION
   in the list of Rois in an Overlay
d) document the NAMES to facilitate interactions between plugins/macros that you did not initially expect.
e) which leads to...worry about namespace problems

Again, thanks to Wayne (and others who responded) for showing me the way forward.

--
Kenneth Sloan
[hidden email]
Vision is the art of seeing what is invisible to others.

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

Recorder bug

Fred Damen
Greetings,

Plugins->Macros->Record... (Java)

Compile and Run:
import ij.*;
import ij.io.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.*;
import ij.plugin.frame.*;

public class DirectoryChooserBug implements PlugIn {
   public void run(String arg) {
      DirectoryChooser dc = new DirectoryChooser("Select");
      String sdir = dc.getDirectory();
      }
}

Click Cancel and Receive(Windows/Linux):
ImageJ 1.52h; Java 1.8.0_112 [64-bit]; Windows 7 6.1; 53MB of 12219MB (<1%)

java.lang.NullPointerException
        at ij.plugin.frame.Recorder.fixPath(Recorder.java:135)
        at ij.plugin.frame.Recorder.recordPath(Recorder.java:415)
        at ij.io.DirectoryChooser.getDirectory(DirectoryChooser.java:118)
        at DirectoryChooserBug.run(DirectoryChooserBug.java:12)
        at ij.plugin.PlugInExecuter.runCompiledPlugin(Compiler.java:323)
        at ij.plugin.PlugInExecuter.run(Compiler.java:312)
        at java.lang.Thread.run(Thread.java:745)

Fred

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

Re: Recorder bug

Wayne Rasband-2
> On Nov 19, 2018, at 3:26 PM, Fred Damen <[hidden email]> wrote:
>
> Greetings,
>
> Plugins->Macros->Record... (Java)

The latest ImageJ daily build (1.52i48) fixes a bug that could cause a NullPointerException when recording a file path.

-wayne


> Compile and Run:
> import ij.*;
> import ij.io.*;
> import ij.process.*;
> import ij.gui.*;
> import java.awt.*;
> import ij.plugin.*;
> import ij.plugin.frame.*;
>
> public class DirectoryChooserBug implements PlugIn {
>   public void run(String arg) {
>      DirectoryChooser dc = new DirectoryChooser("Select");
>      String sdir = dc.getDirectory();
>      }
> }
>
> Click Cancel and Receive(Windows/Linux):
> ImageJ 1.52h; Java 1.8.0_112 [64-bit]; Windows 7 6.1; 53MB of 12219MB (<1%)
>
> java.lang.NullPointerException
> at ij.plugin.frame.Recorder.fixPath(Recorder.java:135)
> at ij.plugin.frame.Recorder.recordPath(Recorder.java:415)
> at ij.io.DirectoryChooser.getDirectory(DirectoryChooser.java:118)
> at DirectoryChooserBug.run(DirectoryChooserBug.java:12)
> at ij.plugin.PlugInExecuter.runCompiledPlugin(Compiler.java:323)
> at ij.plugin.PlugInExecuter.run(Compiler.java:312)
> at java.lang.Thread.run(Thread.java:745)
>
> Fred

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

Re: Recorder bug

Robert Smith
Thanks Wayne!!!!
Bob
________________________________
From: Wayne Rasband <[hidden email]>
Sent: Monday, November 19, 2018 11:21 PM
To: [hidden email]
Subject: Re: Recorder bug

> On Nov 19, 2018, at 3:26 PM, Fred Damen <[hidden email]> wrote:
>
> Greetings,
>
> Plugins->Macros->Record... (Java)

The latest ImageJ daily build (1.52i48) fixes a bug that could cause a NullPointerException when recording a file path.

-wayne


> Compile and Run:
> import ij.*;
> import ij.io.*;
> import ij.process.*;
> import ij.gui.*;
> import java.awt.*;
> import ij.plugin.*;
> import ij.plugin.frame.*;
>
> public class DirectoryChooserBug implements PlugIn {
>   public void run(String arg) {
>      DirectoryChooser dc = new DirectoryChooser("Select");
>      String sdir = dc.getDirectory();
>      }
> }
>
> Click Cancel and Receive(Windows/Linux):
> ImageJ 1.52h; Java 1.8.0_112 [64-bit]; Windows 7 6.1; 53MB of 12219MB (<1%)
>
> java.lang.NullPointerException
>        at ij.plugin.frame.Recorder.fixPath(Recorder.java:135)
>        at ij.plugin.frame.Recorder.recordPath(Recorder.java:415)
>        at ij.io.DirectoryChooser.getDirectory(DirectoryChooser.java:118)
>        at DirectoryChooserBug.run(DirectoryChooserBug.java:12)
>        at ij.plugin.PlugInExecuter.runCompiledPlugin(Compiler.java:323)
>        at ij.plugin.PlugInExecuter.run(Compiler.java:312)
>        at java.lang.Thread.run(Thread.java:745)
>
> Fred

--
ImageJ mailing list: https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&amp;data=02%7C01%7C%7C3369ccd8158347ff128e08d64ea022aa%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636782847007557118&amp;sdata=8kjoK0mrZ6nHrsbWGfy1M9zbX5vUJKlf96DwYVUQj6U%3D&amp;reserved=0

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