Ask Your Question

Revision history [back]

You should know the difference between sRGB and Adobe RGB.Sorry, opencv and pillow can not complete this task very well.You should try to process the image with imagemagick first.Like this:

from PIL import Image, ImageCMS
import numpy as np
srgb = ImageCms.createProfile('sRGB')
def get_adobe(img):
    output = BytesIO()   
    adobe = ImageCms.getOpenProfile(output)     
    return adobe

def convert_to_srgb(image):
    if'icc_profile', ''):
        adobe = get_adobe(image)
        image = ImageCms.profileToProfile(image, adobe, srgb)
    return image