code: def rgb2hsv(rgb, *, channel_axis=-1):
      """RGB to HSV color space conversion.
  
      Parameters
      ----------
      rgb : (..., C=3, ...) array_like
          The image in RGB format. By default, the final dimension denotes
          channels.
      channel_axis : int, optional
          This parameter indicates which axis of the array corresponds to
          channels.
  
          .. versionadded:: 0.19
             ``channel_axis`` was added in 0.19.
  
      Returns
      -------
      out : (..., C=3, ...) ndarray
          The image in HSV format. Same dimensions as input.
  
      Raises
      ------
      ValueError
          If `rgb` is not at least 2-D with shape (..., C=3, ...).
  
      Notes
      -----
      Conversion between RGB and HSV color spaces results in some loss of
      precision, due to integer arithmetic and rounding [1]_.
  
      References
      ----------
      .. [1] https://en.wikipedia.org/wiki/HSL_and_HSV
  
      Examples
      --------
      >>> from skimage import color
      >>> from skimage import data
      >>> img = data.astronaut()
      >>> img_hsv = color.rgb2hsv(img)
      """
      input_is_one_pixel = rgb.ndim == 1
      if input_is_one_pixel:
          rgb = rgb[np.newaxis, ...]
  
      arr = _prepare_colorarray(rgb, channel_axis=-1)
      out = np.empty_like(arr)
  
      # -- V channel
      out_v = arr.max(-1)
  
      # -- S channel
      delta = arr.ptp(-1)
      # Ignore warning for zero divided by zero
      old_settings = np.seterr(invalid="ignore")
      out_s = delta / out_v
      out_s[delta == 0.0] = 0.0
  
      # -- H channel
      # red is max
      idx = arr[..., 0] == out_v
      out[idx, 0] = (arr[idx, 1] - arr[idx, 2]) / delta[idx]
  
      # green is max
      idx = arr[..., 1] == out_v
      out[idx, 0] = 2.0 + (arr[idx, 2] - arr[idx, 0]) / delta[idx]
  
      # blue is max
      idx = arr[..., 2] == out_v
      out[idx, 0] = 4.0 + (arr[idx, 0] - arr[idx, 1]) / delta[idx]
      out_h = (out[..., 0] / 6.0) % 1.0
      out_h[delta == 0.0] = 0.0
  
      np.seterr(**old_settings)
  
      # -- output
      out[..., 0] = out_h
      out[..., 1] = out_s
      out[..., 2] = out_v
  
      # # remove NaN
      out[np.isnan(out)] = 0
  
      if input_is_one_pixel:
          out = np.squeeze(out, axis=0)
  
      return out
  
imports: from warnings import warn
  import numpy
  from scipy import linalg
  from .._shared.utils import _supported_float_type, channel_as_last_axis, identity, reshape_nd, slice_at_axis
  from ..util import dtype, dtype_limits
label_desc: Use image node_id 5 for calling a global function with example usage: rgb2hsv(rgb) and returns: out