3 from gdcmConfigDemo import *
4 from gdcmPython.vtk import *
5 from vtkpython import *
11 print "%s <fileName>" % sys.argv[0]
12 print " fileName : path to the DICOM file to see"
18 fileName = sys.argv[1]
20 fileName = os.path.join(GDCM_DATA_ROOT, "test.acr")
21 if( not os.path.isfile(fileName) ):
22 fileName=os.path.join(os.path.split(sys.argv[0])[0],"test.acr")
24 if( not os.path.isfile(fileName) ):
29 reader = vtkGdcmReader()
30 reader.SetFileName(fileName)
34 writer = vtkGdcmWriter()
35 writer.SetInput(reader.GetOutput())
36 writer.SetFileName("outputPy.dcm")
40 reader2 = vtkGdcmReader()
41 reader2.SetFileName("outputPy.dcm")
45 viewer = vtkImageViewer()
46 viewer.SetInput(reader2.GetOutput())
47 rng = reader.GetOutput().GetScalarRange()
48 viewer.SetColorWindow(rng[1] - rng[0])
49 viewer.SetColorLevel(0.5 * (rng[1] + rng[0]))
51 dim = reader.GetOutput().GetDimensions()
52 viewer.SetSize(dim[0],dim[1])
54 # For multiframe dicom, take a snapshot of the center slice (+/- 1)
55 viewer.SetZSlice(dim[2] / 2)