Login  Register

Re: Speeding up TIFF stack loading

Posted by Wayne Rasband on Jun 25, 2009; 8:27pm
URL: http://imagej.273.s1.nabble.com/Speeding-up-TIFF-stack-loading-tp3691996p3691997.html

On Jun 25, 2009, at 4:11 PM, aweitz wrote:

> Hi,
>
> I have a bunch of TIFF stacks that I want to open with ImageJ.  Each
> stack
> has 6000 slices.  When I try to open a TIFF stack, it takes about 40
> seconds
> for ImageJ to count how many slices are in the stack.
>
> I noticed that if I open a stack with ImageJ, save it, and re-open it,
> it
> immediately knows how many slices are in the stack and doesn't have to
> spend
> those 40 seconds trying to figure it out.  Looking in
> TiffDecoder.java, I
> see this is because it reads the number of images/slices from the TIFF
> description tag and then sets FileInfo nImages to 6000.
>
> I tried modifying the code to automatically set nImages to 6000.  When
> I do
> this, my TIFF stacks open without the 40-second delay.  However, the
> stacks
> don't open correctly.  Only the first slice appears OK, and the
> subsequent
> 5999 slices look bad.
>
> Does anyone know how I can modify the source to have ImageJ assume
> there are
> 6000 slices in every TIFF stack so that I don't have to waste 40
> seconds
> having ImageJ count the slices?

You could open the stacks using File>Import>Raw. To find the offset
(header size), enable debugging in Edit>Options>Misc and use File>Open
to open one of the stacks. The offset is the value of the StripOffsets
tag.

-wayne