[Image-SIG] window level and width

Fredrik Lundh fredrik at pythonware.com
Wed Jun 6 11:17:20 CEST 2007

Dr.Ashoka G K wrote:

> Many DICOM related softwares have a feature to alter window level and
> window width of the images. Is this the same as changing the
> brightness and contrast of the image?

my guess is that the "window" is the range of levels in the source image 
that's being mapped to the 256 levels supported by most displays.

if "image" is an "L" or "I" image, you can use the "point" method to do 
linear windowing:

    scale = 256.0 / window_width
    offset = -window_level * scale

    out = image.point(lambda i: i * scale + offset, "L")

to implement non-linear transforms, use a lookup table instead (see the 
"point" documentation for details).

hope this helps!


More information about the Image-SIG mailing list