[vtkusers] Simple Viewer Dicom

David Gobbi david.gobbi at gmail.com
Fri Sep 11 13:02:23 EDT 2015


Hi Pedro,

Take a look at Examples/ImageProcessing/Python/ImageInteractorReslice.py
(in the VTK source).  It provides window/level interaction with the left
mouse button.

 - David

On Fri, Sep 11, 2015 at 12:52 AM, Pedro Paulo <pedropaulobmjr at hotmail.com>
wrote:

> Hello, I am developing an application in python to view a dicom image and
> to change brightness and contrast, I could already make application to
> view, from this example (
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/IO/ReadDICOM) I adapted to
> python, and when show the picture if I press the left button mouse and move
> it across the image it changes the brightness and contrast of it, and if I
> press the R key the pixels back the original settings. So my question is,
> how can I make these changes brightness, contrast and R button (to reset
> the values of the original pixels) in my code? I would not like to do
> algebraic operations on pixels of the dicom image, such as gamma correction
> for contrast, but I wanted functions that VTK probably already own, but
> searching I have not found. I thank the attention.
>
>
> The code in python that I adapted:
>
> import vtk
> import sys
>
> def show_dicom_image(ndicom):
> reader = vtk.vtkDICOMImageReader()
> reader.SetFileName(ndicom)
> reader.Update()
>
> # Visualize
> imageViewer = vtk.vtkImageViewer()
> imageViewer.SetInputConnection(reader.GetOutputPort())
> renderWindowInteractor = vtk.vtkRenderWindowInteractor()
> imageViewer.SetupInteractor(renderWindowInteractor)
> imageViewer.Render()
> imageViewer.GetRenderer().ResetCamera()
> imageViewer.Render()
> renderWindowInteractor.Start()
>
> show_dicom_image(sys.argv[1])
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150911/6496b0bb/attachment.html>


More information about the vtkusers mailing list