I would like to import an image from buffer; is it right?
const unsigned short numberOfPixels = pow(size_import_buffer[0] , 3);
auto * localBuffer = new PixelType[numberOfPixels];
PixelType * it = localBuffer;
for(int z= 0 ; z < size_for_dimensions[2]; z++)
for(int y= 0 ; y < size_for_dimensions[2]; y++)
for(int x= 0 ; x < size_for_dimensions[2]; x++)
{
const ImageType::IndexType pixelIndex_Buffer_1 = {{ x, y, z }}; // Position of {X,Y,Z}
std::cerr<<"HI: "<<std::endl;
*it++ = Flipped_Trachea -> GetPixel(pixelIndex_Buffer_1);
}
const bool importImageFilterWillOwnTheBuffer = true;
importFilter->SetImportPointer(localBuffer, numberOfPixels, importImageFilterWillOwnTheBuffer);
auto writerTraqueia = WriterTypeTraqueia::New();
writerTraqueia->SetFileName("TRACHEA AIRWAY SEG.dcm");
writerTraqueia->SetInput(importFilter->GetOutput());
writerTraqueia->SetImageIO(gdcmIO);
writerTraqueia->Update();