[ITK] how to output 3d tiff stack from a memory buffer

Ronn Kling ronn at rlkling.com
Fri Jan 30 08:30:44 EST 2015


All,

I have a 3D memory buffer (resampledBuffer) that came from a non ITK 
source and I want to write it out as a 3D tiff stack. This is what I am 
trying.  Now I know that FillBuffer only takes a constant fixed pixel 
type, but there must be a way to get resampledBuffer into them 
resampleImage pointer?

           typedef   itk::ImageFileWriter< movingImageType > 
MovingWriterType;
           MovingWriterType::Pointer movingWriter = MovingWriterType::New();
           itk::ImageIOBase::Pointer imageIO3 = itk::TIFFImageIO::New();
           movingWriter->SetImageIO(imageIO3);
           movingWriter->SetFileName(outputFileName);

          //output the 3d tiff stack
          typedef itk::Image< int, 3 >  ImageType;
          ImageType::Pointer  resampledImage = ImageType::New();

          resampledImage->FillBuffer(resampledBuffer);  //not right, but 
what to use instead?

          movingWriter->SetInput(resampledImage);
          movingWriter->Write();


More information about the Community mailing list