Usually we use vtkImageViewer2 to show DICOM image. In this case, the display bounds for the image actor is something like [0, MaxX, 0, MaxY, 0, MaxZ]. But if we use vtkImageReslice to cut the DICOM image data, the default bounds for the image actor is something like [-minX, maxX, -minY, maxY, -minZ, maxZ] which is not consistent with vtkImageViewer2. Any idea to solve this issue? Thank a lot.
A quick and dirty way to force the bounds to start at zero is to apply vtkImageChangeInformation after vtkImageReslice. Use SetOutputOrigin(0,0,0) to force the bounds to start at zero.
More generally, when you create a transform for reformatting an image (for use with SetResliceAxes() or SetResliceTransform()), make sure the center-of-rotation for the transform is the center of the image volume.
I fixed my issue by using vtkImageChangeInformation.SetOriginTranslation. Now all the images(axial, saggital, coronal) have correct coordinates. But here I have a new question:
How to convert the 2D display coordiantes to world coordinates by the matrix vtkImageReslice.ResliceAxes? Note that the reslice matrix can be anyone that is not only in orthogonal direction.
If you are using vtkImageViewer2, then there is no easy way to convert the 2D display coordinates to 3D coordinates in the original image space.
If you are serious about 3D coordinates, then I suggest that you use the vtkImageResliceMapper instead of using vtkImageReslice/vtkImageViewer2. The mapper will manage most of the coordinate conversions automatically when you use a vtkPicker to pick a 2D position in the image.