[vtkusers] Bug in vtkTIFFReader reading multi-paged tiff file

David Gobbi david.gobbi at gmail.com
Fri Nov 8 17:25:46 EST 2013


On Fri, Nov 8, 2013 at 2:35 PM, Maarten Beek <beekmaarten at yahoo.com> wrote:
> Hi David,
>
> Using VTK 6.0.0, sorry ;-)

My tiff patch didn't make it into VTK 6.0, either.  Just master. (And
eventually, VTK 6.1 and maybe even VTK 5.10.2).

> Should I send you the tiff file so you can play with it?

Sure.  I always like having more images to play with.  Is it a true
TIFF, or is it converted from LSM (Zeiss)?

> Now I seem to have your attention:
>
> - How do I display a multi-page tif? I don't seem to see the different
> images using a vtkImageSlice.

Ideally, it should load as a 3D volume, just like any other 3D image
format, and the only special thing you have to do is set the
DataSpacing.

However, one of the other bugs I fixed at the same time as the
OutputExtent segfault was a frame indexing error, which caused some
frames to be missing when the file was loaded.  Also, even after the
patches that I made, the TIFF reader still didn't behave properly for
all images.  I can't remember exactly what the problems were, because
it was several months ago.

> - What would be good values for the window and level parameters? I am using
> window = range[1]-range[0] and level = 0.5*(range[0]+range[1]) which works
> ok for this multi-page tif, but gets me nowhere when I try to display a drr.

I wrote a class called vtkImageHistogramStatistics to help me out with
Window/Level.  It is included with VTK 5.10 and VTK 6.  It works like
this:

1) set the input of vtkImageHistogramStatistics to your image
2) call Update()
3) call GetAutoRange(range) to get a good window/level range

The AutoRange gives a range based on the threshold for the 99th
percentile of the image histogram, which gives much better results
than using the full range (i.e. the full range will often make the
image look way too dark, whereas the 99th percentile gives something
much more reasonable).

  David


> Thanks - Maarten
>
>
>
>
>
>
> On Friday, November 8, 2013 4:23:23 PM, David Gobbi <david.gobbi at gmail.com>
> wrote:
> Hi Maarten,
>
> Which version of VTK are you using?  I believe that this bug has been
> fixed in the master branch by a commits in the following topic merge:
> http://vtk.org/gitweb?p=VTK.git;a=commitdiff;h=7e3d5270
>
> It was not fixed in time for VTK 5.10, however.
>
>   David
>
>
> On Fri, Nov 8, 2013 at 2:12 PM, Maarten Beek <beekmaarten at yahoo.com> wrote:
>> Hi all,
>>
>> vtkTIFFReader crashed for me while loading a multi-paged tiff file.
>>
>> The crash occured in vtkTIFFReader::ReadGenericImage(), because
>> this->OutputExtent was not set (still NULL).
>> The scalar type for the image I was loading was unsigned short, so it
>> happened at line 1368.
>>
>> I changed void vtkTIFFReader::ReadVolume(void* buffer) into void
>> vtkTIFFReader::ReadVolume(void* buffer, int outExt[6]) and added the line
>> this->outputExtent = outExt.
>>
>> This solved my crash.
>> I am not sure I am on to something, but thought to let you know.
>>
>> Maarten
>
>


More information about the vtkusers mailing list