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","."]
docstr: Load an image from a file and return an RGB element or array
  
  Args:
      filename: Filename of the image to be loaded
      height: Determines the bounds of the image where the width
              is scaled relative to the aspect ratio of the image.
      array: Whether to return an array (rather than RGB default)
      bounds: Bounds for the returned RGB (overrides height)
      bare: Whether to hide the axes
      kwargs: Additional kwargs to the RGB constructor
  
  Returns:
      RGB element or array
docstr_tok: ["Load","an","image","from","a","file","and","return","an","RGB","element","or","array","Args",":","filename",":","Filename","of","the","image","to","be","loaded","height",":","Determines","the","bounds","of","the","image","where","the","width","is","scaled","relative","to","the","aspect","ratio","of","the","image",".","array",":","Whether","to","return","an","array","(","rather","than","RGB","default",")","bounds",":","Bounds","for","the","returned","RGB","(","overrides","height",")","bare",":","Whether","to","hide","the","axes","kwargs",":","Additional","kwargs","to","the","RGB","constructor","Returns",":","RGB","element","or","array"]
code: def load_image(
      cls,
      filename,
      height=1,
      array=False,
      bounds=None,
      bare=False,
      **kwargs,
  ):
      """Load an image from a file and return an RGB element or array
  
      Args:
          filename: Filename of the image to be loaded
          height: Determines the bounds of the image where the width
                  is scaled relative to the aspect ratio of the image.
          array: Whether to return an array (rather than RGB default)
          bounds: Bounds for the returned RGB (overrides height)
          bare: Whether to hide the axes
          kwargs: Additional kwargs to the RGB constructor
  
      Returns:
          RGB element or array
      """
      try:
          from PIL import Image
      except ImportError:
          raise ImportError(
              "RGB.load_image requires PIL (or Pillow)."
          ) from None
  
      with open(filename, "rb") as f:
          data = np.array(Image.open(f))
          data = data / 255.0
  
      if array:
          return data
  
      (h, w, _) = data.shape
      if bounds is None:
          f = float(height) / h
          xoffset, yoffset = w * f / 2, h * f / 2
          bounds = (-xoffset, -yoffset, xoffset, yoffset)
      rgb = cls(data, bounds=bounds, **kwargs)
      if bare:
          rgb.opts(xaxis=None, yaxis=None)
      return rgb
  
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 2 for calling the RGB obj's underlying member method code with example usage: obj.load_image(cls, filename, height, array, bounds, bare) and returns: rgb, data