class_docstr: Apply CLAHE to L/V/L channels in HLS/HSV/Lab colorspaces.
  
  This augmenter applies CLAHE (Contrast Limited Adaptive Histogram
  Equalization) to images, a form of histogram equalization that normalizes
  within local image patches.
  The augmenter transforms input images to a target colorspace (e.g.
  ``Lab``), extracts an intensity-related channel from the converted
  images (e.g. ``L`` for ``Lab``), applies CLAHE to the channel and then
  converts the resulting image back to the original colorspace.
  
  Grayscale images (images without channel axis or with only one channel
  axis) are automatically handled, `from_colorspace` does not have to be
  adjusted for them. For images with four channels (e.g. ``RGBA``), the
  fourth channel is ignored in the colorspace conversion (e.g. from an
  ``RGBA`` image, only the ``RGB`` part is converted, normalized, converted
  back and concatenated with the input ``A`` channel). Images with unusual
  channel numbers (2, 5 or more than 5) are normalized channel-by-channel
  (same behaviour as ``AllChannelsCLAHE``, though a warning will be raised).
  
  If you want to apply CLAHE to each channel of the original input image's
  colorspace (without any colorspace conversion), use
  ``imgaug.augmenters.contrast.AllChannelsCLAHE`` instead.
  
  **Supported dtypes**:
  
      * ``uint8``: yes; fully tested
      * ``uint16``: no (1)
      * ``uint32``: no (1)
      * ``uint64``: no (1)
      * ``int8``: no (1)
      * ``int16``: no (1)
      * ``int32``: no (1)
      * ``int64``: no (1)
      * ``float16``: no (1)
      * ``float32``: no (1)
      * ``float64``: no (1)
      * ``float128``: no (1)
      * ``bool``: no (1)
  
      - (1) This augmenter uses
            :class:`~imgaug.augmenters.color.ChangeColorspace`, which is
            currently limited to ``uint8``.
  
  Parameters
  ----------
  clip_limit : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
      Clipping limit. Higher values result in stronger contrast. OpenCV
      uses a default of ``40``, though values around ``5`` seem to already
      produce decent contrast.
  
          * If a number, then that value will be used for all images.
          * If a tuple ``(a, b)``, then a value from the range ``[a, b]``
            will be used per image.
          * If a list, then a random value will be sampled from that list
            per image.
          * If a ``StochasticParameter``, then a value will be sampled per
            image from that parameter.
  
  tile_grid_size_px : int or tuple of int or list of int or imgaug.parameters.StochasticParameter or tuple of tuple of int or tuple of list of int or tuple of imgaug.parameters.StochasticParameter, optional
      Kernel size, i.e. size of each local neighbourhood in pixels.
  
          * If an ``int``, then that value will be used for all images for
            both kernel height and width.
          * If a tuple ``(a, b)``, then a value from the discrete interval
            ``[a..b]`` will be uniformly sampled per image.
          * If a list, then a random value will be sampled from that list
            per image and used for both kernel height and width.
          * If a ``StochasticParameter``, then a value will be sampled per
            image from that parameter per image and used for both kernel
            height and width.
          * If a tuple of tuple of ``int`` given as ``((a, b), (c, d))``,
            then two values will be sampled independently from the discrete
            ranges ``[a..b]`` and ``[c..d]`` per image and used as the
            kernel height and width.
          * If a tuple of lists of ``int``, then two values will be sampled
            independently per image, one from the first list and one from
            the second, and used as the kernel height and width.
          * If a tuple of ``StochasticParameter``, then two values will be
            sampled indepdently per image, one from the first parameter and
            one from the second, and used as the kernel height and width.
  
  tile_grid_size_px_min : int, optional
      Minimum kernel size in px, per axis. If the sampling results in a
      value lower than this minimum, it will be clipped to this value.
  
  from_colorspace : {"RGB", "BGR", "HSV", "HLS", "Lab"}, optional
      Colorspace of the input images.
      If any input image has only one or zero channels, this setting will
      be ignored and it will be assumed that the input is grayscale.
      If a fourth channel is present in an input image, it will be removed
      before the colorspace conversion and later re-added.
      See also :func:`~imgaug.augmenters.color.change_colorspace_` for
      details.
  
  to_colorspace : {"Lab", "HLS", "HSV"}, optional
      Colorspace in which to perform CLAHE. For ``Lab``, CLAHE will only be
      applied to the first channel (``L``), for ``HLS`` to the
      second (``L``) and for ``HSV`` to the third (``V``). To apply CLAHE
      to all channels of an input image (without colorspace conversion),
      see ``imgaug.augmenters.contrast.AllChannelsCLAHE``.
  
  seed : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
      See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.
  
  name : None or str, optional
      See :func:`~imgaug.augmenters.meta.Augmenter.__init__`.
  
  random_state : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional
      Old name for parameter `seed`.
      Its usage will not yet cause a deprecation warning,
      but it is still recommended to use `seed` now.
      Outdated since 0.4.0.
  
  deterministic : bool, optional
      Deprecated since 0.4.0.
      See method ``to_deterministic()`` for an alternative and for
      details about what the "deterministic mode" actually does.
  
  Examples
  --------
  >>> import imgaug.augmenters as iaa
  >>> aug = iaa.CLAHE()
  
  Create a standard CLAHE augmenter.
  
  >>> aug = iaa.CLAHE(clip_limit=(1, 10))
  
  Create a CLAHE augmenter with a clip limit uniformly sampled from
  ``[1..10]``, where ``1`` is rather low contrast and ``10`` is rather
  high contrast.
  
  >>> aug = iaa.CLAHE(tile_grid_size_px=(3, 21))
  
  Create a CLAHE augmenter with kernel sizes of ``SxS``, where ``S`` is
  uniformly sampled from ``[3..21]``. Sampling happens once per image.
  
  >>> aug = iaa.CLAHE(
  >>>     tile_grid_size_px=iap.Discretize(iap.Normal(loc=7, scale=2)),
  >>>     tile_grid_size_px_min=3)
  
  Create a CLAHE augmenter with kernel sizes of ``SxS``, where ``S`` is
  sampled from ``N(7, 2)``, but does not go below ``3``.
  
  >>> aug = iaa.CLAHE(tile_grid_size_px=((3, 21), [3, 5, 7]))
  
  Create a CLAHE augmenter with kernel sizes of ``HxW``, where ``H`` is
  uniformly sampled from ``[3..21]`` and ``W`` is randomly picked from the
  list ``[3, 5, 7]``.
  
  >>> aug = iaa.CLAHE(
  >>>     from_colorspace=iaa.CSPACE_BGR,
  >>>     to_colorspace=iaa.CSPACE_HSV)
  
  Create a CLAHE augmenter that converts images from BGR colorspace to
  HSV colorspace and then applies the local histogram equalization to the
  ``V`` channel of the images (before converting back to ``BGR``).
  Alternatively, ``Lab`` (default) or ``HLS`` can be used as the target
  colorspace. Grayscale images (no channels / one channel) are never
  converted and are instead directly normalized (i.e. `from_colorspace`
  does not have to be changed for them).
