# Volume Rendering with Binary mask

**URL:** https://discourse.vtk.org/t/volume-rendering-with-binary-mask/4339
**Category:** Development
**Created:** [October 2, 2020, 7:11pm UTC](https://discourse.vtk.org/t/volume-rendering-with-binary-mask/4339 "2020-10-02T19:11:08Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![assia.shabeeba](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/a8b319/32.png) [@assia.shabeeba](https://discourse.vtk.org/u/assia.shabeeba)
#### Post date: [October 2, 2020, 7:11pm UTC](https://discourse.vtk.org/t/volume-rendering-with-binary-mask/4339/1 "2020-10-02T19:11:08Z")

</div>

Hi , I have rendered a volume using vtkGPUVolumeRaycastMapper, now I need to mask the volume using binary mask  
Mapper.SetMaskTypeToBinary()  
Mapper.SetMaskInput(maskImageData) , but the mask is not working. Does anyone knows any solution, or is anything to be done in addition.  
For preparing the mask I have created a 3D numpy array of type unsigned char(ubyte) , filling inside values with 255 and others with 0. I then converted this numpy array to vtkImageData.  
Input volume data is a 3d numpy array of type unsigned 8 bit integer- Converted this to vtkImageData and set it as input to mapper as below:  
mapper.SetInput(inputimage).  
Volume is rendering, but mask is not working.Does anyone knows any solution, or is anything to be done in addition.

---

<div class="post-metadata">

### Author: ![yuhuimoon](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/y/c6cbf5/32.png) [@yuhuimoon](https://discourse.vtk.org/u/yuhuimoon)
#### Post date: [December 7, 2020, 10:55am UTC](https://discourse.vtk.org/t/volume-rendering-with-binary-mask/4339/2 "2020-12-07T10:55:13Z")

</div>

I have met the same problem. Have you solved it?

---

<div class="post-metadata">

### Author: ![assia.shabeeba](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/a8b319/32.png) [@assia.shabeeba](https://discourse.vtk.org/u/assia.shabeeba)
#### Post date: [April 9, 2021, 6:18pm UTC](https://discourse.vtk.org/t/volume-rendering-with-binary-mask/4339/3 "2021-04-09T18:18:54Z")

</div>

yes . I solved it. My problem was that I was using 2 render windows - one pop up window - vtkRenderWindowInteractor and other wxVTKRenderWindowInteractor. If we are using 2 renderes, then masking is not working( don’t know the reason though ).  
If your input data and mask is of same shape, then it should work.

---

<div class="post-metadata">

### Author: ![yuhuimoon](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/y/c6cbf5/32.png) [@yuhuimoon](https://discourse.vtk.org/u/yuhuimoon)
#### Post date: [April 11, 2021, 4:57pm UTC](https://discourse.vtk.org/t/volume-rendering-with-binary-mask/4339/4 "2021-04-11T16:57:21Z")

</div>

I will check my code following your suggestion.Thank you.
