# Problem with ImageReslice

**URL:** https://discourse.vtk.org/t/problem-with-imagereslice/9705
**Category:** Web
**Created:** [October 31, 2022, 4:18am UTC](https://discourse.vtk.org/t/problem-with-imagereslice/9705 "2022-10-31T04:18:57Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Xoz](https://discourse.vtk.org/user_avatar/discourse.vtk.org/xoz/32/5714_2.png) [@Xoz](https://discourse.vtk.org/u/Xoz)
#### Post date: [October 31, 2022, 4:18am UTC](https://discourse.vtk.org/t/problem-with-imagereslice/9705/1 "2022-10-31T04:18:57Z")

</div>

Hi everyone,  
I’m working on the resliceCursorWidget demo,and did `setColorLevel(1000), setColorWindow(4000)` to change color on the property of the vtkImageSlice instance for better look, but when I make a rotation or some transform, the background seems not to be correct. This is what it looks like,  
 ![my_reslice](https://discourse.vtk.org/uploads/default/original/2X/7/7220613aeeb939de1e7ec9090a58d6d3455d1b20.jpeg)  
What I’m expecting is the edge parts(pointed by blue arrows) should be the same with the empty part(pointed by the green arrow).  
What I’ve done on ImageReslice instance are:

```auto
setSlabMode(SlabMode.MEAN);
setSlabNumberOfSlices(1);
setTransformInputSampling(false);
setAutoCropOutput(true);
setOutputDimensionality(2);
setBackgroundColor(0, 0, 0, 0);

```

Is there any idea for this?

---

<div class="post-metadata">

### Author: ![finetjul](https://discourse.vtk.org/user_avatar/discourse.vtk.org/finetjul/32/154_2.png) [@finetjul](https://discourse.vtk.org/u/finetjul)
#### Post date: [October 31, 2022, 9:16am UTC](https://discourse.vtk.org/t/problem-with-imagereslice/9705/2 "2022-10-31T09:16:19Z")

</div>

I wonder if [this commit](https://github.com/Kitware/vtk-js/pull/2606/commits/bfb9a224c40d8a40bbb573036da80579de5b7b3f#diff-3ec697cf21ee76ec96f860fa2914d323f11fb5ea541aaa4654699943cebf6501) has fixed the `setBackgroundColor()` setter.  
Would you mind trying with latest master branch?

Please note that the background color variable is still not well handled. It should have as many components as your input volume (e.g. 3 if input volume is RGB, 1 if input volume is single scalar).

---

<div class="post-metadata">

### Author: ![Xoz](https://discourse.vtk.org/user_avatar/discourse.vtk.org/xoz/32/5714_2.png) [@Xoz](https://discourse.vtk.org/u/Xoz)
#### Post date: [October 31, 2022, 11:04am UTC](https://discourse.vtk.org/t/problem-with-imagereslice/9705/4 "2022-10-31T11:04:44Z")

</div>

Hi Julien,  
I tried the latest 25.11.0 but it seems not work, my input volume is single scalar from a series of CT scan, when I did `setBackgroundColor(0)` or `setBackgroundColor(0, 0, 0)` I got `Invalid number of values for array setter (backgroundColor)` , it only worked when I did `setBackgroundColor(0, 0, 0, 0)` but the problem still remained

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [October 31, 2022, 12:15pm UTC](https://discourse.vtk.org/t/problem-with-imagereslice/9705/5 "2022-10-31T12:15:49Z")

</div>

This is a CT image, so the black area probably has a value of -1000. Try this:

```nohighlight
setBackgroundLevel(-1000.0);

```

In a CT image that uses Hounsfield units, the following values can be useful:

```nohighlight
-1000 air
    0 water
+1000 hard bone

```

* * *

Since vtk.js doesn’t have `setBackgroundLevel()`, do this instead:

```nohighlight
setBackgroundColor(-1000.0, -1000.0, -1000.0, 0.0);

```

---

<div class="post-metadata">

### Author: ![Xoz](https://discourse.vtk.org/user_avatar/discourse.vtk.org/xoz/32/5714_2.png) [@Xoz](https://discourse.vtk.org/u/Xoz)
#### Post date: [November 1, 2022, 1:05am UTC](https://discourse.vtk.org/t/problem-with-imagereslice/9705/6 "2022-11-01T01:05:47Z")

</div>

Thank you, this works

---

<div class="post-metadata">

### Author: ![Xoz](https://discourse.vtk.org/user_avatar/discourse.vtk.org/xoz/32/5714_2.png) [@Xoz](https://discourse.vtk.org/u/Xoz)
#### Post date: [November 1, 2022, 1:51am UTC](https://discourse.vtk.org/t/problem-with-imagereslice/9705/7 "2022-11-01T01:51:29Z")

</div>

The final solution is:

1. Upgrade to latest version(currently v25.11.0 with the **Image reslice oriented image support** )
2. `setBackgroundColor(-1000.0, -1000.0, -1000.0, 0.0)`  
Previous versions will not support a color value of negative number in the params