class_docstr_tok: ["Apply","CLAHE","to","L\/V\/L","channels","in","HLS\/HSV\/Lab","colorspaces",".","This","augmenter","applies","CLAHE","(","Contrast","Limited","Adaptive","Histogram","Equalization",")","to","images",",","a","form","of","histogram","equalization","that","normalizes","within","local","image","patches",".","The","augmenter","transforms","input","images","to","a","target","colorspace","(","e.g",".","``","Lab","``",")",",","extracts","an","intensity-related","channel","from","the","converted","images","(","e.g",".","``","L","``","for","``","Lab","``",")",",","applies","CLAHE","to","the","channel","and","then","converts","the","resulting","image","back","to","the","original","colorspace",".","Grayscale","images","(","images","without","channel","axis","or","with","only","one","channel","axis",")","are","automatically","handled",",","`","from_colorspace","`","does","not","have","to","be","adjusted","for","them",".","For","images","with","four","channels","(","e.g",".","``","RGBA","``",")",",","the","fourth","channel","is","ignored","in","the","colorspace","conversion","(","e.g",".","from","an","``","RGBA","``","image",",","only","the","``","RGB","``","part","is","converted",",","normalized",",","converted","back","and","concatenated","with","the","input","``","A","``","channel",")",".","Images","with","unusual","channel","numbers","(","2",",","5","or","more","than","5",")","are","normalized","channel-by-channel","(","same","behaviour","as","``","AllChannelsCLAHE","``",",","though","a","warning","will","be","raised",")",".","If","you","want","to","apply","CLAHE","to","each","channel","of","the","original","input","image's","colorspace","(","without","any","colorspace","conversion",")",",","use","``","imgaug.augmenters.contrast.AllChannelsCLAHE","``","instead",".","*","*","Supported","dtypes","*","*",":","*","``","uint8","``",":","yes",";","fully","tested","*","``","uint16","``",":","no","(","1",")","*","``","uint32","``",":","no","(","1",")","*","``","uint64","``",":","no","(","1",")","*","``","int8","``",":","no","(","1",")","*","``","int16","``",":","no","(","1",")","*","``","int32","``",":","no","(","1",")","*","``","int64","``",":","no","(","1",")","*","``","float16","``",":","no","(","1",")","*","``","float32","``",":","no","(","1",")","*","``","float64","``",":","no","(","1",")","*","``","float128","``",":","no","(","1",")","*","``","bool","``",":","no","(","1",")","-","(","1",")","This","augmenter","uses",":","class",":","`","~imgaug.augmenters.color.ChangeColorspace","`",",","which","is","currently","limited","to","``","uint8","``",".","Parameters","--","--","--","--","--","clip_limit",":","number","or","tuple","of","number","or","list","of","number","or","imgaug.parameters.StochasticParameter",",","optional","Clipping","limit",".","Higher","values","result","in","stronger","contrast",".","OpenCV","uses","a","default","of","``","40","``",",","though","values","around","``","5","``","seem","to","already","produce","decent","contrast",".","*","If","a","number",",","then","that","value","will","be","used","for","all","images",".","*","If","a","tuple","``","(","a",",","b",")","``",",","then","a","value","from","the","range","``","[","a",",","b","]","``","will","be","used","per","image",".","*","If","a","list",",","then","a","random","value","will","be","sampled","from","that","list","per","image",".","*","If","a","``","StochasticParameter","``",",","then","a","value","will","be","sampled","per","image","from","that","parameter",".","tile_grid_size_px",":","int","or","tuple","of","int","or","list","of","int","or","imgaug.parameters.StochasticParameter","or","tuple","of","tuple","of","int","or","tuple","of","list","of","int","or","tuple","of","imgaug.parameters.StochasticParameter",",","optional","Kernel","size",",","i.e",".","size","of","each","local","neighbourhood","in","pixels",".","*","If","an","``","int","``",",","then","that","value","will","be","used","for","all","images","for","both","kernel","height","and","width",".","*","If","a","tuple","``","(","a",",","b",")","``",",","then","a","value","from","the","discrete","interval","``","[","a","..","b","]","``","will","be","uniformly","sampled","per","image",".","*","If","a","list",",","then","a","random","value","will","be","sampled","from","that","list","per","image","and","used","for","both","kernel","height","and","width",".","*","If","a","``","StochasticParameter","``",",","then","a","value","will","be","sampled","per","image","from","that","parameter","per","image","and","used","for","both","kernel","height","and","width",".","*","If","a","tuple","of","tuple","of","``","int","``","given","as","``","(","(","a",",","b",")",",","(","c",",","d",")",")","``",",","then","two","values","will","be","sampled","independently","from","the","discrete","ranges","``","[","a","..","b","]","``","and","``","[","c","..","d","]","``","per","image","and","used","as","the","kernel","height","and","width",".","*","If","a","tuple","of","lists","of","``","int","``",",","then","two","values","will","be","sampled","independently","per","image",",","one","from","the","first","list","and","one","from","the","second",",","and","used","as","the","kernel","height","and","width",".","*","If","a","tuple","of","``","StochasticParameter","``",",","then","two","values","will","be","sampled","indepdently","per","image",",","one","from","the","first","parameter","and","one","from","the","second",",","and","used","as","the","kernel","height","and","width",".","tile_grid_size_px_min",":","int",",","optional","Minimum","kernel","size","in","px",",","per","axis",".","If","the","sampling","results","in","a","value","lower","than","this","minimum",",","it","will","be","clipped","to","this","value",".","from_colorspace",":","{","``","RGB","''",",","``","BGR","''",",","``","HSV","''",",","``","HLS","''",",","``","Lab","''","}",",","optional","Colorspace","of","the","input","images",".","If","any","input","image","has","only","one","or","zero","channels",",","this","setting","will","be","ignored","and","it","will","be","assumed","that","the","input","is","grayscale",".","If","a","fourth","channel","is","present","in","an","input","image",",","it","will","be","removed","before","the","colorspace","conversion","and","later","re-added",".","See","also",":","func",":","`","~imgaug.augmenters.color.change_colorspace_","`","for","details",".","to_colorspace",":","{","``","Lab","''",",","``","HLS","''",",","``","HSV","''","}",",","optional","Colorspace","in","which","to","perform","CLAHE",".","For","``","Lab","``",",","CLAHE","will","only","be","applied","to","the","first","channel","(","``","L","``",")",",","for","``","HLS","``","to","the","second","(","``","L","``",")","and","for","``","HSV","``","to","the","third","(","``","V","``",")",".","To","apply","CLAHE","to","all","channels","of","an","input","image","(","without","colorspace","conversion",")",",","see","``","imgaug.augmenters.contrast.AllChannelsCLAHE","``",".","seed",":","None","or","int","or","imgaug.random.RNG","or","numpy.random.Generator","or","numpy.random.BitGenerator","or","numpy.random.SeedSequence","or","numpy.random.RandomState",",","optional","See",":","func",":","`","~imgaug.augmenters.meta.Augmenter.__init__","`",".","name",":","None","or","str",",","optional","See",":","func",":","`","~imgaug.augmenters.meta.Augmenter.__init__","`",".","random_state",":","None","or","int","or","imgaug.random.RNG","or","numpy.random.Generator","or","numpy.random.BitGenerator","or","numpy.random.SeedSequence","or","numpy.random.RandomState",",","optional","Old","name","for","parameter","`","seed","`",".","Its","usage","will","not","yet","cause","a","deprecation","warning",",","but","it","is","still","recommended","to","use","`","seed","`","now",".","Outdated","since","0.4.0.","deterministic",":","bool",",","optional","Deprecated","since","0.4.0",".","See","method","``","to_deterministic","(",")","``","for","an","alternative","and","for","details","about","what","the","``","deterministic","mode","''","actually","does",".","Examples","--","--","--","--",">",">",">","import","imgaug.augmenters","as","iaa",">",">",">","aug","=","iaa.CLAHE","(",")","Create","a","standard","CLAHE","augmenter",".",">",">",">","aug","=","iaa.CLAHE","(","clip_limit=","(","1",",","10",")",")","Create","a","CLAHE","augmenter","with","a","clip","limit","uniformly","sampled","from","``","[","1","..","10","]","``",",","where","``","1","``","is","rather","low","contrast","and","``","10","``","is","rather","high","contrast",".",">",">",">","aug","=","iaa.CLAHE","(","tile_grid_size_px=","(","3",",","21",")",")","Create","a","CLAHE","augmenter","with","kernel","sizes","of","``","SxS","``",",","where","``","S","``","is","uniformly","sampled","from","``","[","3","..","21","]","``",".","Sampling","happens","once","per","image",".",">",">",">","aug","=","iaa.CLAHE","(",">",">",">","tile_grid_size_px=iap.Discretize","(","iap.Normal","(","loc=7",",","scale=2",")",")",",",">",">",">","tile_grid_size_px_min=3",")","Create","a","CLAHE","augmenter","with","kernel","sizes","of","``","SxS","``",",","where","``","S","``","is","sampled","from","``","N","(","7",",","2",")","``",",","but","does","not","go","below","``","3","``",".",">",">",">","aug","=","iaa.CLAHE","(","tile_grid_size_px=","(","(","3",",","21",")",",","[","3",",","5",",","7","]",")",")","Create","a","CLAHE","augmenter","with","kernel","sizes","of","``","HxW","``",",","where","``","H","``","is","uniformly","sampled","from","``","[","3","..","21","]","``","and","``","W","``","is","randomly","picked","from","the","list","``","[","3",",","5",",","7","]","``",".",">",">",">","aug","=","iaa.CLAHE","(",">",">",">","from_colorspace=iaa.CSPACE_BGR",",",">",">",">","to_colorspace=iaa.CSPACE_HSV",")","Create","a","CLAHE","augmenter","that","converts","images","from","BGR","colorspace","to","HSV","colorspace","and","then","applies","the","local","histogram","equalization","to","the","``","V","``","channel","of","the","images","(","before","converting","back","to","``","BGR","``",")",".","Alternatively",",","``","Lab","``","(","default",")","or","``","HLS","``","can","be","used","as","the","target","colorspace",".","Grayscale","images","(","no","channels","\/","one","channel",")","are","never","converted","and","are","instead","directly","normalized","(","i.e",".","`","from_colorspace","`","does","not","have","to","be","changed","for","them",")","."]
code: def __init__(
      self,
      clip_limit=(0.1, 8),
      tile_grid_size_px=(3, 12),
      tile_grid_size_px_min=3,
      from_colorspace=color_lib.CSPACE_RGB,
      to_colorspace=color_lib.CSPACE_Lab,
      seed=None,
      name=None,
      random_state="deprecated",
      deterministic="deprecated",
  ):
      super(CLAHE, self).__init__(
          seed=seed,
          name=name,
          random_state=random_state,
          deterministic=deterministic,
      )
  
      self.all_channel_clahe = AllChannelsCLAHE(
          clip_limit=clip_limit,
          tile_grid_size_px=tile_grid_size_px,
          tile_grid_size_px_min=tile_grid_size_px_min,
          name="%s_AllChannelsCLAHE" % (name,),
      )
  
      self.intensity_channel_based_applier = (
          _IntensityChannelBasedApplier(from_colorspace, to_colorspace)
      )
  
imports: from __future__ import print_function, division, absolute_import
  import numpy
  import six.moves
  import skimage.exposure
  import cv2
  import imgaug
  from imgaug.imgaug import _normalize_cv2_input_arr_
  from .None import meta
  from .None import color
  from ..None import parameters
  from ..None import dtypes
  from ..augmentables.batches import _BatchInAugmentation
label_desc: Use image node_id 1 to create a new CLAHE object from inherited base classes: meta with example: obj = CLAHE(clip_limit, tile_grid_size_px, tile_grid_size_px_min, from_colorspace, to_colorspace, seed, name, random_state, deterministic)