class_docstr: Apply a canny edge detector to input images.
  
  **Supported dtypes**:
  
      * ``uint8``: yes; fully tested
      * ``uint16``: no; not tested
      * ``uint32``: no; not tested
      * ``uint64``: no; not tested
      * ``int8``: no; not tested
      * ``int16``: no; not tested
      * ``int32``: no; not tested
      * ``int64``: no; not tested
      * ``float16``: no; not tested
      * ``float32``: no; not tested
      * ``float64``: no; not tested
      * ``float128``: no; not tested
      * ``bool``: no; not tested
  
  Parameters
  ----------
  alpha : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
      Blending factor to use in alpha blending.
      A value close to 1.0 means that only the edge image is visible.
      A value close to 0.0 means that only the original image is visible.
      A value close to 0.5 means that the images are merged according to
      `0.5*image + 0.5*edge_image`.
      If a sample from this parameter is 0, no action will be performed for
      the corresponding image.
  
          * If an int or float, exactly that value will be used.
          * If a tuple ``(a, b)``, a random value from the range
            ``a <= x <= b`` will be sampled per image.
          * If a list, then a random value will be sampled from that list
            per image.
          * If a StochasticParameter, a value will be sampled from the
            parameter per image.
  
  hysteresis_thresholds : number or tuple of number or list of number or imgaug.parameters.StochasticParameter or tuple of tuple of number or tuple of list of number or tuple of imgaug.parameters.StochasticParameter, optional
      Min and max values to use in hysteresis thresholding.
      (This parameter seems to have not very much effect on the results.)
      Either a single parameter or a tuple of two parameters.
      If a single parameter is provided, the sampling happens once for all
      images with `(N,2)` samples being requested from the parameter,
      where each first value denotes the hysteresis minimum and each second
      the maximum.
      If a tuple of two parameters is provided, one sampling of `(N,)` values
      is independently performed per parameter (first parameter: hysteresis
      minimum, second: hysteresis maximum).
  
          * If this is a single number, both min and max value will always be
            exactly that value.
          * If this is a tuple of numbers ``(a, b)``, two random values from
            the range ``a <= x <= b`` will be sampled per image.
          * If this is a list, two random values will be sampled from that
            list per image.
          * If this is a StochasticParameter, two random values will be
            sampled from that parameter per image.
          * If this is a tuple ``(min, max)`` with ``min`` and ``max``
            both *not* being numbers, they will be treated according to the
            rules above (i.e. may be a number, tuple, list or
            StochasticParameter). A single value will be sampled per image
            and parameter.
  
  sobel_kernel_size : int or tuple of int or list of int or imgaug.parameters.StochasticParameter, optional
      Kernel size of the sobel operator initially applied to each image.
      This corresponds to ``apertureSize`` in ``cv2.Canny()``.
      If a sample from this parameter is ``<=1``, no action will be performed
      for the corresponding image.
      The maximum for this parameter is ``7`` (inclusive). Higher values are
      not accepted by OpenCV.
      If an even value ``v`` is sampled, it is automatically changed to
      ``v-1``.
  
          * If this is a single integer, the kernel size always matches that
            value.
          * If this is a tuple of integers ``(a, b)``, a random discrete
            value will be sampled from the range ``a <= x <= b`` per image.
          * If this is a list, a random value will be sampled from that
            list per image.
          * If this is a StochasticParameter, a random value will be sampled
            from that parameter per image.
  
  colorizer : None or imgaug.augmenters.edges.IBinaryImageColorizer, optional
      A strategy to convert binary edge images to color images.
      If this is ``None``, an instance of ``RandomColorBinaryImageColorizer``
      is created, which means that each edge image is converted into an
      ``uint8`` image, where edge and non-edge pixels each have a different
      color that was uniformly randomly sampled from the space of all
      ``uint8`` colors.
  
  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.Canny()
  
  Create an augmenter that generates random blends between images and
  their canny edge representations.
  
  >>> aug = iaa.Canny(alpha=(0.0, 0.5))
  
  Create a canny edge augmenter that generates edge images with a blending
  factor of max ``50%``, i.e. the original (non-edge) image is always at
  least partially visible.
  
  >>> aug = iaa.Canny(
  >>>     alpha=(0.0, 0.5),
  >>>     colorizer=iaa.RandomColorsBinaryImageColorizer(
  >>>         color_true=255,
  >>>         color_false=0
  >>>     )
  >>> )
  
  Same as in the previous example, but the edge image always uses the
  color white for edges and black for the background.
  
  >>> aug = iaa.Canny(alpha=(0.5, 1.0), sobel_kernel_size=[3, 7])
  
  Create a canny edge augmenter that initially preprocesses images using
  a sobel filter with kernel size of either ``3x3`` or ``13x13`` and
  alpha-blends with result using a strength of ``50%`` (both images
  equally visible) to ``100%`` (only edge image visible).
  
  >>> aug = iaa.Alpha(
  >>>     (0.0, 1.0),
  >>>     iaa.Canny(alpha=1),
  >>>     iaa.MedianBlur(13)
  >>> )
  
  Create an augmenter that blends a canny edge image with a median-blurred
  version of the input image. The median blur uses a fixed kernel size
  of ``13x13`` pixels.
