简体   繁体   中英

How can rotate dicom in the X, Y and Z with VTK?

need to be able to rotate an dicom block in memory, and then write an .mhd to this result.

I know that in VTK is possible to work with the camera to have these effects, and vtkimageSlice can cut in a uniform manner.

But what can not rotate is the dicom own block on the axis xy z.

I saw this post Flip a DICOM Image over the x = y Line , a form to make vtkTransform, but in the new version of vtk (6.3) was not able to make it work.

I could do as follows

string path;

vtkDICOMImageReader *reader = vtkDICOMImageReader::New();
reader->SetDirectoryName(path.c_str());
reader->Update();
double bounds[6];
reader->GetOutput()->GetBounds(bounds);


vtkSmartPointer<vtkTransform> transform = vtkSmartPointer<vtkTransform>::New();

double center[3];
center[0] = (bounds[1] + bounds[0]) / 2.0;
center[1] = (bounds[3] + bounds[2]) / 2.0;
center[2] = (bounds[5] + bounds[4]) / 2.0;

transform->Translate(center[0], center[1], center[2]);
transform->RotateX(90);
transform->Translate(-center[0], -center[1], -center[2]);

vtkSmartPointer<vtkImageReslice> reslice = vtkSmartPointer<vtkImageReslice>::New();
reslice->SetInputConnection(reader->GetOutputPort());
reslice->SetResliceTransform(transform);
reslice->SetInterpolationModeToCubic();
reslice->SetOutputSpacing(reader->GetOutput()->GetSpacing()[0], reader->GetOutput()->GetSpacing()[1], reader->GetOutput()->GetSpacing()[2]);
reslice->SetOutputOrigin(reader->GetOutput()->GetOrigin()[0], reader->GetOutput()->GetOrigin()[1], reader->GetOutput()->GetOrigin()[2]);
reslice->SetOutputExtent(reader->GetOutput()->GetExtent());


//Saida alterada!
reslice->GetOutput();

then we save in a .mhd

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM