hello everyone,
I use the code below to read a segmentation file and then convert image data to surface polydata ,write to .vtp file. The code works fine.Then i open the origin .nii.gz file and the generated vtp file in 3DSlicer, i found there has a offset between two surface, shouldn’t them be overlapped?
I want know what causes the offset and how to fix this problem.
//read nii.gz segment file with vtkNIFTIImageReader
vtkSmartPointer<vtkNIFTIImageReader> reader = vtkSmartPointer<vtkNIFTIImageReader>::New();
reader->SetFileName("D:/proj/vmtk_out/N-1000349/N-1000349.seg.nii.gz");
reader->Update();
//convert to vtkPolyData and then write to file
vtkSmartPointer<vtkMarchingCubes> surface = vtkSmartPointer<vtkMarchingCubes>::New();
surface->SetInputConnection(reader->GetOutputPort());
surface->ComputeNormalsOn();
surface->ComputeGradientsOn();
surface->SetValue(0, 0.5);
surface->Update();
vtkSmartPointer<vtkXMLPolyDataWriter> writer = vtkSmartPointer<vtkXMLPolyDataWriter>::New();
writer->SetFileName("D:/proj/vmtk_out/N-1000349/surface.vtp");
writer->SetInputData(surface->GetOutput());
writer->SetDataModeToAscii();
writer->Write();