how to adjust the volume position base on image slice

Hi,
My program can render image slice(sagittal, coronal and axial orientation) from DICOM data and the volume base on the DICOM data in a window. But the volume position is not what I want. It’s outside of the slice bound range.

I want to adjust the volume to the correct position like the demo show in the following picture:

I don’t want to adjust the position of the volume manually by setting matrix on UI. I want to my program can do this automatically. I have no idea to realize it. Can some one give me some tips or reference sourc code.
Thanks in advance!

If the images are two different scans then you can align them automatically using intensity-based image registration. You can use ITK or ITK-based registration libraries, such as Elastix.

2 Likes

I successfully adjust the position of the volume by using GetSFormMatrix() from the reader. The volume and the reslice are from the same image source.

//m_imgReader is an object of vtkNIFTIImageReader
vtkSmartPointer<vtkMatrix4x4> matImage = m_imgReader->GetSFormMatrix();
vtkSmartPointer<vtkTransform> transf = vtkSmartPointer<vtkTransform>::New();
transf->SetMatrix(matImage);
transf->PostMultiply();
transf->Concatenate(m_vtkVolume->GetMatrix());
m_vtkVolume->SetUserTransform(transf);

If they are from the different images, I use Elastix and it works well.
Thanks! :grinning:

Great… Can I get the this Source Code??
My program can render image slice… but as I add reslice actor to Volume , Image is broken like this Picture.
image