def rgb2ycbcr(img, only_y=True):
    'same as matlab rgb2ycbcr\n    only_y: only return Y channel\n    Input:\n        uint8, [0, 255]\n        float, [0, 1]\n    '
    in_img_type = img.dtype
    img_ = img.astype(np.float32)
    if (in_img_type != np.uint8):
        img_ *= 255.0
    if only_y:
        rlt = ((np.dot(img_, [65.481, 128.553, 24.966]) / 255.0) + 16.0)
    else:
        rlt = ((np.matmul(img_, [[65.481, (- 37.797), 112.0], [128.553, (- 74.203), (- 93.786)], [24.966, 112.0, (- 18.214)]]) / 255.0) + [16, 128, 128])
    if (in_img_type == np.uint8):
        rlt = rlt.round()
    else:
        rlt /= 255.0
    return rlt.astype(in_img_type)
same as matlab rgb2ycbcr
only_y: only return Y channel
Input:
    uint8, [0, 255]
    float, [0, 1]
def rgb2ycbcr(img, only_y=True):
    'same as matlab rgb2ycbcr\n    only_y: only return Y channel\n    Input:\n        uint8, [0, 255]\n        float, [0, 1]\n    '
    in_img_type = img.dtype
    img_ = img.astype(np.float32)
    if (in_img_type != np.uint8):
        img_ *= 255.0
    if only_y:
        rlt = ((np.dot(img_, [65.481, 128.553, 24.966]) / 255.0) + 16.0)
    else:
        rlt = ((np.matmul(img_, [[65.481, (- 37.797), 112.0], [128.553, (- 74.203), (- 93.786)], [24.966, 112.0, (- 18.214)]]) / 255.0) + [16, 128, 128])
    if (in_img_type == np.uint8):
        rlt = rlt.round()
    else:
        rlt /= 255.0
    return rlt.astype(in_img_type)