# vtkThresholdScalar with empty intervals

**URL:** https://discourse.vtk.org/t/vtkthresholdscalar-with-empty-intervals/16318
**Category:** Development
**Created:** [March 6, 2026, 8:06am UTC](https://discourse.vtk.org/t/vtkthresholdscalar-with-empty-intervals/16318 "2026-03-06T08:06:07Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![nbeck](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/n/97f17d/32.png) [@nbeck](https://discourse.vtk.org/u/nbeck)
#### Post date: [March 6, 2026, 8:06am UTC](https://discourse.vtk.org/t/vtkthresholdscalar-with-empty-intervals/16318/1 "2026-03-06T08:06:07Z")

</div>

Hi,

I’ve played around with the new vtkThresholdScalars class and it works nicely. However, I was surprised to see that it can’t be used when no interval is added. Of course in a static setting it doesn’t make sense to use the filter with no intervals. But in an interactive setting it would be easier to use if it would would simply return an image filled with the background label in that case.

```auto
if (this->Intervals->GetNumberOfIntervals() < 1)
{
    vtkErrorMacro(<< “No thresholding intervals defined!”);
    return 1;
}

```

Also I think it would be nice if one could change the data type that is used for the labels from integer to e.g. short. Although I don’t know how difficult it would be to implement.

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [March 6, 2026, 6:31pm UTC](https://discourse.vtk.org/t/vtkthresholdscalar-with-empty-intervals/16318/2 "2026-03-06T18:31:34Z")

</div>

Hello,

My two cents: if the user does not provide an interval, just add a default one varying between `std::numeric_limits<[float|double]>::min()` and `std::numeric_limits<[float|double]>::max()`.

best,

PC

---

<div class="post-metadata">

### Author: ![nbeck](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/n/97f17d/32.png) [@nbeck](https://discourse.vtk.org/u/nbeck)
#### Post date: [March 9, 2026, 8:34am UTC](https://discourse.vtk.org/t/vtkthresholdscalar-with-empty-intervals/16318/3 "2026-03-09T08:34:38Z")

</div>

You’re right, it’s easy to work around by providing a dummy interval. It’s just that it means additional logic to work around a restriction that I don’t think is necessary in the first place. But maybe I am missing something here.

I ended copying the whole class anyway to switch from integer labels to short.
