source/utils.py
def convert_rgb_to_ycbcr(img, dim_order='hwc'):
    """ Convert to YCbCr from RGB (standard conversion)

    :param img: input image array in RGB form
    :return: out image array in YCbCr form

    """

    if dim_order == 'hwc':
        y = 16. + (64.738 * img[..., 0] + 129.057 * img[..., 1] + 25.064 * img[..., 2]) / 256.
        cb = 128. + (-37.945 * img[..., 0] - 74.494 * img[..., 1] + 112.439 * img[..., 2]) / 256.
        cr = 128. + (112.439 * img[..., 0] - 94.154 * img[..., 1] - 18.285 * img[..., 2]) / 256.
    else:
        y = 16. + (64.738 * img[0] + 129.057 * img[1] + 25.064 * img[2]) / 256.
        cb = 128. + (-37.945 * img[0] - 74.494 * img[1] + 112.439 * img[2]) / 256.
        cr = 128. + (112.439 * img[0] - 94.154 * img[1] - 18.285 * img[2]) / 256.
    return np.array([y, cb, cr]).transpose([1, 2, 0])
 Convert to YCbCr from RGB (standard conversion)

    :param img: input image array in RGB form
    :return: out image array in YCbCr form

    
Convert to YCbCr from RGB (standard conversion)
Convert to YCbCr from RGB ( standard conversion )
def convert_rgb_to_ycbcr(img, dim_order='hwc'):
    if dim_order == 'hwc':
        y = 16. + (64.738 * img[..., 0] + 129.057 * img[..., 1] + 25.064 * img[..., 2]) / 256.
        cb = 128. + (-37.945 * img[..., 0] - 74.494 * img[..., 1] + 112.439 * img[..., 2]) / 256.
        cr = 128. + (112.439 * img[..., 0] - 94.154 * img[..., 1] - 18.285 * img[..., 2]) / 256.
    else:
        y = 16. + (64.738 * img[0] + 129.057 * img[1] + 25.064 * img[2]) / 256.
        cb = 128. + (-37.945 * img[0] - 74.494 * img[1] + 112.439 * img[2]) / 256.
        cr = 128. + (112.439 * img[0] - 94.154 * img[1] - 18.285 * img[2]) / 256.
    return np.array([y, cb, cr]).transpose([1, 2, 0])
def convert_rgb_to_ycbcr ( img , dim_order = 'hwc' ) : if dim_order == 'hwc' : y = 16. + ( 64.738 * img [ ... , 0 ] + 129.057 * img [ ... , 1 ] + 25.064 * img [ ... , 2 ] ) / 256. cb = 128. + ( - 37.945 * img [ ... , 0 ] - 74.494 * img [ ... , 1 ] + 112.439 * img [ ... , 2 ] ) / 256. cr = 128. + ( 112.439 * img [ ... , 0 ] - 94.154 * img [ ... , 1 ] - 18.285 * img [ ... , 2 ] ) / 256. else : y = 16. + ( 64.738 * img [ 0 ] + 129.057 * img [ 1 ] + 25.064 * img [ 2 ] ) / 256. cb = 128. + ( - 37.945 * img [ 0 ] - 74.494 * img [ 1 ] + 112.439 * img [ 2 ] ) / 256. cr = 128. + ( 112.439 * img [ 0 ] - 94.154 * img [ 1 ] - 18.285 * img [ 2 ] ) / 256. return np . array ( [ y , cb , cr ] ) . transpose ( [ 1 , 2 , 0 ] )
Convert to YCbCr from RGB (standard conversion)
Convert to YCbCr from RGB ( standard conversion )
""" Convert to YCbCr from RGB (standard conversion)

    :param img: input image array in RGB form
    :return: out image array in YCbCr form

    """
out image array in YCbCr form
out image array in YCbCr form
img
input image array in RGB form
input image array in RGB form
dim_order