class_docstr: An internal class to manage filters/algorithms for uniform grid datasets.
class_docstr_tok: ["An","internal","class","to","manage","filters\/algorithms","for","uniform","grid","datasets","."]
docstr: Apply a threshold to scalar values in a uniform grid.
  
  If a single value is given for threshold, scalar values above or equal
  to the threshold are ``'in'`` and scalar values below the threshold are ``'out'``.
  If two values are given for threshold (sequence) then values equal to
  or between the two values are ``'in'`` and values outside the range are ``'out'``.
  
  If ``None`` is given for ``in_value``, scalars that are ``'in'`` will not be replaced.
  If ``None`` is given for ``out_value``, scalars that are ``'out'`` will not be replaced.
  
  Warning: applying this filter to cell data will send the output to a
  new point array with the same name, overwriting any existing point data
  array with the same name.
  
  Parameters
  ----------
  threshold : float or sequence[float]
      Single value or (min, max) to be used for the data threshold.  If
      a sequence, then length must be 2. Threshold(s) for deciding which
      cells/points are ``'in'`` or ``'out'`` based on scalar data.
  
  in_value : float, default: 1.0
      Scalars that match the threshold criteria for ``'in'`` will be replaced with this.
  
  out_value : float, default: 0.0
      Scalars that match the threshold criteria for ``'out'`` will be replaced with this.
  
  scalars : str, optional
      Name of scalars to process. Defaults to currently active scalars.
  
  preference : str, default: "point"
      When scalars is specified, this is the preferred array
      type to search for in the dataset.  Must be either
      ``'point'`` or ``'cell'``.
  
  progress_bar : bool, default: False
      Display a progress bar to indicate progress.
  
  Returns
  -------
  pyvista.ImageData
      Dataset with the specified scalars thresholded.
  
  Examples
  --------
  Demonstrate image threshold on an example dataset. First, plot
  the example dataset with the active scalars.
  
  >>> from pyvista import examples
  >>> uni = examples.load_uniform()
  >>> uni.plot()
  
  Now, plot the image threshold with ``threshold=100``. Note how
  values above the threshold are 1 and below are 0.
  
  >>> ithresh = uni.image_threshold(100)
  >>> ithresh.plot()
