I have a DICOM volume (read by the vtkDICOMreader) visualized using the vtkGPUVolumeRayCastMapper. Working fine.
Moreover, I have vtkImageReslice with Dimensions set on 2, so the output is the plane in fact.
I can output the resliced plane to 2D image viewer window. This works fine too.
What I need now is to visualize the vtkImageReslice output in the volume rendering window, i.e. to visualize exactly the vtkImageReslice output (the plane) placed correctly inside the volume and see its bounds.
I have no clue how to do it. I will appreciate any advice.
Thank you and have a nice day,
I have solved this by myself. Following is the solution, for everyone that needs it.
- First, dimensions are set to 3 for visualisation. Once you see the correct 3D imageReslice output, we can change it back to 2.
- Create the mapper and volume for imageReslice
- Set volume mapper to the created one
- Add the volume to the renderer
Here is the code snippet (Python):
#creating volume property - I want only the red color mapping for the imageReslice for visualisation
opacityTransferFunction1 = vtk.vtkPiecewiseFunction()
colorTransferFunction1 = vtk.vtkColorTransferFunction()
colorTransferFunction1.AddRGBPoint(0.0, 0.1, 0.0, 0.0)
colorTransferFunction1.AddRGBPoint(255.0, 1.0, 0.0, 0.0)
volumeProperty1 = vtk.vtkVolumeProperty()
self.imageReslice = vtk.vtkImageReslice()
self.imageReslice.SetResliceAxesDirectionCosines(1, 0, 0, 0, 0, 1, 0, -1, 0)
self.imageReslice.SetOutputExtent(0, 100, 0, 100, 0, 200)
#extractor is the vtkExtractVOI object
self.imageReslice.SetOutputSpacing(1, 1, 1)
reslicedVolumeMapper = vtk.vtkFixedPointVolumeRayCastMapper()
reslicedImageVolume = vtk.vtkVolume()
#the following volume is the volume created from the vtkDICOMReader output. Commented as I don't need to show it always. "ren2" is the renderer of one of the windows I use in my code.
#the following extractorVolume is the volume created from the vtkExtractVOI output.
As I wanted to show only the question relevant code part, the above code snippet is missing parts of adding renderer to window, window interractor, etc. that are standard parts of the vtk pipeline and we can find it in many examples. If you don’t use classes (OOP), remove the “self.” from the above code…
Hope, it can be useful for someone.