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

yan xu xy198908 at gmail.com
Tue Aug 14 17:22:10 EDT 2012


 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120814/5f03e5b2/attachment.htm>


More information about the Insight-users mailing list