# Threshold changes when we change contrast value

**URL:** <https://discourse.slicer.org/t/threshold-changes-when-we-change-contrast-value/6621>\
**Category:** Support\
**Tags:** segmentation\
**Created:** [April 26, 2019, 11:45am UTC](https://discourse.slicer.org/t/threshold-changes-when-we-change-contrast-value/6621 "2019-04-26T11:45:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![prorai](https://avatars.discourse-cdn.com/v4/letter/p/e8c25b/32.png) [@prorai](https://discourse.slicer.org/u/prorai)\
**Post date:** [April 26, 2019, 11:45am UTC](https://discourse.slicer.org/t/threshold-changes-when-we-change-contrast-value/6621/1 "2019-04-26T11:45:21Z")

</div>

i’m using contrast change in python code,

i.e.

```
a = slicer.util.arrayFromVolume(self.importedVolume)
self.contrastScale = 2.0
a[:] = a * self.contrastScale

```

i notice that it changes the threshold value impact on volume in segmentation, how can we relate it with original threshold value input for segmentation.

---

<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:** [April 26, 2019, 12:27pm UTC](https://discourse.slicer.org/t/threshold-changes-when-we-change-contrast-value/6621/2 "2019-04-26T12:27:47Z")

</div>

Do _not_ change the voxel values of your volume if you just want to change its display brightness/contrast! Adjust window/level values in the volume’s display node instead.

For example, increase contrast by halving the display window width:

```
displayNode = self.importedVolume.GetDisplayNode()
displayNode.SetAutoWindowLevelOff()
displayNode.SetWindow(displayNode.GetWindow()/2.0)
```

---

<div class="post-metadata">

**Author:** ![prorai](https://avatars.discourse-cdn.com/v4/letter/p/e8c25b/32.png) [@prorai](https://discourse.slicer.org/u/prorai)\
**Post date:** [April 26, 2019, 12:37pm UTC](https://discourse.slicer.org/t/threshold-changes-when-we-change-contrast-value/6621/3 "2019-04-26T12:37:48Z")

</div>

i’m not using it only to change display brightness , i’m using it cause it helps in body part segmentation.  
like it helps to get thin layer of skin etc.

---

<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:** [April 26, 2019, 12:41pm UTC](https://discourse.slicer.org/t/threshold-changes-when-we-change-contrast-value/6621/4 "2019-04-26T12:41:24Z")

</div>

You cannot help segmentation by applying linear offset/scaling to voxels. In general, you must not modify the original image.

Complete all [segmentation tutorials](https://www.slicer.org/wiki/Documentation/Nightly/Training#Segmentation) to learn more about segmentation.
