Sorry to bother you.
I really need some help in vtkImageReslice class!!!
The Problem is : I get the vtkImageData from MR dicom images. I want to get the oblique image form it by given origin and direction;
Here is the part of code:
vtkSmartPointer<vtkImageData> m_image_data;
int b_dims[3];
m_image_data->GetDimensions(b_dims); //512, 512, 20
double b_sp[3];
m_image_data->GetSpacing(b_sp); //0.7 0.7 6
double b_center[3];
m_image_data->GetCenter(b_center);
double reslice_matrix[16] = {1, 0, 0, b_center[0],
0, 0, 1, b_center[1],
0, -1, 0, b_center[2],
0, 0, 0, 1};
vtkNew<vtkMatrix4x4> resliceAxes ;
resliceAxes->DeepCopy(reslice_matrix);
int new_dims[3] = {512, 512, 20};
double new_sp[3] = {b_sp[0], b_sp[1], b_sp[2]};
vtkSmartPointer<vtkImageReslice> reslice = vtkSmartPointer<vtkImageReslice>::New();
reslice->SetInputData(m_image_data);
reslice->SetOutputDimensionality(3);
reslice->SetOutputExtent(0, new_dims[0] - 1, 0, new_dims[1] - 1, 0, new_dims[2] - 1);
reslice->SetOutputSpacing(new_sp[0], new_sp[1], new_sp[2]);
//reslice->SetOutputOrigin(b_center);
reslice->SetResliceAxes(resliceAxes);
reslice->SetInterpolationModeToCubic();
reslice->Update();
The question :
How to calc the origin and directionMatrix of reslice data based on resliceAxes and inputData, outputOrigin ?
-
In many examples, the resliceAxesOrigin is usually set to be image center. if I have b_center to be another position, it seem to the same result?
-
In VTK9.0, imagedata has directionMatrix, when I set image data origin and direction matrix, ( origin is not {0, 0, 0}, directionMatrix is not identity matrix) , alse give me a different reslice data.
Thanks very much!