Hello Group, I have a question about how vtkImageReslice works .
I understand that with SetResliceAxes we can define a transformation matrix to the reslicer, where
the last column is the translation in 3D space.
The problem is that let’s say for an initial volume I want to translate it on x or on y axis, it doesn’t take into account them and reslicer returns with the original image.
The question is, how can I tell vtkImageReslicer to return with the ‘translated’ image
or how can I convert 3D reslice coordinate to the 2D plane x and y ?
When vtkImageReslice applies a transform, by default it automatically adjusts the bounding box (i.e. the Origin and dimensions of the volume). So when you apply a translation transformation, in the end it will accomplish the translation simply by adjusting the Origin. The image will look exactly the same, the only change will be that the physical coordinates of the image have shifted.
For your requirements, I think the best approach is to hold the Origin fixed when you apply the translation. There are two ways of doing this.
One way is to call SetOutputOrigin() to tell vtkImageReslice exactly what the Origin should be for the output image (you can set it to be the same as the input image, or to whatever you want).
The other way is to call SetInformationInput() to specify an image that will provide the Origin and dimensions for vtkImageReslice to use for you output. If the InformationInput is set to the same as the main input, then the output will always have the same origin and dimensions as the input. So this can be used unless you are trying to extract a single slice from a volume.
after this I call SetResliceAxes to set reslice rotation and translation
then I get the result imageData by calling reslice->GetOutput().
So my question is:
Is it possible to turn off this automatic bounding box adjustment feature, so reslicer returns with the shifted image?
or
what is the formula that gives me the translation amount this automatic bounding box adjustment applies ? (like shiftX, shiftY).
The only methods for turning it off are the ones I gave before: the InformationInput like you’ve done above, and directly setting the OutputOrigin (and OutputSpacing and OutputExtent also need to control the size if the matrix scales the volume).
Some control over the bounding box is possible with these flags:
SetAutoCropOutput(true) causes the bounding box of the output to always be large enough that it fully contains the transformed input bounding box (imagine using transforming the 8 corner points of the input bounds, and creating a bounding box that just large enough to contain all 8 of those points). This is off by default, and you’ll want to keep it off.
SetTransformInputSampling(true) causes the spacing and dimensions to be rotated by the ResliceAxes matrix (and scaled, if ResliceAxes applies a scale). This is on by default, and it’s main purpose is to make it easy to do orthogonal reformats e.g axial to coronal or sagittal. This setting doesn’t change the behavior regarding translation.
There is no simple flag for turning off the translation of the bounding box. When this filter was originally written, the application of a translation was thought of as more of a padding or cropping kind of operation, rather than a reslicing or resampling operation.
I’ve tried to find this automatic bounding box adjustment in the code, but no luck so far. Could you tell me please, where can I find it, so I can apply its inverse to the output origin?