Override DataArray values beyond set values

I’m looking to set a new range on my data, assuming I have a new_min and new_max, so that values > new_max are set to new_max and values < new_min are set to new_min

Easy enough to do with the vtk_to_numpy/numpy_to_vtk array conversions and performing the operations in numpy, but is there a filter or more straight-forward method to do so in vtk itself?

Hi, Theodore,

You can use the vtkMath class to clamp values in an array of doubles. https://vtk.org/doc/nightly/html/classvtkMath.html . Take a look at its ClampValues() overrides and use one that suits your need.



Thank you @Paulo_Carvalho!

Interesting that the methods don’t accept a vtkDataArray so I still need to convert back and forth using numpy_support but that’s fine. Thanks again.