code: def rgb2ycbcr(img, y_only=False):
      """Convert a RGB image to YCbCr image.
  
      This function produces the same results as Matlab's `rgb2ycbcr` function.
      It implements the ITU-R BT.601 conversion for standard-definition
      television. See more details in
      https://en.wikipedia.org/wiki/YCbCr#ITU-R_BT.601_conversion.
  
      It differs from a similar function in cv2.cvtColor: `RGB <-> YCrCb`.
      In OpenCV, it implements a JPEG conversion. See more details in
      https://en.wikipedia.org/wiki/YCbCr#JPEG_conversion.
  
      Args:
          img (ndarray): The input image. It accepts:
              1. np.uint8 type with range [0, 255];
              2. np.float32 type with range [0, 1].
          y_only (bool): Whether to only return Y channel. Default: False.
  
      Returns:
          ndarray: The converted YCbCr image. The output image has the same type
              and range as input image.
      """
      img_type = img.dtype
      img = _convert_input_type_range(img)
      if y_only:
          out_img = np.dot(img, [65.481, 128.553, 24.966]) + 16.0
      else:
          out_img = np.matmul(
              img,
              [
                  [65.481, -37.797, 112.0],
                  [128.553, -74.203, -93.786],
                  [24.966, 112.0, -18.214],
              ],
          ) + [16, 128, 128]
      out_img = _convert_output_type_range(out_img, img_type)
      return out_img
  
file_path: lavis/lavis/common/annotator/uniformer/mmcv/image/colorspace.py
imports: import cv2
  import numpy
label_desc: Use image node_id 8 for calling a global function with example usage: rgb2ycbcr(img, y_only) and returns: out_img