[Insight-users] 3D Rigid Registration - "Unable to allocate / Failed to allocate memory for image" problem
Luis Ibanez
luis.ibanez at kitware.com
Tue May 19 20:55:10 EDT 2009
Hi Vural,
The size of your input image is:
509 x 512 x 512 pixels = 133 x 10^6 pixels
with 2 bytes per pixel.
This is 254 Mb.
If you load two of them you have
509 Mb
then the Metric computes derivatives of the moving image,
using 3 floats per pixel = 12 bytes per pixel, for an image of
133 x 10^6 * 12 = 1.6 Gigabytes
plust the 509 Mb of the fixed and moving image you have
2.1 Gigabytes
this is only in data. without counting your program and
other proceses in memory.
It is quite easy to hit the 3.2 GB top of your RAM.
An easy option is to replace the optimizer with one that
doesn't rely on the gradients of the metric.
For example, you can consider the use of the
* Amoeba optimizer
* OnePlusOneEvolutionary optimizer
You can also focus on a smaller region of interest,...
although you already explored that path.
BTW: for debugging this, you will find useful the
classes:
itkMemoryProbe.cxx
itkMemoryProbe.h
itkMemoryProbesCollectorBase.h
They show you how memory is allocated as the process
of registration takes place.
Regards,
Luis
---------------------
Vural Özbudak wrote:
> Hi everyone,
>
> I want to implement 3D rigid registration on 2 sets of 509 slices 512 x
> 512 CT dicom data. I'm basically using
> Insight/Examples/Registration/ImageRegistration8.cxx code with some
> altering in data loading part, load it slice by slice having a vtkImage
> at hand, convert it to itkImage, apply the registration, back convert to
> a vtkImage and then give it to a renderer (just for visualization of one
> slice).
>
> One set of dicom data I have is about 100 Mb, (two sets 200 Mb), and I'm
> working on a quad-core 2.66 GHz computer which has 3.2 GB of RAM. Before
> the time of execution, RAM usage was about 0.5 GB as I follow from the
> system monitor of Fedora Core 8.
>
> 1) I tried to load all the 509 slices of the two sets, when RAM usage
> increases to 2.0 GB, code stops running, RAM usage goes back to 0.5 GB
> and this problem occurs:
>
> vtkDoubleArray (0xa8a1a10): Unable to allocate 133431296 elements of
> size 8 bytes. (I guess this makes roughly 1GB for 509 x 2 slices)
>
> 2) So I diminished the number of slices I load (I know it's useless for
> registration purpose but), and I gave 200 slices per data set. RAM usage
> increases to 2.2 GB, code stops and RAM goes back to 0.5 GB again. The
> output was the lots of repeated prints of this error:
> ......
> Unable to allocate 67766783 elements of size 8 bytes (About 0.5 GB for
> 200 x 2 slices)
> .......
> Segmentation Fault
>
> 3) I decreased the slices to 130 slices. During execution, RAM usage
> increased to 2.3 GB, code stopped and RAM went back to 0.5 GB. The error
> turned out to be the following:
>
> terminate called after throwing an instance of 'itk::ExceptionObject'
> what(): /usr/local/ITK/ITK/Code/Common/itkImportImageContainer.txx:188:
> Failed to allocate memory for image.
> Aborted
>
> 4) I decreased slice number to be loaded to 120 slices per both data
> sets and the code worked properly, found the registration parameters and
> showed one slice in the renderer just like as I wanted to. (RAM usage
> was 2.5 GB while code was running)
>
> So I couldn't load more than 120 slices of my data. I tried to subsample
> it (say by 4) and free the memory used by original data and calculate
> registration parameters with the subsampled version of the data. It made
> no difference on the memory usage whether I used the original data or
> subsampled versions of it. So it didn't work either.
>
> By the way Insight/Examples/Registration/ImageRegistration8.cxx uses:
> #include "itkVersorRigid3DTransform.h"
> #include "itkVersorRigid3DTransformOptimizer.h"
>
> My question is, what does exploit and blow up the memory in this
> process? How can I get over these problems? In similar problems which
> ITK fellows encountered before, the main problem was about the gradient
> calculation as far as I've read from the mail list. I don't know what
> VersorRigid3DTransform does inside, but does this memory problem have
> anything to do with it?
>
> Any kind of solution/suggestion will be appreciated. Thanks in advance.
>
>
> --
> Vural Ozbudak
>
>
> ------------------------------------------------------------------------
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> 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
More information about the Insight-users
mailing list