[Insight-users] 1. outer layer filter 2. vtk itk convertors help
Ruby Shamir
rubke at cs.huji.ac.il
Sun Jul 18 06:27:42 EDT 2004
Hi All,
1. Is there a filter getting the outer layer from 3D image data? (our
data is MRI head).
2. I tried to convert vtkImageData to itk::Image and then to convert it
back to vtkImageData, but when tried to update() got an exception:
itk::ExceptionObject (0012E984)
Location: "Unknown"
File: f:\itk\code\code\basicfilters\itkvtkimageimport.txx
Line: 102
Description: itk::ERROR: VTKImageImport(09FACC90): Downcast from
DataObject to my Image type failed.
Help.
Thank you,
Ruby
>From outside we run:
v16 = vtkVolume16Reader::New();
... (reading 3D object)
vtkImageData * originalImage = vtkImageData::New();
v16->Update();
originalImage->DeepCopy(v16->GetOutput());
originalImage->SetScalarTypeToUnsignedShort();
originalImage->UpdateData();
vtkImageData * cleanedImage = vtkImageData::New();
cleanedImage->DeepCopy(cleanImageData(originalImage));
And the function is:
vtkImageData * showVolume::cleanImageData (vtkImageData *
originalImageData){
typedef itk::Image<unsigned short, 3> inputImageType;
typedef itk::ImageToVTKImageFilter<inputImageType>
itkToVtkConnectorType;
typedef itk::VTKImageToImageFilter<inputImageType>
vtkToItkConnectorType;
itkToVtkConnectorType::Pointer itkToVtkConnector =
itkToVtkConnectorType::New();
vtkToItkConnectorType::Pointer vtkToItkConnector =
vtkToItkConnectorType::New();
try{
vtkToItkConnector->SetInput(originalImageData);
vtkToItkConnector->GetImporter()->Update();
itkToVtkConnector->SetInput(vtkToItkConnector->GetOutput());
itkToVtkConnector->GetImporter()->Update();
}
catch (itk::ExceptionObject o){
fstream b;
b.open("err.txt",ios::out);
b<<o;
b.close();
}
return (itkToVtkConnector->GetOutput());
}
More information about the Insight-users
mailing list