# How to handle CT intensity / contrast differences

**URL:** https://discourse.slicer.org/t/how-to-handle-ct-intensity-contrast-differences/19604
**Category:** Support
**Created:** [September 10, 2021, 9:35am UTC](https://discourse.slicer.org/t/how-to-handle-ct-intensity-contrast-differences/19604 "2021-09-10T09:35:20Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)
#### Post date: [September 10, 2021, 9:35am UTC](https://discourse.slicer.org/t/how-to-handle-ct-intensity-contrast-differences/19604/1 "2021-09-10T09:35:20Z")

</div>

In the COVID-19 open-source dataset of @PaoloZaffino some CTs have a large variation in terms of brightness, intensity, and contrast.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/6/5695ab3efb6e249273e44f69e64425bd2efdbd6b.jpeg)

Up: weak contrast  
Lower: better contrast

I need to do extensive window leveling work to achieve an acceptable display.  
How do you guys handle this kind of problem? Is there a trick, maybe script, to get a good initial brightness and contrast (lung window) in all CT?

---

<div class="post-metadata">

### Author: ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)
#### Post date: [September 10, 2021, 9:38am UTC](https://discourse.slicer.org/t/how-to-handle-ct-intensity-contrast-differences/19604/2 "2021-09-10T09:38:05Z")

</div>

In astrophotography (fits images) I would “stretch” each image / channel to archieve a similar histogram.

---

<div class="post-metadata">

### Author: ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)
#### Post date: [September 10, 2021, 11:32am UTC](https://discourse.slicer.org/t/how-to-handle-ct-intensity-contrast-differences/19604/3 "2021-09-10T11:32:50Z")

</div>

Probably you just need to set the same window level. Easiest is to use one of the presets in the Volumes module - right click on the volume in the Data module and pick Edit properties then click the lung preset. For dicom we use the window/level from the header (usually set by the radiographer) but for non-dicom there’s a formula which depends on the values in the data, which can vary.

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/5/35d93170990bcc87f0345c7dfb007ea6b4494b87.png)

---

<div class="post-metadata">

### Author: ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)
#### Post date: [September 10, 2021, 1:44pm UTC](https://discourse.slicer.org/t/how-to-handle-ct-intensity-contrast-differences/19604/4 "2021-09-10T13:44:02Z")

</div>

Excellent, that works.

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [September 11, 2021, 12:42am UTC](https://discourse.slicer.org/t/how-to-handle-ct-intensity-contrast-differences/19604/5 "2021-09-11T00:42:21Z")

</div>

See some more information on how to adjust window/level:

> [@Recent improvements in window/level management](https://discourse.slicer.org/t/recent-improvements-in-window-level-management/7284):
>
> This is a quick summary of image window/level (brightness/contrast) adjustment changes introduced in recent Slicer Preview (formerly known as “Nightly”) releases. Improved automatic window/level algorithm Images that do not contain preferred window/level information are displayed with automatically computed values. The complex automatic computation algorithm that had been used in Slicer worked marginally better for some images, but sometimes generated too bright images and overall the results…

I’ve fixed the DICOM import plugin now to [use the middle slice’s window/level instead of the first file’s](https://github.com/Slicer/Slicer/issues/5140). @rbumm It would be great if you could test the Slicer Preview Release tomorrow if the default window/level setting works better.

---

<div class="post-metadata">

### Author: ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)
#### Post date: [September 11, 2021, 10:38am UTC](https://discourse.slicer.org/t/how-to-handle-ct-intensity-contrast-differences/19604/6 "2021-09-11T10:38:56Z")

</div>

Unfortunately, today’s preview Slicer 4.13.0-2021-09-10 does not start correctly on Windows (it shows just the initial splash screen, no further action).

---

<div class="post-metadata">

### Author: ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)
#### Post date: [September 11, 2021, 11:05am UTC](https://discourse.slicer.org/t/how-to-handle-ct-intensity-contrast-differences/19604/7 "2021-09-11T11:05:35Z")

</div>

The only way I got 4.13.0-2021-09-10 starting was to redirect stderr or stdout in powershell command line.

```auto
./Slicer.exe >> err.txt

```

The default window level for the problematic CT (Pat 27 of the public COV dataset) was the same, too bright.  
When I switched to the “Volumes” module slicer crashed.

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [September 11, 2021, 7:30pm UTC](https://discourse.slicer.org/t/how-to-handle-ct-intensity-contrast-differences/19604/8 "2021-09-11T19:30:51Z")

</div>

Thanks for reporting the startup failure/crash, it’s probably due to my changes that I made yesterday in an attempt to improve console output on Windows. I’ll fix it today.

Can you check in the DICOM browser what window width & center values are stored in the files? (right-click on the series and choose View metadata to see the DICOM fields)

---

<div class="post-metadata">

### Author: ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)
#### Post date: [September 11, 2021, 8:52pm UTC](https://discourse.slicer.org/t/how-to-handle-ct-intensity-contrast-differences/19604/9 "2021-09-11T20:52:24Z")

</div>

The open source COV CTs all come as nrrd datasets so they are not in the DICOM database and I can not easily extract the metadata. Pls tell me if you want me to check/do anything else.

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [September 12, 2021, 6:28pm UTC](https://discourse.slicer.org/t/how-to-handle-ct-intensity-contrast-differences/19604/10 "2021-09-12T18:28:01Z")

</div>

I see, there is nothing further to test then. I don’t think nrrd files can store the recommended window/level setting, so for those files the window/level setting is determined automatically (by using a range between the 0.1 and 99.9 percentiles of the intensity histogram).

---

<div class="post-metadata">

### Author: ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)
#### Post date: [September 12, 2021, 7:38pm UTC](https://discourse.slicer.org/t/how-to-handle-ct-intensity-contrast-differences/19604/11 "2021-09-12T19:38:51Z")

</div>

The features of “Volumes” enable a good selection of presets.  
BTW today´s version of the preview release starts up well and “Volumes” does not crash it.
