[ITK] Reading multi-paged TIFF Image

Imre Goretzki goretzki.imre at gmail.com
Fri Nov 20 10:24:22 EST 2015


Hey guys,

i was wondering if you could help me getting all pages from a 
multi-paged TIFF image.

There are plenty of examples on how to read tiff images, e.g.

|typedefitk::RGBAPixel<unsigned char> PixelType;// Pixel 
typeconstunsignedintDimension=3;typedefitk::Image<PixelType,Dimension>ImageType;ImageType::Pointerimage; 
||typedefitk::ImageFileReader<ImageType>ReaderType;|
|||itk::TIFFImageIO::Pointer io = itk::TIFFImageIO::New()|| 
ReaderType::Pointerreader=ReaderType::New();constchar*filename 
="path/to/file.tif";|||| reader->SetImageIO(io);reader->SetFileName(filename); ||ImageType::IndexTypepixelIndex;pixelIndex[0]=103; //xpixelIndex[1]=178; //y|||pixelIndex[2]=0;| ImageType::PixelTypepixelValue 
=image->GetPixel(pixelIndex);std::cout <<"pixel : "<<pixelValue 
<<std::endl;|

in this example, if i'm not mistaking, the third pixelIndex corresponds 
to the pages of a stacked tiff image.

Is this the right way to get access to single pages? And how do I get 
the RGB values?

My TIFF file is structured as follows:

It has at least 47 Images stored, each of those has the following dimensions
520x520x3 (WxHxRGB)

I checked these informations via SCIFIOImageIO::ReadImageInformation, 
like this:

std::cout << "Pixel Type is " << 
imageIO->GetComponentTypeAsString(pixelType) << std::endl; const size_t 
numDimensions = imageIO->GetNumberOfDimensions(); std::cout << 
"numDimensions: " << numDimensions << std::endl; // '5' std::cout << 
"component size: " << imageIO->GetComponentSize() << std::endl; // '8' 
std::cout << "pixel type (string): " << 
imageIO->GetPixelTypeAsString(imageIO->GetPixelType()) << std::endl; // 
'vector' std::cout << "pixel type: " << imageIO->GetPixelType() << 
std::endl; // '5'


or this:

ImageType::Pointer img = reader->GetOutput(); ImageType::RegionType = 
img->GetLargestPossibleRegion(); std::cout << "Region: " << region << 
std::endl; // '5' OUTPUT:
Dimension: 5 Index: [0,0,0,0,0] Size: [520, 520, 47, 1, 3]



If I print the pixels, I will get the same output for each channel 
(which I guess is RGB).

If I change the input dimension to 5, the index has to be changed:

|ImageType::IndexTypepixelIndex;pixelIndex[0]=240; //xpixelIndex[1]=430; //y|||pixelIndex[2]=0;| //z |||pixelIndex[3]=0;| //timestamp i guess? Dimension of this is always 1 
for my data |||pixelIndex[4]=0;| //R-Channel|
||pixelIndex[4]=1;| //G-Channel|
||pixelIndex[4]=2;| //B-Channel|

Is this correct?

OUTPUT for pixels via img->GetPixel(pixelIndex) is
[930, 930, 930]

for idx = [ {{240, 430, 0, 0, 0}}, {{240, 430, 0, 0, 1}}  ,{{240, 430, 0, 0, 2}}  ]



I could think of using an ImageIterator, but I don't know how to use 
them in a multi-paged image.

The last thing I would like to ask you is, if you could help me on how 
to use the TIFFImageIO::ReadVolume.
It says that you could read 3D images, but there are neither examples 
nor tips.

To sum things up, i would like to know if there is a good way to access 
each image in such a multi-paged TIFF file.

I really hope, you guys can help me.

Thanks
Imre
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20151120/d691acdc/attachment-0001.html>


More information about the Community mailing list