[Insight-users] Follow up question on import/export data buffer from itk filters

Frank Webster mafeng at hotmail . com
Thu, 11 Sep 2003 20:44:18 -0400


Hi, all:

  I read previous posts on import/export data buffer from itk filters. Here 
I have additional questions regarding this issue.

  As Luis has warned that SetContainerManageMemory() should not be called 
prematurely. I am not quite sure I understand this. I have the following 
code segment to illustrate the situation: Input data buffer from outside; 
release intermidate filter's data when not needed, returned the final 
filter's data buffer in the end.

I put questions between lines.


int testfunc(short *inbuffer, float *outbuffer, int *dims, double *spacing, 
doube *orign, ...)
{
  typedef itk::Image<short, 3> inputImgType;
  typedef itk::Image<float, 3> outputImgType;
  inputImgType::Pointer inputImg;
  outputImgType::Pointer outputImg;

  // Keep track of the number of voxels in the image
  int dataBufferSize = dims[0]*dims[1]*dims[2];

  //set up inputImg region, origin spacing

  inputImg = inputImgType::New();

  inputImg->GetPixelContainer()->SetImportPointer(inbuffer, dataBufferSize, 
false);
  //The above line is similiar to
  //inputImg->GetPixelContainer()->SetContainerManageMemory(false); ?

  itkfilter1->SetInput(inputImg);
  itkfilter1->ReleaseDataFlagOn(); //Could I add on ReleaseDataFlagOn()?

  itkfilter2->SetInput(itkfilter1->GetOutput());
  itkfilter2->ReleaseDataFlagOn(); //Could I?

  itkfilter3->SetInput(itkfilter2->GetOutput());

  outbuffer = 
itkfilter3->GetOutput()->GetPixelContainer()->GetImportPointer();
}

Thanks.

-Feng

_________________________________________________________________
Get 10MB of e-mail storage! Sign up for Hotmail Extra Storage.  
http://join . msn . com/?PAGE=features/es