Here is my code to display 2d
slices of DICOM volume using vtk renderer with python :
# Read DICOM images
self.reader = vtk.vtkDICOMImageReader()
#Create Sagittal Slice Matrix
sagittal = vtk.vtkMatrix4x4()
sagittal.DeepCopy((0, 0, -1, center,
1, 0, 0, center,
0, -1, 0, center,
0, 0, 0, 1))
# Reslice image
widget = QVTKRenderWindowInteractor()
slice = vtk.vtkImageReslice()
# Display the image
actor = vtk.vtkImageActor()
renderer = vtk.vtkRenderer()
# Remove Renderer And Reset
# Set up the interaction
slice_interactorStyle = vtk.vtkInteractorStyleImage()
slice_interactor = widget.GetRenderWindow().GetInteractor()
# Start interaction
This is also my output :
The vtkImageProperty can be used to adjust the contrast. For a 16 bit CT you can use the following as a starting point:
This is exactly what I wanted
Thank You very much for your answering
could you please explain a little about color window and color level ?
what are they changing and effecting on?
VTK’s “ColorWindow” and “ColorLevel” correspond to what radiologists usually call the “window level” and “window width”, e.g.:
Windowing, also known as grey-level mapping, contrast stretching, histogram modification or contrast enhancement is the process in which the CT image greyscale component of an image is manipulated via the CT numbers; doing this will change the ap...
To make a long story short, the image mapper has a lookup table (grayscale by default), and the ColorWindow and ColorLevel in the image property control the range of image values that are mapped through the lookup table.
for volume is it also the same way or is different?
You mean volume rendering, i.e. vtkVolumeProperty? Completely different.
I mean for adjusting the volume contrast too what should I do?
as you see my volume has lots of noise too.
as I searched , only understand that I have to use vtkPiecewiseFunction with vtkVolumeProperty.setColor()
but I’m not sure about t it
I’m first in vtk.
Thank you so much for all your helpful responses.
I have exactly similar project but I am new to python. I need to ask some basics. How can I contact with you?
Im working on a same project but on pelvis. I need to add implant to some pictures and move them to find the best position. Since last time I messaged I had succeeded a lot. Do you find any way to make a 3D stl file from CT-Images?