Hello,
I split the meniscus from MRI and input it, but this result is not what I expected. I would like to generate a model similar to the real meniscus. I attach the snippet code.
Please, could you help me to find a solution?
Thank you very much in advance!
#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL2);
VTK_MODULE_INIT(vtkInteractionStyle);
#include <vtkSmartPointer.h>
#include <vtkStructuredPointsReader.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkStripper.h>
#include <vtkSmoothPolyDataFilter.h>
#include <vtkProperty.h>
#include <vtkPolyDataNormals.h>
#include <vtkJPEGReader.h>
#include <vtkContourFilter.h>
int main(int argc, char* argv[]) {
vtkSmartPointer<vtkJPEGReader> reader = vtkSmartPointer<vtkJPEGReader>::New();
reader->SetDataScalarTypeToUnsignedChar();
reader->SetFileDimensionality(3);
reader->SetDataOrigin(0, 0, 0);
reader->SetFilePrefix("D:/VS/source/repos/file/");
reader->SetFilePattern("%s%02d.jpg");
reader->SetDataExtent(0, 383, 0, 383, 1, 52);
reader->Update();
vtkSmartPointer<vtkContourFilter> skinExtractor = vtkSmartPointer<vtkContourFilter>::New();
skinExtractor->SetInputConnection(reader->GetOutputPort());
skinExtractor->SetValue(0, 50);
skinExtractor->ComputeGradientsOn();
skinExtractor->ComputeScalarsOn();
vtkSmartPointer<vtkSmoothPolyDataFilter> pSmoothPolyDataFilter = vtkSmartPointer<vtkSmoothPolyDataFilter>::New();
pSmoothPolyDataFilter->SetInputConnection(skinExtractor->GetOutputPort());
pSmoothPolyDataFilter->BoundarySmoothingOn();
pSmoothPolyDataFilter->SetRelaxationFactor(0.05);
pSmoothPolyDataFilter->SetNumberOfIterations(500);
vtkSmartPointer<vtkPolyDataNormals> pPolyDataNormals = vtkSmartPointer<vtkPolyDataNormals>::New();
pPolyDataNormals->SetInputConnection(pSmoothPolyDataFilter->GetOutputPort());
pPolyDataNormals->SetFeatureAngle(200);
vtkSmartPointer<vtkStripper> boneStripper = vtkSmartPointer<vtkStripper>::New();
boneStripper->SetInputConnection(pPolyDataNormals->GetOutputPort());
boneStripper->Update();
auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(boneStripper->GetOutputPort());
auto actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
actor->GetProperty()->SetColor(1, 1, 1);
auto renderer = vtkSmartPointer<vtkRenderer>::New();
renderer->AddActor(actor);
renderer->SetBackground(1.0, 1.0, 1.0);
auto renWin = vtkSmartPointer<vtkRenderWindow>::New();
renWin->AddRenderer(renderer);
auto interactor = vtkSmartPointer<vtkRenderWindowInteractor>::New();
interactor->SetRenderWindow(renWin);
renWin->Render();
auto style = vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
interactor->SetInteractorStyle(style);
interactor->Initialize();
interactor->Start();
return 0;
}