Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

How to apply CT window settings in Python

Adjusting Window Center and Width settings in CT scans for enhanced medical imaging clarity

CT window settings in this page are the two numbers you pass to a converter: window center (WC) and window width (WW). The job is to apply them to a DICOM CT series in Python so a liver, lung, tumor, or bone window is a file you can open — not a slider lecture.

If you meant WW vs WL as a conceptwindow width vs window level. If you meant the HU scalewhat Hounsfield units are. If you meant windowing as a preprocess step before a model → what is image preprocessing.

This URL is also the landing for the leftover /dicommriwindowing/ and /niftictwindowing/ paths. Same apply-windowing job. Not a new post.

WC and WW

Window center (WC) is the midpoint of the HU range you display. Raise it and the image goes darker; lower it and the image goes brighter. Same slider 635 calls window level.

Window Width (WW) is the width of that range. Narrow WW = high contrast (tissues near the center separate). Wide WW = more greys at once (survey view, less punch).

A monitor shows about 256 greys. A CT stores a few thousand HU. Windowing is the clip that makes one organ readable. The numbers themselves live on the Hounsfield scale.

Apply it in Python

The converter is DicomCTWindowing from pycad-medic. Point it at a DICOM series folder. It writes a windowed output.

from pycad.preprocessing import DicomCTWindowing

dicom_dir = "path/to/dicom/series"
output_dir = "path/to/output"
window_center = 40
window_width = 400
converter = DicomCTWindowing(window_center, window_width, visualize=True)
converter.convert(dicom_dir, output_dir)

window_center and window_width are the two knobs. visualize=True opens a preview so you can see the preset before you batch. Change the pair, re-run. That is the whole how-to.

Presets already in the examples

Target WC (HU) WW (HU) Why that pair
Soft-tissue default (script above) +40 400 Midpoint on soft tissue; a usable first pass
Liver +60 150 Narrow width so liver texture and a lesion in it separate
Lungs −600 to −700 1500 to 2000 Center on air-filled lung; wide enough for vessels and a nodule
Tumor (against nearby soft tissue) Slightly above the host organ Moderate Raise WC so the mass is not the same grey as the bed it sits in
Bone +400 to +700 1500 to 2000 Center on cortex; wide enough for marrow vs cortex

These numbers are the ones the original examples used. They are starting points, not a protocol Bible. A PE study still wants the lung pair; a hairline fracture still wants the bone pair. If you need the clinical why for those three named windows, that is window width vs window level.

Liver

WC about +60 HU, WW 150 HU. Liver texture and a density change inside it show up; a wide soft-tissue window washes that out.

CT liver window, WC +60 HU, WW 150 HU

Lungs

WC −600 to −700 HU, WW 1500 to 2000 HU. Air is the bed; vessels and a nodule stay visible because the width is wide.

CT lung window, WC −600 to −700 HU, WW 1500 to 2000 HU

Tumors

Location decides the pair. A slightly higher WC than the host organ, and a moderate WW, is the usual move so the mass is not the same grey as the tissue around it.

CT tumor window, WC raised against surrounding soft tissue

Bones

WC +400 to +700 HU, WW 1500 to 2000 HU. Cortex stays bright; a fracture line is a dark break, not a smear.

CT bone window, WC +400 to +700 HU, WW 1500 to 2000 HU

What this page is not

It is not a comparison of the two sliders — that is 635. It is not the HU table — that is 622. MRI intensity has no Hounsfield scale; do not paste these presets onto an MRI series and expect the same picture.

PYCAD builds the imaging side of products that have to window a series for real. Case studies.

We build custom medical imaging platforms — advanced DICOM viewers, AI segmentation, and the clinical systems around them.

Get in Touch

Copyright © 2026 PYCAD. All Rights Reserved.