docstr_tok: ["Apply","a","threshold","to","scalar","values","in","a","uniform","grid",".","If","a","single","value","is","given","for","threshold",",","scalar","values","above","or","equal","to","the","threshold","are","``","'in","'","``","and","scalar","values","below","the","threshold","are","``","'out","'","``",".","If","two","values","are","given","for","threshold","(","sequence",")","then","values","equal","to","or","between","the","two","values","are","``","'in","'","``","and","values","outside","the","range","are","``","'out","'","``",".","If","``","None","``","is","given","for","``","in_value","``",",","scalars","that","are","``","'in","'","``","will","not","be","replaced",".","If","``","None","``","is","given","for","``","out_value","``",",","scalars","that","are","``","'out","'","``","will","not","be","replaced",".","Warning",":","applying","this","filter","to","cell","data","will","send","the","output","to","a","new","point","array","with","the","same","name",",","overwriting","any","existing","point","data","array","with","the","same","name",".","Parameters","--","--","--","--","--","threshold",":","float","or","sequence","[","float","]","Single","value","or","(","min",",","max",")","to","be","used","for","the","data","threshold",".","If","a","sequence",",","then","length","must","be","2",".","Threshold","(","s",")","for","deciding","which","cells\/points","are","``","'in","'","``","or","``","'out","'","``","based","on","scalar","data",".","in_value",":","float",",","default",":","1.0","Scalars","that","match","the","threshold","criteria","for","``","'in","'","``","will","be","replaced","with","this",".","out_value",":","float",",","default",":","0.0","Scalars","that","match","the","threshold","criteria","for","``","'out","'","``","will","be","replaced","with","this",".","scalars",":","str",",","optional","Name","of","scalars","to","process",".","Defaults","to","currently","active","scalars",".","preference",":","str",",","default",":","``","point","''","When","scalars","is","specified",",","this","is","the","preferred","array","type","to","search","for","in","the","dataset",".","Must","be","either","``","'point","'","``","or","``","'cell","'","``",".","progress_bar",":","bool",",","default",":","False","Display","a","progress","bar","to","indicate","progress",".","Returns","--","--","--","-","pyvista.ImageData","Dataset","with","the","specified","scalars","thresholded",".","Examples","--","--","--","--","Demonstrate","image","threshold","on","an","example","dataset",".","First",",","plot","the","example","dataset","with","the","active","scalars",".",">",">",">","from","pyvista","import","examples",">",">",">","uni","=","examples.load_uniform","(",")",">",">",">","uni.plot","(",")","Now",",","plot","the","image","threshold","with","``","threshold=100","``",".","Note","how","values","above","the","threshold","are","1","and","below","are","0",".",">",">",">","ithresh","=","uni.image_threshold","(","100",")",">",">",">","ithresh.plot","(",")"]
code: def image_threshold(
      self,
      threshold,
      in_value=1.0,
      out_value=0.0,
      scalars=None,
      preference="point",
      progress_bar=False,
  ):
      """Apply a threshold to scalar values in a uniform grid.
  
      If a single value is given for threshold, scalar values above or equal
      to the threshold are ``'in'`` and scalar values below the threshold are ``'out'``.
      If two values are given for threshold (sequence) then values equal to
      or between the two values are ``'in'`` and values outside the range are ``'out'``.
  
      If ``None`` is given for ``in_value``, scalars that are ``'in'`` will not be replaced.
      If ``None`` is given for ``out_value``, scalars that are ``'out'`` will not be replaced.
  
      Warning: applying this filter to cell data will send the output to a
      new point array with the same name, overwriting any existing point data
      array with the same name.
  
      Parameters
      ----------
      threshold : float or sequence[float]
          Single value or (min, max) to be used for the data threshold.  If
          a sequence, then length must be 2. Threshold(s) for deciding which
          cells/points are ``'in'`` or ``'out'`` based on scalar data.
  
      in_value : float, default: 1.0
          Scalars that match the threshold criteria for ``'in'`` will be replaced with this.
  
      out_value : float, default: 0.0
          Scalars that match the threshold criteria for ``'out'`` will be replaced with this.
  
      scalars : str, optional
          Name of scalars to process. Defaults to currently active scalars.
  
      preference : str, default: "point"
          When scalars is specified, this is the preferred array
          type to search for in the dataset.  Must be either
          ``'point'`` or ``'cell'``.
  
      progress_bar : bool, default: False
          Display a progress bar to indicate progress.
  
      Returns
      -------
      pyvista.ImageData
          Dataset with the specified scalars thresholded.
  
      Examples
      --------
      Demonstrate image threshold on an example dataset. First, plot
      the example dataset with the active scalars.
  
      >>> from pyvista import examples
      >>> uni = examples.load_uniform()
      >>> uni.plot()
  
      Now, plot the image threshold with ``threshold=100``. Note how
      values above the threshold are 1 and below are 0.
  
      >>> ithresh = uni.image_threshold(100)
      >>> ithresh.plot()
  
      """
      alg = _vtk.vtkImageThreshold()
      alg.SetInputDataObject(self)
      if scalars is None:
          set_default_active_scalars(self)
          field, scalars = self.active_scalars_info
      else:
          field = self.get_array_association(
              scalars, preference=preference
          )
      alg.SetInputArrayToProcess(
          0, 0, 0, field.value, scalars
      )  # args: (idx, port, connection, field, name)
      # set the threshold(s) and mode
      if isinstance(threshold, (np.ndarray, collections.abc.Sequence)):
          if len(threshold) != 2:
              raise ValueError(
                  f"Threshold must be length one for a float value or two for min/max; not ({threshold})."
              )
          alg.ThresholdBetween(threshold[0], threshold[1])
      elif isinstance(threshold, collections.abc.Iterable):
          raise TypeError(
              "Threshold must either be a single scalar or a sequence."
          )
      else:
          alg.ThresholdByUpper(threshold)
      # set the replacement values / modes
      if in_value is not None:
          alg.SetReplaceIn(True)
          alg.SetInValue(in_value)
      else:
          alg.SetReplaceIn(False)
      if out_value is not None:
          alg.SetReplaceOut(True)
          alg.SetOutValue(out_value)
      else:
          alg.SetReplaceOut(False)
      # run the algorithm
      _update_alg(alg, progress_bar, "Performing Image Thresholding")
      return _get_output(alg)
  
imports: import collections.abc
  from typing import Literal, Optional, cast
  import numpy
  import pyvista
  from pyvista.core import _vtk_core
  from pyvista.core.errors import AmbiguousDataError, MissingDataError
  from pyvista.core.filters import _get_output, _update_alg
  from pyvista.core.filters.data_set import DataSetFilters
  from pyvista.core.utilities.arrays import FieldAssociation, set_default_active_scalars
  from pyvista.core.utilities.helpers import wrap
  from pyvista.core.utilities.misc import abstract_class
label_desc: Use image node_id 5 for calling the ImageDataFilters obj's underlying member method code with example usage: obj.image_threshold(threshold, in_value, out_value, scalars, preference, progress_bar) and returns: _get_output