How to avoid updating the image

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to avoid updating the image

Avital Steinberg
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)

Thanks,
Avital

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

Re: How to avoid updating the image

Pariksheet Nanda
On Tue, Oct 14, 2014 at 8:30 AM, Avital Steinberg
<[hidden email]> wrote:
> How can I cancel the display of the moving ROI? (needless to
> say, it's slow)

Try using setBatchMode(true) so, for example, adding that makes a
script like this this execute much faster.

setBatchMode(true);
run("Blobs (25K)");
imWidth = getWidth();
imHeight = getWidth();
roiWidth = roiHeight = 25;
for (x = 0; x < imWidth - roiWidth; x++)
{
    for (y = 0; y < imHeight - roiHeight; y++)
    {
        makeOval(x, y, roiWidth, roiHeight);
        run("Measure");
    }
}


> Avital

Pariksheet

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

Re: How to avoid updating the image

Rasband, Wayne (NIH/NIMH) [E]
In reply to this post by Avital Steinberg
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
Reply | Threaded
Open this post in threaded view
|

Re: How to avoid updating the image

Avital Steinberg
In reply to this post by Pariksheet Nanda
Thank you for your answer - it worked well.

On Tue, Oct 14, 2014 at 5:07 PM, Pariksheet Nanda <
[hidden email]> wrote:

> On Tue, Oct 14, 2014 at 8:30 AM, Avital Steinberg
> <[hidden email]> wrote:
> > How can I cancel the display of the moving ROI? (needless to
> > say, it's slow)
>
> Try using setBatchMode(true) so, for example, adding that makes a
> script like this this execute much faster.
>
> setBatchMode(true);
> run("Blobs (25K)");
> imWidth = getWidth();
> imHeight = getWidth();
> roiWidth = roiHeight = 25;
> for (x = 0; x < imWidth - roiWidth; x++)
> {
>     for (y = 0; y < imHeight - roiHeight; y++)
>     {
>         makeOval(x, y, roiWidth, roiHeight);
>         run("Measure");
>     }
> }
>
>
> > Avital
>
> Pariksheet
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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

Re: How to avoid updating the image

Avital Steinberg
In reply to this post by Rasband, Wayne (NIH/NIMH) [E]
Thank you for your answer - I wrote 'true' instead of true. I didn't get a
syntax error but the command didn't do anything,

Avital

On Tue, Oct 14, 2014 at 9:34 PM, Rasband, Wayne (NIH/NIMH) [E] <
[hidden email]> wrote:

> 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
>

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