[ITK-users] Reading a very large image

Vikram Venkatraghavan 88.vikram at gmail.com
Tue Mar 3 02:19:40 EST 2015


Hello,

I am relatively new to ITK. I am trying to read a very large TIFF image
using the IO streaming functionality in ITK. I am reading a very small
portion of the image and I still end up getting memory allocation error. I
get the feeling, the code is trying to read the entire image at once, even
after specifying the region to read. Can someone please tell what is wrong
the following code snippet ?

typedef itk::RGBPixel< unsigned char >  RGBPixelType;
typedef itk::Image< RGBPixelType, 2 >   RGB2DImageType;
typedef itk::ImageFileReader<RGB2DImageType> RGBReaderType;

itk::TIFFImageIO::Pointer tiffIO = itk::TIFFImageIO::New();
tiffIO->SetPixelType(itk::ImageIOBase::RGBA);

RGB2DImageType::SizeType sz;
RGB2DImageType::IndexType idx;
sz[0]=128; sz[1]=128;
idx[0]=0; idx[1]=0;

itk::ImageIORegion region(2);
region.SetSize(0,sz[0]);
region.SetSize(1,sz[1]);
region.SetIndex(0,idx[0]);
region.SetIndex(1,idx[1]);
tiffIO->SetIORegion(region);

RGBReaderType::Pointer reader = RGBReaderType::New();
reader->SetFileName("V:\\TiFF_Image.tiff");
reader->SetImageIO(tiffIO);
reader->SetUseStreaming(1);
reader->Update();

Thanks in advance.

Regards,
Vikram
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20150303/cb71d7c9/attachment.html>


More information about the Insight-users mailing list