class_docstr: Colorizer using two randomly sampled foreground/background colors.
  
  Parameters
  ----------
  color_true : int or tuple of int or list of int or imgaug.parameters.StochasticParameter, optional
      Color of the foreground, i.e. all pixels in binary images that are
      ``True``. This parameter will be queried once per image to
      generate ``(3,)`` samples denoting the color. (Note that even for
      grayscale images three values will be sampled and converted to
      grayscale according to ``0.299*R + 0.587*G + 0.114*B``. This is the
      same equation that is also used by OpenCV.)
  
          * If an int, exactly that value will always be used, i.e. every
            color will be ``(v, v, v)`` for value ``v``.
          * If a tuple ``(a, b)``, three random values from the range
            ``a <= x <= b`` will be sampled per image.
          * If a list, then three random values will be sampled from that
            list per image.
          * If a StochasticParameter, three values will be sampled from the
            parameter per image.
  
  color_false : int or tuple of int or list of int or imgaug.parameters.StochasticParameter, optional
      Analogous to `color_true`, but denotes the color for all pixels that
      are ``False`` in the binary input image.
class_docstr_tok: ["Colorizer","using","two","randomly","sampled","foreground\/background","colors",".","Parameters","--","--","--","--","--","color_true",":","int","or","tuple","of","int","or","list","of","int","or","imgaug.parameters.StochasticParameter",",","optional","Color","of","the","foreground",",","i.e",".","all","pixels","in","binary","images","that","are","``","True","``",".","This","parameter","will","be","queried","once","per","image","to","generate","``","(","3",",",")","``","samples","denoting","the","color",".","(","Note","that","even","for","grayscale","images","three","values","will","be","sampled","and","converted","to","grayscale","according","to","``","0.299","*","R","+","0.587","*","G","+","0.114","*","B","``",".","This","is","the","same","equation","that","is","also","used","by","OpenCV",".",")","*","If","an","int",",","exactly","that","value","will","always","be","used",",","i.e",".","every","color","will","be","``","(","v",",","v",",","v",")","``","for","value","``","v","``",".","*","If","a","tuple","``","(","a",",","b",")","``",",","three","random","values","from","the","range","``","a","<","=","x","<","=","b","``","will","be","sampled","per","image",".","*","If","a","list",",","then","three","random","values","will","be","sampled","from","that","list","per","image",".","*","If","a","StochasticParameter",",","three","values","will","be","sampled","from","the","parameter","per","image",".","color_false",":","int","or","tuple","of","int","or","list","of","int","or","imgaug.parameters.StochasticParameter",",","optional","Analogous","to","`","color_true","`",",","but","denotes","the","color","for","all","pixels","that","are","``","False","``","in","the","binary","input","image","."]
code: def colorize(
      self, image_binary, image_original, nth_image, random_state
  ):
      assert image_binary.ndim == 2, (
          "Expected binary image to colorize to be 2-dimensional, "
          "got %d dimensions." % (image_binary.ndim,)
      )
      assert image_binary.dtype.kind == "b", (
          "Expected binary image to colorize to be boolean, "
          "got dtype kind %s." % (image_binary.dtype.kind,)
      )
      assert image_original.ndim == 3, (
          "Expected original image to be 3-dimensional, got %d "
          "dimensions." % (image_original.ndim,)
      )
      assert image_original.shape[-1] in [1, 3, 4], (
          "Expected original image to have 1, 3 or 4 channels. "
          "Got %d channels." % (image_original.shape[-1],)
      )
      assert image_original.dtype == iadt._UINT8_DTYPE, (
          "Expected original image to have dtype uint8, got dtype %s."
          % (image_original.dtype.name)
      )
  
      color_true, color_false = self._draw_samples(random_state)
  
      nb_channels = min(image_original.shape[-1], 3)
      image_colorized = np.zeros(
          (
              image_original.shape[0],
              image_original.shape[1],
              nb_channels,
          ),
          dtype=image_original.dtype,
      )
  
      if nb_channels == 1:
          # single channel input image, convert colors to grayscale
          image_colorized[image_binary] = (
              0.299 * color_true[0]
              + 0.587 * color_true[1]
              + 0.114 * color_true[2]
          )
          image_colorized[~image_binary] = (
              0.299 * color_false[0]
              + 0.587 * color_false[1]
              + 0.114 * color_false[2]
          )
      else:
          image_colorized[image_binary] = color_true
          image_colorized[~image_binary] = color_false
  
      # re-attach alpha channel if it was present in input image
      if image_original.shape[-1] == 4:
          image_colorized = np.dstack(
              [image_colorized, image_original[:, :, 3:4]]
          )
  
      return image_colorized
  
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 3 for calling the RandomColorsBinaryImageColorizer obj's underlying member method code with example usage: obj.colorize(image_binary, image_original, nth_image, random_state) and returns: image_colorized