[vtkusers] dicom series image orientation problem! request David for help!
scofield zhu
scofieldzhu.zcg at gmail.com
Tue Jun 5 04:30:26 EDT 2018
hi david,
I use vtkGDCMImageReader(gdcm2.8.5) to read dicom serires image, and
SetFileLowerLeftOn() called too. after success reading, the process image
codes as following:
_____________________________________________________________________________
Point3 data_origin = imgdata->GetOrigin();
Point3 dataorigin = info->origin;
Point3 patient_position = info->patient_position;
//here: i am sure:data_origin is equal with both dataorigin and
patient_position
Vec3 row_orient = info->patient_row_orientation;
Vec3 col_orient = info->patient_col_orientation;
Vec3 slice_orient = info->patient_orientation;
vtkMatrix4x4* matrix = vtkMatrix4x4::New();
matrix->Identity();
matrix->SetElement(0, 0, row_orient[0]);
matrix->SetElement(0, 1, row_orient[1]);
matrix->SetElement(0, 2, row_orient[2]);
matrix->SetElement(1, 0, col_orient[0]);
matrix->SetElement(1, 1, col_orient[1]);
matrix->SetElement(1, 2, col_orient[2]);
matrix->SetElement(2, 0, slice_orient[0]);
matrix->SetElement(2, 1, slice_orient[1]);
matrix->SetElement(2, 2, slice_orient[2]);
vtkMatrix4x4* inverse_matrix = vtkMatrix4x4::New();
matrix->Invert(matrix, inverse_matrix);
double new_origin[4] = {0.0};
new_origin[3] = 1.0;
inverse_matrix->MultiplyPoint(data_origin, new_origin);
inverse_matrix->Delete();
vtkImageChangeInformation* imgchangeinfo =
vtkImageChangeInformation::New();
imgchangeinfo->SetOutputOrigin(new_origin[0], new_origin[1],
new_origin[2]);
imgchangeinfo->SetInputData(imgdata);
imgchangeinfo->Update();
imgdata->DeepCopy(reslice->GetOutput());
imgchangeinfo->Delete();
vtkTransformFilter* transform_filter = vtkTransformFilter::New();
vtkTransform* patient_transform = vtkTransform::New();
patient_transform->SetMatrix(matrix);
transform_filter->SetTransform(patient_transform);
transform_filter->SetInputData(imgdata);
transform_filter->Update();
imgdata->DeepCopy(transform_filter->GetOutputDataObject(0));
transform_filter->Delete();
patient_transform->Delete();
matrix->Delete();
__________________________________________________________________________
it works ok in some dicom series image, but not working for some series
image especially single dcm file with multi-frame.
what's wrong in my code? please help me ! thanks a lot!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20180605/b23f0727/attachment-0001.html>
More information about the vtkusers
mailing list