# ColorLevel/Window in vtkImageCPRMapper

**URL:** https://discourse.vtk.org/t/colorlevel-window-in-vtkimagecprmapper/13741
**Category:** Support
**Created:** [April 18, 2024, 2:04pm UTC](https://discourse.vtk.org/t/colorlevel-window-in-vtkimagecprmapper/13741 "2024-04-18T14:04:17Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![steveryuan](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/b9e5f3/32.png) [@steveryuan](https://discourse.vtk.org/u/steveryuan)
#### Post date: [April 18, 2024, 2:04pm UTC](https://discourse.vtk.org/t/colorlevel-window-in-vtkimagecprmapper/13741/1 "2024-04-18T14:04:17Z")

</div>

Hi everyone,

I was using vtkImageCPRMapper for CPR reconstruction (vtk.js 29.8.0). However, when I tried to set the values of _ProjectionSlabNumberOfSamples_ and _ProjectionSlabThickness_ for projection, the color window of the results unexpectedly changed. Here are the images:  
\<1\>

 ![image](https://discourse.vtk.org/uploads/default/original/2X/a/af24da9da7f0a93c9e38d1a5ee20eb762ba987e7.jpeg)  
\<2\>  
 ![image](https://discourse.vtk.org/uploads/default/original/2X/3/3dcfd8845814c443281b29f49920f4b831c0b8ee.jpeg)  
For both images, I set window level to 40 (by _vtkImageProperty.setColorLevel_) and window width to 350 (by _vtkImageProperty.setColorWindow_). The differences are:  
For image\<1\>, the number of samples was set to 1 (by _vtkImageCPRMapper.setProjectionSlabNumberOfSamples_) and thickness was set to 0 (by _vtkImageCPRMapper.setProjectionSlabThickness_),  
while for image\<2\>, the number of samples was set to 500 and thickness was set to 0.2.

Could I ask why is this happening? My guess is vtkImageCPRMapper assigned 0 to the values of some sample pixels, but in CT images the minimum of the pixel value is negative (e.g. air in lung). It results in the misted image.

I am not sure about my guess and how to achieve the desired result. Any help is appreciated!

---

<div class="post-metadata">

### Author: ![steveryuan](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/b9e5f3/32.png) [@steveryuan](https://discourse.vtk.org/u/steveryuan)
#### Post date: [April 18, 2024, 4:40pm UTC](https://discourse.vtk.org/t/colorlevel-window-in-vtkimagecprmapper/13741/2 "2024-04-18T16:40:45Z")

</div>

Based on my guess above, I searched Internet and found that there is a class in SimpleITK named ResampleImageFilter ([SimpleITK: itk::simple::ResampleImageFilter Class Reference](https://simpleitk.org/doxygen/latest/html/classitk_1_1simple_1_1ResampleImageFilter.html)). The class has a member function _SetDefaultPixelValue()_ for setting the pixel value when a transformed pixel is outside of the image. And the default default pixel value is 0. If the CPRMapper in VTK has similar mechanism, it could explain the problem.

So is there a way to set the default pixel value when we do resampling in VTK (like changing the value by _vtkImageCPRMapper.setProjectionSlabThickness_)?
