PyCMS: ICC Profil CANNOT transform

700 Views Asked by At

Now I have a project about color-management for the smartphone camera and i have a that I can't transform my selfmade icc profile in the pycms. It raises always the error 'PIL.ImageCms.PyCMSError: cannot build transform '. Now, i am very confused,when i use the standard icc profile, the transform is always successful.

Therefore, I consider that there are a problem either with my selfmade icc Profile or something wrong with the Codes. So i have made my ICC Profile for smartphone camera with 3 methods:

The first method: with software 'color checker camera calibration' Firstly, i have sampled all Pictures from differents smartphones. And then i have transformed the 'jpeg'pictures in 'Tiff' and lade them in the software. Finally, I get my icc Profile.

Second method with software 'I1 Profiler' and the third method with 'BaicColor input 6' are also similar as the first method.

But all of the Icc profile can’t be transformed in my code. Now i don't know where is the problem in my code or in my ICC profile. Could you please tell me where is my problem? on my ICC Profile OR on my code? the following is my code in Python3.7 and in hyperlinks you will also find my icc.enter link description here

import os
from PIL.ImageCms import *


# initialization the current working directory into a dictionary 
def init():
    current_dir = os.path.abspath(os.path.dirname(__file__))
    return {
        'honor6x': os.path.join(current_dir, 'icc_profile', 'honor6x.icc'),
        'honor7i': os.path.join(current_dir, 'icc_profile', 'honor7i.icc'),
        'huawei-p30pro': os.path.join(current_dir, 'icc_profile', 'huawei-p30pro.icc'),
        'iphone6s': os.path.join(current_dir, 'icc_profile', 'iphone6s.icc'),
        'iphone8': os.path.join(current_dir, 'icc_profile', 'iphone8.icc'),
        'iphonex': os.path.join(current_dir, 'icc_profile', 'iphonex.icc'),
        'samsung-s8': os.path.join(current_dir, 'icc_profile', 'samsung-s8.icc'),
        'sony-G8341': os.path.join(current_dir, 'icc_profile', 'sony-G8341.icc')
    }


# the main function to carry out the icc-profile retrieval with the input of the smartphone type,
# and correction the input photos through the icc-profile
def main():
    #my_phone = input('give me a type of smartphone:')
    #icc = get_icc(my_phone)
    #if not icc:
     #   return
    #print(icc)
    inputProfile = ImageCmsProfile(os.path.join('icc_profile', 'sRGB_IEC61966-2-1_no_black_scaling(v4).icc'))
    outputProfile = ImageCmsProfile(os.path.join('icc_profile', 'sRGB2014(v2.0.0).icc'))
    print(outputProfile)
    # input the new photo and transform it to the corrected photo through the icc-Profile
    my_photo = input('give me a photo of the smartphone:')
    im = Image.open(my_photo)


    im_converted = profileToProfile(im, inputProfile, outputProfile, renderingIntent=1)
    # after the transformation of the input photo, save the corrected photos as a target photo
    im_converted.save (f"{my_photo}_corrected.jpeg")

# search the input type smartphone with the relevant icc profile, if the input type in the dict and get its icc
# if not, print it
def get_icc(my_phone):
    if my_phone not in icc_dict:
        print(f'{my_phone} is not validated!')
    return icc_dict.get(my_phone)



if __name__ == '__main__':
    icc_dict = init()

    main()
0

There are 0 best solutions below