[Insight-users] pointer to image data

barbababa tonimuusimaki at gmail.com
Tue Jul 19 04:41:23 EDT 2011


HI!

Just to make it clear here. So with using float *img_data as an input to
importimagefilter
does not allocate new memory? Currently i am using this:

typedef itk::Image< float, 3 > ItkImagereal3;
typedef float PixelTypereal3;

Image itktoimagereal3( const ItkImagereal3 * input)
{
  Image Output;
  ItkImagereal3::RegionType region1 = input->GetBufferedRegion();

  ItkImagereal3::SizeType size1 = region1.GetSize();
  const PixelTypereal3 * itkBuffer = input->GetBufferPointer();

  const unsigned int numberOfPixels = size1[0]*size1[1]*size1[2];
  const unsigned int numberOfBytes = numberOfPixels *
sizeof(PixelTypereal3);

  memcpy(reinterpret_cast&lt;float*&gt;( Output.get_image_data().get_data()
) , itkBuffer, numberOfBytes );

return Output;
}


So as memory  is considered, which one is better?
My goal is (for 3d images) just to create the output image from itk filters
and not any intermediate images.

thanks!

--
View this message in context: http://itk-insight-users.2283740.n2.nabble.com/pointer-to-image-data-tp6596336p6597995.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.


More information about the Insight-users mailing list