[vtkusers] Export data from VTK to ITK
Massi
Massinissa.Bandou at USherbrooke.ca
Wed Oct 3 19:35:24 EDT 2012
I got the previous error by changing mesh to image and use
itkvtkImageToImageFilter instead of itkVTKImageImport
#include "vtkDICOMImageReader.h"
#include "vtkContourFilter.h"
#include "vtkPolyDataConnectivityFilter.h"
#include "vtkImageExport.h"
#include "itkVTKImageImport.h"
#include "itkMesh.h"
#include "itkImageFileWriter.h"
#include "vtkImageToImageFilter.h"
int main(int argc, char *argv[]) {
vtkSmartPointer<vtkDICOMImageReader> Read =
vtkSmartPointer<vtkDICOMImageReader>::New();
Read->SetDirectoryName(filename.c_str());
Read->Update();
//Get the contour of the PolyData
vtkSmartPointer<vtkContourFilter> contour =
vtkSmartPointer<vtkContourFilter>::New();
contour->SetInput(Read->GetOutput());
contour->ComputeScalarsOff();
contour->SetValue(0,0.5);
//Mesh the largest contour
vtkSmartPointer<vtkPolyDataConnectivityFilter> connectivityFilter =
vtkSmartPointer<vtkPolyDataConnectivityFilter>::New();
connectivityFilter->SetInput(contour->GetOutput());
connectivityFilter->SetExtractionModeToLargestRegion();
connectivityFilter->Update();
//Export vtk Data to ITK
vtkImageExport* exportdata = vtkImageExport::New();
exportdata->SetInput(connectivityFilter->GetOutput());
vtkSmartPointer<vtkImageExport> exportdata =
vtkSmartPointer<vtkImageExport>::New();
exportdata->SetInput(connectivityFilter->GetOutput());
typedef itk::Image<unsigned short, 3> ImageType;
typedef itk::VTKImageToImageFilter<ImageType> itkvtkConverter;
itkvtkConverter::Pointer conv =itkvtkConverter::New();
conv->SetInput(exportdata->GetOutput());
return EXIT_SUCCESS;;
}
--
View this message in context: http://vtk.1045678.n5.nabble.com/Export-data-from-VTK-to-ITK-tp5716418p5716434.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list