# Changing opacity of volume rendering based on window width/window level in VTK

**URL:** https://discourse.vtk.org/t/changing-opacity-of-volume-rendering-based-on-window-width-window-level-in-vtk/3363
**Category:** Support
**Created:** [May 21, 2020, 4:40pm UTC](https://discourse.vtk.org/t/changing-opacity-of-volume-rendering-based-on-window-width-window-level-in-vtk/3363 "2020-05-21T16:40:15Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![watson](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/w/ce73a5/32.png) [@watson](https://discourse.vtk.org/u/watson)
#### Post date: [May 21, 2020, 4:40pm UTC](https://discourse.vtk.org/t/changing-opacity-of-volume-rendering-based-on-window-width-window-level-in-vtk/3363/1 "2020-05-21T16:40:16Z")

</div>

I need to change the **opacity transfer function** of **volume rendered** image based in **window width and window level**.I need to know how to set the opacity transfer function with respect to WW/WL

ie) `OpacityTransferFunction->AddPoint(??,??);`

**What I tried:**

I went through this :[link](http://vtk.1045678.n5.nabble.com/VolumeRendering-Window-Width-and-Window-Level-td5734045.html) but it is not answered precisely.Can anyone help?

**EDIT**  
(I want to do exactly Like the **Adjust Window** option in 3D VR of **Radiant Dicom Viewer** )

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [May 21, 2020, 5:33pm UTC](https://discourse.vtk.org/t/changing-opacity-of-volume-rendering-based-on-window-width-window-level-in-vtk/3363/2 "2020-05-21T17:33:13Z")

</div>

This is implemented in 3D Slicer here:

> <https://github.com/Slicer/Slicer/blob/47b845f91ef332e6008af4a166b294912de6d052/Modules/Loadable/VolumeRendering/Logic/vtkSlicerVolumeRenderingLogic.cxx#L458-L540>

You can use Slicer source code any way you want (e.g., copy-paste any code without acknowledgment), and we are happy if we could help you with that. Since Slicer already contains all basic medical image visualization and computing features that you can think of, you might go further, and save a lot of time and effort by not copying it feature-by-feature but simply implement your custom algorithms and GUI as a 3D Slicer extension or 3D Slicer custom application. See some more information [here](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Slicelets) and you can also ask further questions on the [Slicer forum](https://discourse.slicer.org).
