class_docstr: RGB represents a regularly spaced 2D grid of an underlying
  continuous space of RGB(A) (red, green, blue and alpha) color
  space values. The definition of the grid closely matches the
  semantics of an Image and in the simplest case the grid may be
  specified as a NxMx3 or NxMx4 array of values along with a bounds,
  but it may also be defined through explicit and regularly spaced
  x/y-coordinate arrays. The two most basic supported constructors
  of an RGB element therefore include:
  
      RGB((X, Y, R, G, B))
  
  where X is a 1D array of shape M, Y is a 1D array of shape N and
  R/G/B are 2D array of shape NxM, or equivalently:
  
      RGB(Z, bounds=(x0, y0, x1, y1))
  
  where Z is a 3D array of stacked R/G/B arrays with shape NxMx3/4
  and the bounds define the (left, bottom, top, right) edges of the
  four corners of the grid. Other gridded formats which support
  declaring of explicit x/y-coordinate arrays such as xarray are
  also supported.
  
  Note that the interpretation of the orientation changes depending
  on whether bounds or explicit coordinates are used.
class_docstr_tok: ["RGB","represents","a","regularly","spaced","2D","grid","of","an","underlying","continuous","space","of","RGB","(","A",")","(","red",",","green",",","blue","and","alpha",")","color","space","values",".","The","definition","of","the","grid","closely","matches","the","semantics","of","an","Image","and","in","the","simplest","case","the","grid","may","be","specified","as","a","NxMx3","or","NxMx4","array","of","values","along","with","a","bounds",",","but","it","may","also","be","defined","through","explicit","and","regularly","spaced","x\/y-coordinate","arrays",".","The","two","most","basic","supported","constructors","of","an","RGB","element","therefore","include",":","RGB","(","(","X",",","Y",",","R",",","G",",","B",")",")","where","X","is","a","1D","array","of","shape","M",",","Y","is","a","1D","array","of","shape","N","and","R\/G\/B","are","2D","array","of","shape","NxM",",","or","equivalently",":","RGB","(","Z",",","bounds=","(","x0",",","y0",",","x1",",","y1",")",")","where","Z","is","a","3D","array","of","stacked","R\/G\/B","arrays","with","shape","NxMx3\/4","and","the","bounds","define","the","(","left",",","bottom",",","top",",","right",")","edges","of","the","four","corners","of","the","grid",".","Other","gridded","formats","which","support","declaring","of","explicit","x\/y-coordinate","arrays","such","as","xarray","are","also","supported",".","Note","that","the","interpretation","of","the","orientation","changes","depending","on","whether","bounds","or","explicit","coordinates","are","used","."]
code: def __init__(self, data, kdims=None, vdims=None, **params):
      if isinstance(data, Overlay):
          images = data.values()
          if not all(isinstance(im, Image) for im in images):
              raise ValueError(
                  "Input overlay must only contain Image elements"
              )
          shapes = [im.data.shape for im in images]
          if not all(shape == shapes[0] for shape in shapes):
              raise ValueError(
                  "Images in the input overlays must contain data of the consistent shape"
              )
          ranges = [im.vdims[0].range for im in images]
          if any(None in r for r in ranges):
              raise ValueError(
                  "Ranges must be defined on all the value dimensions of all the Images"
              )
          arrays = [
              (im.data - r[0]) / (r[1] - r[0])
              for r, im in zip(ranges, images)
          ]
          data = np.dstack(arrays)
      if vdims is None:
          # Need to make a deepcopy of the value so the RGB.default is not shared across instances
          vdims = deepcopy(self.vdims)
      else:
          vdims = list(vdims) if isinstance(vdims, list) else [vdims]
  
      alpha = self.alpha_dimension
      if (
          (
              hasattr(data, "shape")
              and data.shape[-1] == 4
              and len(vdims) == 3
          )
          or (
              isinstance(data, tuple)
              and isinstance(data[-1], np.ndarray)
              and data[-1].ndim == 3
              and data[-1].shape[-1] == 4
              and len(vdims) == 3
          )
          or (
              isinstance(data, dict)
              and tuple(dimension_name(vd) for vd in vdims)
              + (alpha.name,)
              in data
          )
      ):
          # Handle all forms of packed value dimensions
          vdims.append(alpha)
      super().__init__(data, kdims=kdims, vdims=vdims, **params)
  
imports: import colorsys
  from copy import deepcopy
  from operator import itemgetter
  import numpy
  import param
  from ..core import Dataset, Dimension, Element2D, Overlay, config, util
  from ..core.boundingregion import BoundingBox, BoundingRegion
  from ..core.data import ImageInterface
  from ..core.data.interface import DataError
  from ..core.dimension import dimension_name
  from ..core.sheetcoords import SheetCoordinateSystem, Slice
  from .chart import Curve
  from .geom import Selection2DExpr
  from .graphs import TriMesh
  from .tabular import Table
  from .util import categorical_aggregate2d, compute_slice_bounds
label_desc: Use image node_id 3 to create a new RGB object from inherited base classes: Image with example: obj = RGB(data, kdims, vdims)