繁体   English   中英

如何使用VTK在X,Y和Z中旋转dicom?

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

需要能够旋转内存中的dicom块,然后将.mhd写入此结果。

我知道在VTK中可以与相机配合使用以产生这些效果,并且vtkimageSlice可以以统一的方式进行切割。

但是不能旋转的是轴xy z上的dicom自有块。

我看到这篇文章在x = y Line上翻转了一个DICOM图像 ,这是制作vtkTransform的一种形式,但是在新版本的vtk(6.3)中却无法使其工作。

我可以做如下

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();

然后我们将其保存为.mhd

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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