Login  Register

Hide ROI Manager Window

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Hide ROI Manager Window

Rafael Ballester
8 posts
Hi everybody,

I have generated a binary image consisting of segmented particles. With ImageJ's API, I would like to obtain its particles as ROIs, so as to analyze them later. What is the easiest way to obtain those ROIs?

The following way works using the ParticleAnalyzer class to store the detected ROIs into the RoiManager, so that I can retrieve them later. But I can't prevent this approach from opening the ROI Manager Window, which is annoying in an automatised context.

int options = ParticleAnalyzer.ADD_TO_MANAGER;
ParticleAnalyzer pa = new ParticleAnalyzer(options, 0, new ResultsTable(), 0, Double.MAX_VALUE, 0, 1);
pa.analyze(imSegmented); // imSegmented is my binary image
RoiManager manager = RoiManager.getInstance();
Roi[] rois = manager.getRoisAsArray();

Do you know how to prevent that window from appearing? Or any different way to obtain the ROIs?

Thanks in advance!
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Hide ROI Manager Window

Rasband, Wayne (NIH/NIMH) [E]
1064 posts
On Nov 24, 2011, at 12:54 PM, Rafael Ballester wrote:

> Hi everybody,
>
> I have generated a binary image consisting of segmented particles. With
> ImageJ's API, I would like to obtain its particles as ROIs, so as to analyze
> them later. What is the easiest way to obtain those ROIs?
>
> The following way works using the ParticleAnalyzer class to store the
> detected ROIs into the RoiManager, so that I can retrieve them later. But I
> can't prevent this approach from opening the ROI Manager Window, which is
> annoying in an automatised context.
>
> int options = ParticleAnalyzer.ADD_TO_MANAGER;
> ParticleAnalyzer pa = new ParticleAnalyzer(options, 0, new ResultsTable(),
> 0, Double.MAX_VALUE, 0, 1);
> pa.analyze(imSegmented); // imSegmented is my binary image
> RoiManager manager = RoiManager.getInstance();
> Roi[] rois = manager.getRoisAsArray();
>
> Do you know how to prevent that window from appearing? Or any different way
> to obtain the ROIs?

The ImageJ 1.46b daily build adds a ParticleAnalyzer.setRoiManager() method that can be used to prevent the ROI Manager window from appearing. Here is a JavaScript example:

  imp = IJ.openImage("http://imagej.nih.gov/ij/images/blobs.gif");
  IJ.setAutoThreshold(imp, "Default");
  manager = new RoiManager(true);
  ParticleAnalyzer.setRoiManager(manager);
  IJ.run(imp, "Analyze Particles...", "size=600 exclude add");
  rois = manager.getRoisAsArray();
  for (i=0; i<rois.length; i++) {
          imp.setRoi(rois[i]);
       print(i+" "+imp.getStatistics());
  }

And here is a lower level example:

  imp = IJ.openImage("http://imagej.nih.gov/ij/images/blobs.gif");
  IJ.setAutoThreshold(imp, "Default");
  manager = new RoiManager(true);
  ParticleAnalyzer.setRoiManager(manager);
  pa = new ParticleAnalyzer(0, 0, new ResultsTable(), 600, Double.MAX_VALUE, 0, 1);
  pa.analyze(imp);
  rois = manager.getRoisAsArray();

-wayne
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Hide ROI Manager Window

Rafael Ballester
8 posts
Thank you for this new feature!

2011/11/25 Rasband, Wayne (NIH/NIMH) [E] <[hidden email]>

> On Nov 24, 2011, at 12:54 PM, Rafael Ballester wrote:
>
> > Hi everybody,
> >
> > I have generated a binary image consisting of segmented particles. With
> > ImageJ's API, I would like to obtain its particles as ROIs, so as to
> analyze
> > them later. What is the easiest way to obtain those ROIs?
> >
> > The following way works using the ParticleAnalyzer class to store the
> > detected ROIs into the RoiManager, so that I can retrieve them later.
> But I
> > can't prevent this approach from opening the ROI Manager Window, which is
> > annoying in an automatised context.
> >
> > int options = ParticleAnalyzer.ADD_TO_MANAGER;
> > ParticleAnalyzer pa = new ParticleAnalyzer(options, 0, new
> ResultsTable(),
> > 0, Double.MAX_VALUE, 0, 1);
> > pa.analyze(imSegmented); // imSegmented is my binary image
> > RoiManager manager = RoiManager.getInstance();
> > Roi[] rois = manager.getRoisAsArray();
> >
> > Do you know how to prevent that window from appearing? Or any different
> way
> > to obtain the ROIs?
>
> The ImageJ 1.46b daily build adds a ParticleAnalyzer.setRoiManager()
> method that can be used to prevent the ROI Manager window from appearing.
> Here is a JavaScript example:
>
>  imp = IJ.openImage("http://imagej.nih.gov/ij/images/blobs.gif");
>  IJ.setAutoThreshold(imp, "Default");
>  manager = new RoiManager(true);
>  ParticleAnalyzer.setRoiManager(manager);
>  IJ.run(imp, "Analyze Particles...", "size=600 exclude add");
>  rois = manager.getRoisAsArray();
>  for (i=0; i<rois.length; i++) {
>          imp.setRoi(rois[i]);
>       print(i+" "+imp.getStatistics());
>  }
>
> And here is a lower level example:
>
>  imp = IJ.openImage("http://imagej.nih.gov/ij/images/blobs.gif");
>  IJ.setAutoThreshold(imp, "Default");
>  manager = new RoiManager(true);
>  ParticleAnalyzer.setRoiManager(manager);
>  pa = new ParticleAnalyzer(0, 0, new ResultsTable(), 600,
> Double.MAX_VALUE, 0, 1);
>  pa.analyze(imp);
>  rois = manager.getRoisAsArray();
>
> -wayne
>