[Insight-users] Reading portion of the image without loading the whole image into the memory

Matt McCormick matt.mccormick at kitware.com
Tue Aug 14 18:26:28 EDT 2012


On Tue, Aug 14, 2012 at 10:14 PM, yan xu <xy198908 at gmail.com> wrote:
>   Hi, Matt,
>        According to CanStreamRead, right now only MetaImageIO and VTKImageIO
> are streamable right?

Yes, and all the formats that inherit from StreamingImageIOBase

  http://www.itk.org/Doxygen/html/classitk_1_1StreamingImageIOBase.html

> What does it need to be a streaming reader?

First, the underlying library that does the reading need to be able to
stream.  Then, the ITK wrapper of the library needs be implemented as
a streamed operation.

Thanks,
Matt

>   Yan
>
> On Tue, Aug 14, 2012 at 5:03 PM, Matt McCormick <matt.mccormick at kitware.com>
> wrote:
>>
>> Hi Yan,
>>
>> Streaming will only occur if the filter is streamable and it has been
>> implemented as a streamable filter.  Unfortunately the NrrdImageIO is
>> not implemented as a streaming reader at this time, so it will always
>> load the entire image to memory.  For more information, see the
>> CanStreamRead method on itk::ImageIOBase.
>>
>> HTH,
>> Matt
>>
>> On Tue, Aug 14, 2012 at 9:22 PM, yan xu <xy198908 at gmail.com> wrote:
>> >  Hi, David,
>> >         I'm afraid it doesn't work, the codes are following for 16bit
>> > nrrd.
>> > The memory still increases up to the size of the image not the region of
>> > image I defined. Is it due to the image type or something? The codes are
>> > following:
>> >
>> > UShortImageType::IndexType index;
>> > index[0] = startX;
>> > index[1] = startY;
>> > index[2] = startZ;
>> >
>> > UShortImageType::SizeType size;
>> > size[0] = sizeX;
>> > size[1] = sizeY;
>> > size[2] = sizeZ;
>> >
>> > UShortImageType::RegionType region;
>> > region.SetIndex( index);
>> > region.SetSize( size);
>> >
>> > ushortImageReader::Pointer reader = ushortImageReader::New();
>> > reader->SetFileName(fileName);
>> > reader->GetOutput()->SetRequestedRegion(region);
>> >
>> > try
>> > {
>> > reader->Update();
>> > }
>> > catch ( itk::ExceptionObject &err)
>> > {
>> > std::cout << "Error in bin_image_writer: " << err << std::endl;
>> > }
>> >
>> >
>> > Yan
>> >
>> >
>> > On Tue, Aug 14, 2012 at 4:08 PM, David Doria <daviddoria at gmail.com>
>> > wrote:
>> >>
>> >> On Tue, Aug 14, 2012 at 4:59 PM, yan xu <xy198908 at gmail.com> wrote:
>> >>>
>> >>> Hi, all
>> >>>       I'm facing a problem to read only portion of the image to test
>> >>> the
>> >>> algorithm since the whole image is too big for the memory. I have
>> >>> tried
>> >>> using the itk pipeline through extractimage filter, but I don't think
>> >>> it
>> >>> works. The memory still goes larger and larger. My image type is 16bit
>> >>> nrrd.
>> >>> What I hope is that the only the desired region of the image is loaded
>> >>> into
>> >>> the memory. Is there a solution for that? Thank you!
>> >>
>> >>
>> >> I've never done it, but you could try this:
>> >>
>> >> http://www.itk.org/Wiki/ITK/Examples/SimpleOperations/RequestedRegion
>> >>
>> >> on your ImageReader.
>> >>
>> >> David
>> >
>> >
>> >
>> >
>> > --
>> > Yan Xu
>> > Research Assistant
>> > Bio-Image Analytics Laboratory
>> > Department of Electrical and Computer Engineering
>> > University of Houston
>> >
>> >
>> >
>> > _____________________________________
>> > Powered by www.kitware.com
>> >
>> > Visit other Kitware open-source projects at
>> > http://www.kitware.com/opensource/opensource.html
>> >
>> > Kitware offers ITK Training Courses, for more information visit:
>> > http://www.kitware.com/products/protraining.php
>> >
>> > Please keep messages on-topic and check the ITK FAQ at:
>> > http://www.itk.org/Wiki/ITK_FAQ
>> >
>> > Follow this link to subscribe/unsubscribe:
>> > http://www.itk.org/mailman/listinfo/insight-users
>> >
>
>
>
>
> --
> Yan Xu
> Research Assistant
> Bio-Image Analytics Laboratory
> Department of Electrical and Computer Engineering
> University of Houston
>
>


More information about the Insight-users mailing list