Login  Register

speed and ROIs

Posted by Jeremy Adler-2 on Jul 07, 2017; 8:05am
URL: http://imagej.273.s1.nabble.com/speed-and-ROIs-tp5019036.html


I am trying to speed up a macro that includes working repeatedly with a large stack.
I assumed that if I operated on a selection and ran a filter, that the filter would only operate on the selection and would
therefore be faster than using the whole stack.
However when I checked the timings using they were almost identical.

While it is reasonable that a selection only limits the volume operate on, it would be helpful if this translated into an increase in  the speed

newImage("play", "8-bit random", 256, 256, 64);
makeRectangle(103, 77, 31, 31);
t0=getTime();
run("Gaussian Blur...", "sigma=2 stack");
t1=getTime();
print('time with selection',t1-t0,' msecs');
run("Select None");
t2=getTime();
run("Gaussian Blur...", "sigma=2 stack");
t3=getTime();
print('time without selection',t3-t2,' msecs');

It occurred to me that Duplicating the volume of the selection and then filtering that would be faster, since Duplicate is fast

newImage("play", "8-bit random", 256, 256, 64);
t0=getTime();
run("Gaussian Blur...", "sigma=2 stack");
t1=getTime();
print('Gau whole stack ',t1-t0,' msecs');

newImage("play2", "8-bit random", 256, 256, 64);
t2=getTime();
makeRectangle(103, 77, 11, 11);
run("Duplicate...", "duplicate");
t3=getTime();
run("Gaussian Blur...", "sigma=2 stack");
t4=getTime();
print('Duplicate ',t3-t2,' msecs');
print('Gau with duplicated selection ',t4-t3,' msecs');

but while duplicate is fast, the time taken for the Gaussian was only marginally reduced.
Which seems strange given that the size of the duplicated image is tiny compared to the original.
What am I missing ?





Jeremy Adler

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