class_docstr_tok: ["Apply","a","canny","edge","detector","to","input","images",".","*","*","Supported","dtypes","*","*",":","*","``","uint8","``",":","yes",";","fully","tested","*","``","uint16","``",":","no",";","not","tested","*","``","uint32","``",":","no",";","not","tested","*","``","uint64","``",":","no",";","not","tested","*","``","int8","``",":","no",";","not","tested","*","``","int16","``",":","no",";","not","tested","*","``","int32","``",":","no",";","not","tested","*","``","int64","``",":","no",";","not","tested","*","``","float16","``",":","no",";","not","tested","*","``","float32","``",":","no",";","not","tested","*","``","float64","``",":","no",";","not","tested","*","``","float128","``",":","no",";","not","tested","*","``","bool","``",":","no",";","not","tested","Parameters","--","--","--","--","--","alpha",":","number","or","tuple","of","number","or","list","of","number","or","imgaug.parameters.StochasticParameter",",","optional","Blending","factor","to","use","in","alpha","blending",".","A","value","close","to","1.0","means","that","only","the","edge","image","is","visible",".","A","value","close","to","0.0","means","that","only","the","original","image","is","visible",".","A","value","close","to","0.5","means","that","the","images","are","merged","according","to","`","0.5","*","image","+","0.5","*","edge_image","`",".","If","a","sample","from","this","parameter","is","0",",","no","action","will","be","performed","for","the","corresponding","image",".","*","If","an","int","or","float",",","exactly","that","value","will","be","used",".","*","If","a","tuple","``","(","a",",","b",")","``",",","a","random","value","from","the","range","``","a","<","=","x","<","=","b","``","will","be","sampled","per","image",".","*","If","a","list",",","then","a","random","value","will","be","sampled","from","that","list","per","image",".","*","If","a","StochasticParameter",",","a","value","will","be","sampled","from","the","parameter","per","image",".","hysteresis_thresholds",":","number","or","tuple","of","number","or","list","of","number","or","imgaug.parameters.StochasticParameter","or","tuple","of","tuple","of","number","or","tuple","of","list","of","number","or","tuple","of","imgaug.parameters.StochasticParameter",",","optional","Min","and","max","values","to","use","in","hysteresis","thresholding",".","(","This","parameter","seems","to","have","not","very","much","effect","on","the","results",".",")","Either","a","single","parameter","or","a","tuple","of","two","parameters",".","If","a","single","parameter","is","provided",",","the","sampling","happens","once","for","all","images","with","`","(","N,2",")","`","samples","being","requested","from","the","parameter",",","where","each","first","value","denotes","the","hysteresis","minimum","and","each","second","the","maximum",".","If","a","tuple","of","two","parameters","is","provided",",","one","sampling","of","`","(","N",",",")","`","values","is","independently","performed","per","parameter","(","first","parameter",":","hysteresis","minimum",",","second",":","hysteresis","maximum",")",".","*","If","this","is","a","single","number",",","both","min","and","max","value","will","always","be","exactly","that","value",".","*","If","this","is","a","tuple","of","numbers","``","(","a",",","b",")","``",",","two","random","values","from","the","range","``","a","<","=","x","<","=","b","``","will","be","sampled","per","image",".","*","If","this","is","a","list",",","two","random","values","will","be","sampled","from","that","list","per","image",".","*","If","this","is","a","StochasticParameter",",","two","random","values","will","be","sampled","from","that","parameter","per","image",".","*","If","this","is","a","tuple","``","(","min",",","max",")","``","with","``","min","``","and","``","max","``","both","*","not","*","being","numbers",",","they","will","be","treated","according","to","the","rules","above","(","i.e",".","may","be","a","number",",","tuple",",","list","or","StochasticParameter",")",".","A","single","value","will","be","sampled","per","image","and","parameter",".","sobel_kernel_size",":","int","or","tuple","of","int","or","list","of","int","or","imgaug.parameters.StochasticParameter",",","optional","Kernel","size","of","the","sobel","operator","initially","applied","to","each","image",".","This","corresponds","to","``","apertureSize","``","in","``","cv2.Canny","(",")","``",".","If","a","sample","from","this","parameter","is","``","<","=1","``",",","no","action","will","be","performed","for","the","corresponding","image",".","The","maximum","for","this","parameter","is","``","7","``","(","inclusive",")",".","Higher","values","are","not","accepted","by","OpenCV",".","If","an","even","value","``","v","``","is","sampled",",","it","is","automatically","changed","to","``","v-1","``",".","*","If","this","is","a","single","integer",",","the","kernel","size","always","matches","that","value",".","*","If","this","is","a","tuple","of","integers","``","(","a",",","b",")","``",",","a","random","discrete","value","will","be","sampled","from","the","range","``","a","<","=","x","<","=","b","``","per","image",".","*","If","this","is","a","list",",","a","random","value","will","be","sampled","from","that","list","per","image",".","*","If","this","is","a","StochasticParameter",",","a","random","value","will","be","sampled","from","that","parameter","per","image",".","colorizer",":","None","or","imgaug.augmenters.edges.IBinaryImageColorizer",",","optional","A","strategy","to","convert","binary","edge","images","to","color","images",".","If","this","is","``","None","``",",","an","instance","of","``","RandomColorBinaryImageColorizer","``","is","created",",","which","means","that","each","edge","image","is","converted","into","an","``","uint8","``","image",",","where","edge","and","non-edge","pixels","each","have","a","different","color","that","was","uniformly","randomly","sampled","from","the","space","of","all","``","uint8","``","colors",".","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.Canny","(",")","Create","an","augmenter","that","generates","random","blends","between","images","and","their","canny","edge","representations",".",">",">",">","aug","=","iaa.Canny","(","alpha=","(","0.0",",","0.5",")",")","Create","a","canny","edge","augmenter","that","generates","edge","images","with","a","blending","factor","of","max","``","50","%","``",",","i.e",".","the","original","(","non-edge",")","image","is","always","at","least","partially","visible",".",">",">",">","aug","=","iaa.Canny","(",">",">",">","alpha=","(","0.0",",","0.5",")",",",">",">",">","colorizer=iaa.RandomColorsBinaryImageColorizer","(",">",">",">","color_true=255",",",">",">",">","color_false=0",">",">",">",")",">",">",">",")","Same","as","in","the","previous","example",",","but","the","edge","image","always","uses","the","color","white","for","edges","and","black","for","the","background",".",">",">",">","aug","=","iaa.Canny","(","alpha=","(","0.5",",","1.0",")",",","sobel_kernel_size=","[","3",",","7","]",")","Create","a","canny","edge","augmenter","that","initially","preprocesses","images","using","a","sobel","filter","with","kernel","size","of","either","``","3x3","``","or","``","13x13","``","and","alpha-blends","with","result","using","a","strength","of","``","50","%","``","(","both","images","equally","visible",")","to","``","100","%","``","(","only","edge","image","visible",")",".",">",">",">","aug","=","iaa.Alpha","(",">",">",">","(","0.0",",","1.0",")",",",">",">",">","iaa.Canny","(","alpha=1",")",",",">",">",">","iaa.MedianBlur","(","13",")",">",">",">",")","Create","an","augmenter","that","blends","a","canny","edge","image","with","a","median-blurred","version","of","the","input","image",".","The","median","blur","uses","a","fixed","kernel","size","of","``","13x13","``","pixels","."]
code: def _draw_samples(self, augmentables, random_state):
      nb_images = len(augmentables)
      rss = random_state.duplicate(4)
  
      alpha_samples = self.alpha.draw_samples((nb_images,), rss[0])
  
      hthresh = self.hysteresis_thresholds
      if isinstance(hthresh, tuple):
          min_values = hthresh[0].draw_samples((nb_images,), rss[1])
          max_values = hthresh[1].draw_samples((nb_images,), rss[2])
          hthresh_samples = np.stack([min_values, max_values], axis=-1)
      else:
          hthresh_samples = hthresh.draw_samples((nb_images, 2), rss[1])
  
      sobel_samples = self.sobel_kernel_size.draw_samples(
          (nb_images,), rss[3]
      )
  
      # verify for hysteresis thresholds that min_value < max_value everywhere
      invalid = hthresh_samples[:, 0] > hthresh_samples[:, 1]
      if np.any(invalid):
          hthresh_samples[invalid, :] = hthresh_samples[invalid, :][
              :, [1, 0]
          ]
  
      # ensure that sobel kernel sizes are correct
      # note that OpenCV accepts only kernel sizes that are (a) even
      # and (b) <=7
      assert not np.any(sobel_samples < 0), (
          "Sampled a sobel kernel size below 0 in Canny. "
          "Allowed value range is 0 to 7."
      )
      assert not np.any(sobel_samples > 7), (
          "Sampled a sobel kernel size above 7 in Canny. "
          "Allowed value range is 0 to 7."
      )
      even_idx = np.mod(sobel_samples, 2) == 0
      sobel_samples[even_idx] -= 1
  
      return alpha_samples, hthresh_samples, sobel_samples
  
imports: from __future__ import print_function, division, absolute_import
  from abc import ABCMeta, abstractmethod
  import numpy
  import cv2
  import six
  import imgaug
  from imgaug.imgaug import _normalize_cv2_input_arr_
  from .None import meta
  from .None import blend
  from ..None import parameters
  from ..None import dtypes
label_desc: Use image node_id 2 for calling the Canny obj's underlying member method code with example usage: obj._draw_samples(augmentables, random_state) and returns: alpha_samples,  hthresh_samples,  sobel_samples