# how to keep mask image the same color

**URL:** https://discourse.vtk.org/t/how-to-keep-mask-image-the-same-color/12030
**Category:** Support
**Tags:** python, code
**Created:** [July 26, 2023, 1:46pm UTC](https://discourse.vtk.org/t/how-to-keep-mask-image-the-same-color/12030 "2023-07-26T13:46:46Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![yi\_zhang](https://discourse.vtk.org/user_avatar/discourse.vtk.org/yi_zhang/32/7523_2.png) [@yi\_zhang](https://discourse.vtk.org/u/yi_zhang)
#### Post date: [July 26, 2023, 1:46pm UTC](https://discourse.vtk.org/t/how-to-keep-mask-image-the-same-color/12030/1 "2023-07-26T13:46:46Z")

</div>

This is my code

```auto
colors = vtk.vtkImageMapToWindowLevelColors()
colors.SetInputConnection(reslice.GetOutputPort())
colors.SetWindow(auto_w)
colors.SetLevel(auto_l)

imageActor = vtk.vtkImageActor()
imageActor.GetMapper().SetInputConnection(colors.GetOutputPort())

####
lut2 = vtk.vtkLookupTable()
lut2.SetTableRange(reader2.GetOutput().GetScalarRange())
lut2.SetNumberOfColors(2)
lut2.Build()
lut2.SetTableValue(0, 0.0, 0.0, 0.0, 1.0)
lut2.SetTableValue(1, 1.0, 0.0, 0.0, 1.0)

mapper2 = vtk.vtkImageMapToColors()
mapper2.SetLookupTable(lut2)
mapper2.SetInputConnection(reslice2.GetOutputPort())
mapper2.Update()

vesselActor = vtk.vtkImageActor()
vesselActor.GetMapper().SetInputConnection(mapper2.GetOutputPort())

ren = vtk.vtkRenderer()
# ren.SetBackground(0, 0, 0)
ren.AddViewProp(imageActor)
ren.AddViewProp(vesselActor)

```

when I adjusted the image window width and level, the red part will change. How do I keep the red areas the same color?

Original Image

 ![image](https://discourse.vtk.org/uploads/default/original/2X/2/27a313c9834d8b4cd1ce7cf05fb2a45597cd4bd8.jpeg)

After changing

 ![image](https://discourse.vtk.org/uploads/default/original/2X/e/eae76a073d714c5334a0532010f2772aff290b88.jpeg)  
 ![image](https://discourse.vtk.org/uploads/default/original/2X/8/8f304278fe024b4fefb559ca120d9393900e1ce9.jpeg)
