[vtkusers] Set window/level and convert image DICOM

David Gobbi david.gobbi at gmail.com
Thu Jan 21 16:47:43 EST 2016


Hi Pedro,

I recommend using vtkImageMapToColors to apply a greyscale lookup table.
In python, for example, it would look like this:

from vtk import *

greymap = vtkScalarsToColors()
greymap.SetRange(wl - 0.5*ww, wl + 0.5*ww)

applymap = vtkImageMapToColors()
applymap.SetInputConnection(...)
applymap.SetLookupTable(greymap)
applymap.SetOutputFormatToRGB() # or use SetOutputFormatToLuminance()
applymap.Update()

Be careful, though, because according to the DICOM standard the
VOI LUT (i.e. window/level) should only be applied after the Modality LUT
(i.e. the RescaleIntercept/RescaleSlope).  Probably around half of the
CT images and nearly all PET images have RescaleIntercept/RescaleSlope,
so if you do not take these into account, you'll get an incorrect result.
You'd
be safe with MRI, which does not have RescaleIntercept/Slope.

So, of course, I'd suggest that you use my vtk-dicom package ;-)
https://github.com/dgobbi/vtk-dicom
It has a filter called vtkDICOMApplyRescale that will correctly apply the
rescale information.

 - David


On Thu, Jan 21, 2016 at 2:22 PM, Pedro Paulo <pedropaulobmjr at hotmail.com>
wrote:

> Hi people, I want to convert a DICOM image to a png, but, before
> converting, I would like to set the parameters of Window Width and Window
> Center, to that the png image looks like if the parameters of ww/wl were
> seen in a viewer, does anyone know how could I do this?
> Thanks!
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160121/79d6df10/attachment-0001.html>


More information about the vtkusers mailing list