[Insight-users] 16-bit TIFF reading
Nick Arini
nick.arini@amersham.com
Tue May 18 14:35:52 EDT 2004
This is a multipart message in MIME format.
--=_alternative 004AB1DD80256E98_=
Content-Type: text/plain; charset="us-ascii"
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
--=_alternative 004AB1DD80256E98_=
Content-Type: text/html; charset="us-ascii"
<br><font size=2 face="sans-serif">Dear ITK users,</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
I am having trouble trying to read single channel grayscale 16-bit TIFF images using the itk::ImageFileReader.</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
The tiffinfo output for my test image looks like this:</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
<begin tifinfo></font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
TIFF Directory at offset 0x8</font><font size=3 face="Times New Roman"> </font><font size=2 face="sans-serif"><br>
Subfile Type: (0 = 0x0)</font><font size=3 face="Times New Roman"> </font><font size=2 face="sans-serif"><br>
Image Width: 1392 Image Length: 1040</font><font size=3 face="Times New Roman"> </font><font size=2 face="sans-serif"><br>
Resolution: 61728, 61728 pixels/cm</font><font size=3 face="Times New Roman"> </font><font size=2 face="sans-serif"><br>
Bits/Sample: 16</font><font size=3 face="Times New Roman"> </font><font size=2 face="sans-serif"><br>
Compression Scheme: None</font><font size=3 face="Times New Roman"> </font><font size=2 face="sans-serif"><br>
Photometric Interpretation: min-is-black</font><font size=3 face="Times New Roman"> </font><font size=2 face="sans-serif"><br>
Samples/Pixel: 1</font><font size=3 face="Times New Roman"> </font><font size=2 face="sans-serif"><br>
Max Sample Value: 4095</font><font size=3 face="Times New Roman"> </font><font size=2 face="sans-serif"><br>
Planar Configuration: single image plane</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
<end tiffinfo></font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
I am using ITK in a manner similar to the following code fragment:</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
<begin code></font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
#include "itkImage.h"</font><font size=3 face="Times New Roman"> </font><font size=2 face="sans-serif"><br>
#include "itkImageFileReader.h"</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
int main( int argc, char * argv[] )</font><font size=3 face="Times New Roman"> </font><font size=2 face="sans-serif"><br>
{</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
if( argc < 3 )</font><font size=3 face="Times New Roman"> </font><font size=2 face="sans-serif"><br>
{</font><font size=3 face="Times New Roman"> </font><font size=2 face="sans-serif"><br>
std::cerr << "Usage: " << argv[0] << " inputImageFile ";</font><font size=3 face="Times New Roman"> </font><font size=2 face="sans-serif"><br>
std::cerr << " outputImageFile" << std::endl; </font><font size=3 face="Times New Roman"> </font><font size=2 face="sans-serif"><br>
return 1;</font><font size=3 face="Times New Roman"> </font><font size=2 face="sans-serif"><br>
}</font><font size=3 face="Times New Roman"> </font><font size=2 face="sans-serif"><br>
<br>
typedef unsigned short PixelType;</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
typedef itk::Image< PixelType, 2 > ImageType;</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
typedef itk::ImageFileReader< ImageType > ReaderType;</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
ReaderType::Pointer reader = ReaderType::New();</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
reader->SetFileName( argv[1] );</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
ImageType::Pointer image = reader->GetOutput();</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
reader->Update();</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
return 0;</font><font size=3 face="Times New Roman"> </font><font size=2 face="sans-serif"><br>
}</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
<end code></font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
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. </font><font size=3 face="Times New Roman"><br>
</font><font size=2 face="sans-serif"><br>
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). </font><font size=3 face="Times New Roman"><br>
</font><font size=2 face="sans-serif"><br>
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.</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
I am using ITK version 1.6.0 and observe exactly the same effect on Linux (GCC) and WinXP(MSVC++7.1).</font><font size=3 face="Times New Roman"> </font><font size=2 face="sans-serif"><br>
</font><font size=3 face="Times New Roman"> </font><font size=2 face="sans-serif"><br>
Thanks in advance for any help or advice.</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
Best regards,</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="sans-serif"><br>
Nick Arini</font>
<br>
--=_alternative 004AB1DD80256E98_=--
More information about the Insight-users
mailing list