code: def threshold(self, vmin=None, vmax=None, replaceWith=None):
          
          th = vtk.vtkImageThreshold()
          th.SetInputData(self.image)
          
          if vmin is not None and vmax is not None:
              th.ThresholdBetween(vmin, vmax)
          elif vmin is not None:
              th.ThresholdByUpper(vmin)
          elif vmax is not None:
              th.ThresholdByLower(vmax)       
  
          if replaceWith:
              th.ReplaceOutOn()
              th.SetOutValue(replaceWith)
          th.Update()
          
          self.image = th.GetOutput()
          self.mapper.SetInputData(self.image)
          self.mapper.Modified()
          return self
docs: Binary or continuous volume thresholding.