# Thresholding VolumeViewer

**URL:** https://discourse.vtk.org/t/thresholding-volumeviewer/6896
**Category:** Web
**Created:** [October 15, 2021, 10:28am UTC](https://discourse.vtk.org/t/thresholding-volumeviewer/6896 "2021-10-15T10:28:26Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![emil-peter](https://discourse.vtk.org/user_avatar/discourse.vtk.org/emil-peter/32/4075_2.png) [@emil-peter](https://discourse.vtk.org/u/emil-peter)
#### Post date: [October 15, 2021, 10:28am UTC](https://discourse.vtk.org/t/thresholding-volumeviewer/6896/1 "2021-10-15T10:28:26Z")

</div>

Hi all,

I’ve seen the examples of vtk js where the volume renderer is used in combination with `vtkPiecewiseFunction` and the `vtkPiecewiseGaussianWidget`  
I was wondering if there is a way to use this piecewise function to threshold the volume show between two grayscale values?  
As to see only the voxels that would lie inbetween these two values.

Kind regards,  
Emil

---

<div class="post-metadata">

### Author: ![Forrest](https://discourse.vtk.org/user_avatar/discourse.vtk.org/forrest/32/300_2.png) [@Forrest](https://discourse.vtk.org/u/Forrest)
#### Post date: [October 20, 2021, 6:03pm UTC](https://discourse.vtk.org/t/thresholding-volumeviewer/6896/2 "2021-10-20T18:03:04Z")

</div>

The `vtkPiecewiseGaussianWidget` is more for interactive colormap and opacity exploration. If you want to only show voxel values that lie in a range, you will need to construct a `vtkPiecewiseFunction` that is 1 in the range and 0 outside the range, then set that function as the volume mapper’s scalar opacity function via `setScalarOpacity`.
