[Insight-users] 16-bit TIFF reading

Luis Ibanez luis.ibanez@kitware.com
Tue May 18 16:10:37 EDT 2004


Hi Nick,

Thanks for your detailed report.

Your code looks fine.

The TIFF reader in ITK is based on the libtiff
that is distributed in: Insight/Utilities/tiff.

Both 8 bits/pixel and 16 bits/pixel are supported.

What you describe sounds like a bug in the pixel
conversion... Could you please send us one of the
TIFF image that is producing this effect for you ?


That will help us to figure out if this is a real
bug and eventually how to fix it.


Thanks


     Luis


PS
If possible, please send a small image   :-)


-----------------
Nick Arini wrote:

> 
> Dear ITK users,
> 
> I am having trouble trying to read single channel grayscale 16-bit TIFF 
> images using the itk::ImageFileReader.
> 
> The tiffinfo output for my test image looks like this:
> 
> <begin tifinfo>
> 
> TIFF Directory at offset 0x8
>  Subfile Type: (0 = 0x0)
>  Image Width: 1392 Image Length: 1040
>  Resolution: 61728, 61728 pixels/cm
>  Bits/Sample: 16
>  Compression Scheme: None
>  Photometric Interpretation: min-is-black
>  Samples/Pixel: 1
>  Max Sample Value: 4095
>  Planar Configuration: single image plane
> 
> <end tiffinfo>
> 
> I am using ITK in a manner similar to the following code fragment:
> 
> <begin code>
> 
> #include "itkImage.h"
> #include "itkImageFileReader.h"
> 
> int main( int argc, char * argv[] )
> {
> 
>  if( argc < 3 )
>    {
>    std::cerr << "Usage: " << argv[0] << " inputImageFile ";
>    std::cerr << " outputImageFile" << std::endl;  
>    return 1;
>    }
>  
>  typedef  unsigned short PixelType;
> 
>  typedef itk::Image< PixelType,  2 >   ImageType;
> 
>  typedef itk::ImageFileReader< ImageType >  ReaderType;
> 
>  ReaderType::Pointer reader = ReaderType::New();
> 
>  reader->SetFileName( argv[1] );
> 
>  ImageType::Pointer image = reader->GetOutput();
> 
>  reader->Update();
> 
>  return 0;
> }
> 
> <end code>
> 
> The problem that I seem to have is that although I can read the file 
> with the correct dimensions the actual pixel values are not the ones I 
> am expecting.
> 
> I have successfully read this image into other packages, including 
> Matlab and know what I should be getting. The effect I am seeing is 
> similar to binning although the new (wrong?) values after reading are 
> not restricted to the 8-bit range(0-255).
> 
> Has anyone else had problems with reading 16-bit TIFF images? Is the ITK 
> IO TIFF machinery based on libtiff and does this support 16-bit TIFFs.
> 
> I am using ITK version 1.6.0 and observe exactly the same effect on 
> Linux (GCC) and WinXP(MSVC++7.1).
>  
> Thanks in advance for any help or advice.
> 
> Best regards,
> 
> Nick Arini






More information about the Insight-users mailing list