[Insight-users] Memory-related Question
Miller, James V (Research)
millerjv at crd.ge.com
Wed Jul 7 09:33:32 EDT 2004
Zein,
Most ITK filters will create a new image to use for the output image.
The input image will remain intact. The exception are filters that
are subclasses of InPlaceFilter. These filters can be told to overwrite
their input storage to produce an output image.
If you have a long pipeline (several filters tied together), then your
application can end up with a very large memory footprint (original input
image plus output images for every filter). To reduce the memory footprint
of your application, you can call filter->ReleaseDataFlagOn() before any
calls to Update(). Setting the release data flag informs the pipeline
that the filter can delete it "input" once it has generated its "output".
So while a filter executes, you have two "copies" of the data (one
input and one output) but once the filter completes, the input bulk data
is released. This has a big benefit when you have several filters
tied together. For an N filter pipeline, you end up a maximum footprint
of 2 copies of the data instead of N+1 copies.
Some of the ITK filters support streaming. If you place a
StreamingImageFilter at the end of the pipeline, the intermediate filters
will process the image a piece at a time. Streaming support is pretty much
limited to a subset of the image processing filters.
To see if you have too many copies of the data floating around, check your
process size (ps on unix or use the task manager on Windows) and compare
that size to your image size. If your data is 16 bits, then one copy of a
512x512x150 image will require 75MB.
Jim
-----Original Message-----
From: salah [mailto:salah at gris.uni-tuebingen.de]
Sent: Wednesday, July 07, 2004 6:44 AM
To: ITK Users (E-Mail)
Subject: [Insight-users] Memory-related Question
> Hello all,
>
> I have a question related to memory allocation in itk filters.
>
> when I have an itk image in some program, defined in terms of a
smartpointer. For example:
>
> ImageType::Pointer exampleImage = ImageType::New();
> exampleImage->SetRegions( region);
> exampleImage->Allocate();
>
> Now if I feed this image as input to some itk filter that inherits
> from ItkImageToImageFilter (by filter->SetInput(exampleImage); ),
> would this filter create/allocate a copy of the exampleImage? Or it
> just uses the one allocated by/in the calling module?
>
> My question is due to the fact that an itk program of me hangs (sometimes
> terminates abnormally, reporting an error with the graphic card) with
> big images (512x512x150) but behaves well with smaller ones.
>
> Many thanks,
>
> Zein
_______________________________________________
Insight-users mailing list
Insight-users at itk.org
http://www.itk.org/mailman/listinfo/insight-users
More information about the Insight-users
mailing list