Re: Using Enlarge function with very large ROI sets

Posted by Rasband, Wayne (NIH/NIMH) [E] on
URL: http://imagej.273.s1.nabble.com/Using-Enlarge-function-with-very-large-ROI-sets-tp5009786p5009789.html

On Sep 26, 2014, at 1:39 PM, Jia-Ren_Lin wrote:

> Dear experts,
>
> I'm trying to quantify timelapse images with nuclear fluorescent marker for
> segmentation and also take cytoplasmic measurements by enlarging ROIs.
> However, because of* very large ROI sets (>50,000)*, my macro ran very slow.
>
> /*counts=roiManager("count");
> for(i=0; i<counts; i++) {
>    roiManager(&amp;quot;Select&amp;quot;, i);
>    run(&amp;quot;Measure&amp;quot;);
>    run(&amp;quot;Enlarge...&amp;quot;, &amp;quot;enlarge=4&amp;quot;);
>    run(&amp;quot;Measure&amp;quot;);
> }&lt;/b>/
>
> I've already setBatchMode("true").  It helps a little (save about half
> time),  but I was wondering if there is a way to speed up my macro.

I get 280ms/ROI when I run your macro on the blobs sample image. If the macro switches to batch mode after running the particle analyzer (the image and ROI Manager are displayed), it takes 22ms/ROI, 13 times faster. If the macro switches to batch mode before running the particle analyzer (the image and ROI Manager are not displayed), the macro takes 5ms/ROI, 46 times faster. At 5ms/ROI, the macro would take  about 4 minutes to process 50,000 ROIs. The following is what the fastest version of the test macro I used looks like.

-wayne

  setBatchMode(true);
  run("Blobs (25K)");
  setAutoThreshold("Default");
  run("Analyze Particles...", "display exclude add");
  t0 = getTime;
  counts=roiManager("count");
  for(i=0; i<counts; i++) {
     roiManager("Select", i);
     run("Measure");
     run("Enlarge...", "enlarge=4");
     run("Measure");
  }
  print((getTime-t0)/counts);


> --
> View this message in context: http://imagej.1557.x6.nabble.com/Using-Enlarge-function-with-very-large-ROI-sets-tp5009786.html
> Sent from the ImageJ mailing list archive at Nabble.com.

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