[Insight-users] about changing itk image to vtk image

Yixun Liu yxliu at fudan.edu.cn
Thu Apr 27 20:21:10 EDT 2006


Hi,

I read dicom using itk and change it to vtk to visualize it. I read dicom and change it to vtk in fun1();

ImageType::Pointer* fun1()
{
...
 dicomReader = ReaderType_Short::New();//itk
...
  //convert itk image to vtk image
    connectorMRI = ConnectorType::New();
 connectorMRI->SetInput(dicomReader->GetOutput());
 try
 { 
  connectorMRI->Update();
 }
 catch( itk::ExceptionObject & excp )
 {
  std::cerr << "Error reading the series " << std::endl;
  std::cerr << excp << std::endl;
 }

return connectorMRI->GetOutput();

}


In fun2(), I generate a volume and render it.
fun2()
{
  vtkVolume *volume = GenerateVolume(fun1());

vtkWin->Render();

}


However, exception occurs. If I change the connectoMRI to class variable instead of local variable. I can render it correctly. I do not konw the reason. I guess that if connectorMIR is a local variable it release memory when the fun1 return. 

Regards,

Yixun Liu

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20060428/02cc08af/attachment.htm


More information about the Insight-users mailing list