[Insight-users] Exporting image data

Reinhard Hameeteman reinhard.afstuderen at gmail.com
Thu Jun 29 05:48:25 EDT 2006


Hi all,

Within a program that uses ITK classes to process image data, I want
to do some processing using other routines (from netlib/FishPack). So
my pipeline is like:
ITK processing -> FishPack processing -> ITK processing
Now I try to avoid unnecessary copying of data from an ITK image to a
C array and back. I know there is a class called ImportImageFilter to
import a chunk of memory into an ITK image, which I can use to get my
image back into an ITK pipeline. But in my case I also need some way
to get the ITK image to the FishPack routines. This routines simply
needs a pixeltype pointer to a contiguous piece of memory, in which
the image is ordered in the same way an ITK iterator traverses through
the image. In the itkFFTWRealToComplexConjugateImageFilter filter I
saw the following way to access the image data:
float *in =
      const_cast<float *>(reinterpret_cast<const float
*>(inputPtr->GetBufferPointer()));

Is it a good thing to omit the const_cast and use this method to pass
an image data pointer to a routine that changes the data and is it
guaranteed that an ITK image is in a contiguous piece of memory?

An other method I saw in the mailing lists is:
PixelType * CArray = image->GetPixelContainer()->GetImportPointer();

Is there a difference between  GetBufferPointer() and
GetPixelContainer()->GetImportPointer() or do they both return a
pixeltype pointer to the image data?

Thanks in advance,
Reinhard


More information about the Insight-users mailing list