Login  Register

Re: 8-bit vs 16-bit ip.set() and ip.get() speed

Posted by Michael Doube on Dec 03, 2009; 3:06pm
URL: http://imagej.273.s1.nabble.com/8-bit-vs-16-bit-ip-set-and-ip-get-speed-tp3690234p3690236.html

Albert,

Thanks for the excellent suggestion.  By caching as you suggest, 8-bit
processing is now much faster...

ImageProcessor[] sliceProcessors = new ImageProcessor[d + 1];
for (int z = 1; z <= d; z++) {
        sliceProcessors[z] = sourceStack.getProcessor(z);
}

then in the inner loop...

targetIP.set(x, y, sliceProcessors[zA].get(xA, yA));

Michael

Albert Cardona wrote:

> Michael,
>
> This chunk:
>
> sourceStack.getProcessor(zA)
>
>
> ... will result in the creation of a new processor for every call.
> It's a very expensive method. See:
>
> http://repo.or.cz/w/imageja.git/blob/d8c301fa7f114b5566c212a8211cbbfcdf4a6083:/ij/ImageStack.java#l232
>
>
> You could go around by caching the processor in a variable for every zA.
>
> Albert