[vtkusers] Convert DICOM Image

Pedro Paulo pedropaulobmjr at hotmail.com
Wed Nov 4 17:28:01 EST 2015


Hello, I am trying to make a conversion from a DICOM image to a JPG and save the image, but the image that I produce does not match the original. I know I need rescaling the image to convert it but I do not know how, if you can help me, thank you.Attached image generated, and below the code in python:
from vtk import *
reader = vtkDICOMImageReader()reader.SetFileName('image.dcm')reader.Update()
castFilter = vtkImageCast()castFilter.SetOutputScalarTypeToUnsignedChar()castFilter.SetInputConnection(reader.GetOutputPort())castFilter.Update()
writer = vtkJPEGWriter()writer.SetFileName('output.jpg')writer.SetInputConnection(castFilter.GetOutputPort())writer.Write()
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20151104/c007ee46/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: output.jpg
Type: image/jpeg
Size: 114774 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20151104/c007ee46/attachment.jpg>


More information about the vtkusers mailing list