Login  Register

Re: How to avoid updating the image

Posted by Rasband, Wayne (NIH/NIMH) [E] on Oct 14, 2014; 7:34pm
URL: http://imagej.273.s1.nabble.com/How-to-avoid-updating-the-image-tp5010025p5010038.html

On Oct 14, 2014, at 4:30 AM, Avital Steinberg wrote:

> Hi,
> I have loops that move an ROI around my image and uses getStatistics to
> measure some parameters.
>
> My problem is that my image is updated thousands of times - each time the
> ROI is moved. How can I cancel the display of the moving ROI? (needless to
> say, it's slow)

Try running the macro in batch mode. The following test macro, which creates and measures one million ROIs, runs in 10 seconds in batch mode and in 16 seconds when not in batch mode.

-wayne

 setBatchMode(true);
 run("Clear Results");
 run("AuPbSn 40 (56K)");
 t0 = getTime;
 n = 1000000;
 size=25;
 for (i=0; i<n; i++) {
     showProgress(i, n);
     x = round(random()*(getWidth-size));
     y = round(random()*(getHeight-size));
     makeRectangle(x, y, size, size);
     getStatistics(area, mean);
     setResult("X", i, x);
     setResult("Y", i, y);
     setResult("Mean", i, mean);
 }
 updateResults;
 print((getTime-t0)/1000+" seconds");
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html