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

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

    """

    if dim_order == 'hwc':
        r = 298.082 * img[..., 0] / 256. + 408.583 * img[..., 2] / 256. - 222.921
        g = 298.082 * img[..., 0] / 256. - 100.291 * img[..., 1] / 256. - 208.120 * img[..., 2] / 256. + 135.576
        b = 298.082 * img[..., 0] / 256. + 516.412 * img[..., 1] / 256. - 276.836
    else:
        r = 298.082 * img[0] / 256. + 408.583 * img[2] / 256. - 222.921
        g = 298.082 * img[0] / 256. - 100.291 * img[1] / 256. - 208.120 * img[2] / 256. + 135.576
        b = 298.082 * img[0] / 256. + 516.412 * img[1] / 256. - 276.836
    return np.array([r, g, b]).transpose([1, 2, 0])
 Convert to RGB from YCbCr (standard conversion)

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

    
Convert to RGB from YCbCr (standard conversion)
Convert to RGB from YCbCr ( standard conversion )
def convert_ycbcr_to_rgb(img, dim_order='hwc'):
    if dim_order == 'hwc':
        r = 298.082 * img[..., 0] / 256. + 408.583 * img[..., 2] / 256. - 222.921
        g = 298.082 * img[..., 0] / 256. - 100.291 * img[..., 1] / 256. - 208.120 * img[..., 2] / 256. + 135.576
        b = 298.082 * img[..., 0] / 256. + 516.412 * img[..., 1] / 256. - 276.836
    else:
        r = 298.082 * img[0] / 256. + 408.583 * img[2] / 256. - 222.921
        g = 298.082 * img[0] / 256. - 100.291 * img[1] / 256. - 208.120 * img[2] / 256. + 135.576
        b = 298.082 * img[0] / 256. + 516.412 * img[1] / 256. - 276.836
    return np.array([r, g, b]).transpose([1, 2, 0])
def convert_ycbcr_to_rgb ( img , dim_order = 'hwc' ) : if dim_order == 'hwc' : r = 298.082 * img [ ... , 0 ] / 256. + 408.583 * img [ ... , 2 ] / 256. - 222.921 g = 298.082 * img [ ... , 0 ] / 256. - 100.291 * img [ ... , 1 ] / 256. - 208.120 * img [ ... , 2 ] / 256. + 135.576 b = 298.082 * img [ ... , 0 ] / 256. + 516.412 * img [ ... , 1 ] / 256. - 276.836 else : r = 298.082 * img [ 0 ] / 256. + 408.583 * img [ 2 ] / 256. - 222.921 g = 298.082 * img [ 0 ] / 256. - 100.291 * img [ 1 ] / 256. - 208.120 * img [ 2 ] / 256. + 135.576 b = 298.082 * img [ 0 ] / 256. + 516.412 * img [ 1 ] / 256. - 276.836 return np . array ( [ r , g , b ] ) . transpose ( [ 1 , 2 , 0 ] )
Convert to RGB from YCbCr (standard conversion)
Convert to RGB from YCbCr ( standard conversion )
""" Convert to RGB from YCbCr (standard conversion)

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

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