Hi all,
according to solution of my topic with 3D reslicing using vtkImageReslice and transformation matrix I can rotate the reslicing cube inside the vtkExtractVOI.
You can see the topic here: https://discourse.vtk.org/t/problem-with-the-vtkimagereslice-position-help-please/8202?u=jamsoft
It works great. What I need now is to have only the XY plane slice. According to the vtk documentation and SetOutputDimensionality method:
“If the dimensionality is 2D, then the Z extent of the output is forced to (0,0) and the Z origin of the output is forced to 0.0 (i.e. the output extent is confined to the xy plane).”
But, when I try to set the output dimensionality to 2, I get no output. If I set the value of 3 then I have some 2D output but I’m not sure what is it exactly (is it XY plane? Or something else?).
You can see my problem in the following pictures and code snippet:
And the output in the vtkImageViewer2:
center = self.extractor.GetOutput().GetCenter()
transform = vtk.vtkTransform()
transform.PostMultiply()
transform.Translate(-center[0], -center[1], -center[2])
transform.RotateX(45)
# Moving the reslice cube to the center of the cube, i.e. up in the Z-axe direction.
# I need to do the same for all 6 diagonal planes of the extractor cube, so for other rotations
# another axe center will be shifted. The cube size is 20, that's why I move it by 10
# (XY plane to the extractor cube center)
transform.Translate(+center[0], +center[1], +center[2] + 10)
transform.Update()
self.imageReslice = vtk.vtkImageReslice()
self.imageReslice.SetInputConnection(self.extractor.GetOutputPort())
self.imageReslice.SetResliceTransform(transform)
self.imageReslice.InterpolateOn()
self.imageReslice.AutoCropOutputOn()
self.imageReslice.SetOutputSpacing(xSpacing, ySpacing, zSpacing)
self.imageReslice.SetOutputDimensionality(3)
self.imageReslice.UpdateWholeExtent()
viewer = vtk.vtkImageViewer2()
viewer.SetInputConnection(self.imageReslice.GetOutputPort())
viewer.SetColorWindow(255)
viewer.SetColorLevel(127.5)
viewer.Render()
reslicedVolumeMapper = vtk.vtkFixedPointVolumeRayCastMapper()
reslicedImageVolume = vtk.vtkVolume()
reslicedVolumeMapper.SetInputConnection(self.imageReslice.GetOutputPort())
reslicedImageVolume.SetMapper(reslicedVolumeMapper)
reslicedImageVolume.SetProperty(volumeProperty1) #mapping the reslice to the red pallete
self.ren2.AddVolume(volume) #ren2 is renderer of one of the windows.
self.ren2.AddVolume(reslicedImageVolume)
self.ren2.AddVolume(extractorVolume)
Using dimensionality of 2 in the above code gives no output in the vtkImageVIewer2 window (and also in the 3D window). In the vtkImageViewer2 window there is only black image. Also, if I try to save reslice to the file on disk, it is all black.
- What am I doing wrong? What can I do to have 2D output of my reslice?
- What is the output in vtkImageViewer2 if I let dimensionality set to 3? If I can be sure that it is the XY plane then I don’t need answer for the 1st question as it is what I need
Thank you for any advice and have a nice day!
Jirka