and here the error : ERROR: In /work/standalone-x64-build/VTK-source/Common/ExecutionModel/vtkDemandDrivenPipeline.cxx, line 809 vtkCompositeDataPipeline (0x4d9cac0): Input for connection index 0 on input port index 0 for algorithm vtkPolyDataWriter(0x4de3ea0) is of type vtkImageData, but a vtkPolyData is required.
I was wondering as to what would be a good way of writing a vtk Polydata file. thanks
You are lacking the steps of segmenting your image, and converting that segmentation into polygonal mesh. Here is a discussion about it on the Slicer forum:
There are many methods for segmentation, a quick one to start with is Otsu (this 2D example should not be hard to extend to 3D). You can use BinaryMask3DMeshSource to convert that into a mesh, and write using MeshFileWriter. You could start from this 3D example.
thank you very much. So as I understand :
1 reading nifti file (segmented file)
2 apply itktovtkfilter
3 creating meshes (using the vtkContourFilter)
4 and finaly convert it to polydata and save it to .vtk file
when I run it with itkToVtkFilter.Update() : Erreur de segmentation (core dumped)
but when I run it without itkToVtkFilter.Update() : vtkMarchingCubes (0x4d03f80): Scalars must be defined for contouring
This might produce an empty image. Try setting ThresholdBelow to a value other than zero. Try 100, 300, and 1000.
The contour filterās input will be null pointer. Of course it complains.
Also, generating an isosurface should be done on the original volume, not a thresholded one. In essence you are trying to combine ITKās and VTKās way of extracting isosurface, but in a weird (improper) way.
thank you sir for your quick answer : #segmentation
thresholdFilter = itk.ThresholdImageFilter[ImageType].New()
thresholdFilter.SetInput(reader.GetOutput())
thresholdFilter.ThresholdBelow(0.1)
thresholdFilter.SetOutsideValue(0)
thresholdFilter.Update()
because I have done a normalization of the image pixel between 0 and 1
and it is the same error : Erreur de segmentation (core dumped)
Can you copy-paste the detail of the error from that āUbuntuā error dialog? I am afraid that something is wrong with your Python or ITK installation.