From: Gonzalez C. J. <jor...@hp...> - 2018-03-27 09:12:35
|
I would like to use the LCMS with python, but when I want to call the function cmsDoTransform the following error appears: TypeError: in method 'cmsDoTransform', argument 2 of type 'void const *' What I am sending to the cmsDoTransform si the following: array = [255,255,255] labColor = lcmsF.transformToLab(array,profileInURL,"RGB","perceptual") --------------- def transformToLab(inputColor, profileInURL, formatIn, intent, BPC = True): LabColor = [] labProfile = lcms.cmsCreateLab4Profile(lcms.cmsCIExyY()) inputProfile = lcms.cmsOpenProfileFromFile(profileInURL, "r") if(formatIn == "RGB"): inType = lcms.TYPE_RGB_DBL elif(formatIn == "CMYK"): inType = lcms.TYPE_CMYK_DBL if(intent == "perceptual"): m_intent = lcms.INTENT_PERCEPTUAL if(BPC): m_BPC = lcms.cmsFLAGS_BLACKPOINTCOMPENSATION else: m_BPC = 0 transform = lcms.cmsCreateTransform(inputProfile, inType, labProfile, lcms.TYPE_Lab_DBL, m_intent, m_BPC) lcms.cmsDoTransform(transform,inputColor, LabColor, DIM_OUT) return LabColor How I am supposed to do it? Thanks, Jordi G.C. |
From: Noel C. <NCa...@Pr...> - 2018-03-27 13:54:35
|
Hi Jordi, I only use Little CMS with C++ myself, and this sounds like the kind of problem that requires more language-specific knowledge of Python than I have. Acknowledging that I know nothing about Python, at first glance your array data [255,255,255] does not sound like it matches your chosen data type of lcms.TYPE_RGB_DBL. Are you trying to process byte-wide data? If so, DBL implies 64 bit double precision floating point, and that doesn't seem the right choice for the format. Hope this helps point you in the right direction. -Noel From: Gonzalez Cano, Jordi [mailto:jor...@hp...] Sent: Tue, March 27, 2018 5:12 AM To: lcm...@li... Subject: [Lcms-user] LCMS python I would like to use the LCMS with python, but when I want to call the function cmsDoTransform the following error appears: TypeError: in method 'cmsDoTransform', argument 2 of type 'void const *' What I am sending to the cmsDoTransform si the following: array = [255,255,255] labColor = lcmsF.transformToLab(array,profileInURL,"RGB","perceptual") --------------- def transformToLab(inputColor, profileInURL, formatIn, intent, BPC = True): LabColor = [] labProfile = lcms.cmsCreateLab4Profile(lcms.cmsCIExyY()) inputProfile = lcms.cmsOpenProfileFromFile(profileInURL, "r") if(formatIn == "RGB"): inType = lcms.TYPE_RGB_DBL elif(formatIn == "CMYK"): inType = lcms.TYPE_CMYK_DBL if(intent == "perceptual"): m_intent = lcms.INTENT_PERCEPTUAL if(BPC): m_BPC = lcms.cmsFLAGS_BLACKPOINTCOMPENSATION else: m_BPC = 0 transform = lcms.cmsCreateTransform(inputProfile, inType, labProfile, lcms.TYPE_Lab_DBL, m_intent, m_BPC) lcms.cmsDoTransform(transform,inputColor, LabColor, DIM_OUT) return LabColor How I am supposed to do it? Thanks, Jordi G.C. |
From: John J. <j.j...@nt...> - 2018-03-27 14:23:05
|
Hi, The first thing, cmsCIExyY() shouldn't be used as the white point of the Lab profile. It is initialised to (0, 0, 0) which obviously isn't right. You probably want cmsD50_xyY() instead. The second thing. The format of the RGB data is TYPE_RGB_DBL. That doesn't match the [255, 255, 255] that's used. Use TYPE_RGB_8 instead. I haven't tested the result of applying these, but it should get you further. John On 27/03/2018 10:12, Gonzalez Cano, Jordi wrote: > > I would like to use the LCMS with python, but when I want to call the > function cmsDoTransform the following error appears: /TypeError: in > method 'cmsDoTransform', argument 2 of type 'void const *'/ > > What I am sending to the cmsDoTransform si the following: > > /array = [255,255,255]/ > > /labColor = lcmsF.transformToLab(array,profileInURL,"RGB","perceptual")/ > > // > > /--------------- / > > // > > /def transformToLab(inputColor, profileInURL, formatIn, intent, BPC = > True):/ > > / LabColor = []/ > > // > > / labProfile = lcms.cmsCreateLab4Profile(lcms.cmsCIExyY())/ > > / inputProfile = lcms.cmsOpenProfileFromFile(profileInURL, "r")/ > > // > > / if(formatIn == "RGB"):/ > > / inType = lcms.TYPE_RGB_DBL/ > > / elif(formatIn == "CMYK"):/ > > / inType = lcms.TYPE_CMYK_DBL/ > > // > > / if(intent == "perceptual"):/ > > / m_intent = lcms.INTENT_PERCEPTUAL/ > > // > > / if(BPC):/ > > / m_BPC = lcms.cmsFLAGS_BLACKPOINTCOMPENSATION/ > > / else:/ > > / m_BPC = 0/ > > / transform = lcms.cmsCreateTransform(inputProfile, inType, > labProfile, lcms.TYPE_Lab_DBL, m_intent, m_BPC)/ > > // > > */ lcms.cmsDoTransform(transform,inputColor, LabColor, DIM_OUT)/* > > / return LabColor/ > > // > > How I am supposed to do it? > > Thanks, > > Jordi G.C. > > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > > > _______________________________________________ > Lcms-user mailing list > Lcm...@li... > https://lists.sourceforge.net/lists/listinfo/lcms-user |
From: John J. <j.j...@nt...> - 2018-03-27 14:42:23
|
Sorry, a third thing. You need to marshal the input & output colour data using a special array format, because the bindings don't do that automatically. You need to do something like this: RGB = [255,255,255] rgb_in = uint8Array(in_comps * n_pixels) Lab_out = doubleArray(out_comps * n_pixels) for i in range(in_comps * n_pixels): rgb_in[i] = RGB[i] cmsDoTransform(....) Lab_tuple = tuple(Lab_out[i] for i in range(out_comps * n_pixels)) The test_05_transform_rgb_Lab test gives an example of what you should be doing. Sorry, that's the way it is until effort is put into doing automatic marshalling to/from Python lists. John On 27/03/2018 15:22, John Jefferies wrote: > > Hi, > The first thing, cmsCIExyY() shouldn't be used as the white point of > the Lab profile. It is initialised to (0, 0, 0) which obviously isn't > right. You probably want cmsD50_xyY() instead. > > The second thing. The format of the RGB data is TYPE_RGB_DBL. That > doesn't match the [255, 255, 255] that's used. Use TYPE_RGB_8 instead. > > I haven't tested the result of applying these, but it should get you > further. > > John > > On 27/03/2018 10:12, Gonzalez Cano, Jordi wrote: >> >> I would like to use the LCMS with python, but when I want to call the >> function cmsDoTransform the following error appears: /TypeError: in >> method 'cmsDoTransform', argument 2 of type 'void const *'/ >> >> What I am sending to the cmsDoTransform si the following: >> >> /array = [255,255,255]/ >> >> /labColor = lcmsF.transformToLab(array,profileInURL,"RGB","perceptual")/ >> >> // >> >> /--------------- / >> >> // >> >> /def transformToLab(inputColor, profileInURL, formatIn, intent, BPC = >> True):/ >> >> / LabColor = []/ >> >> // >> >> / labProfile = lcms.cmsCreateLab4Profile(lcms.cmsCIExyY())/ >> >> / inputProfile = lcms.cmsOpenProfileFromFile(profileInURL, "r")/ >> >> // >> >> / if(formatIn == "RGB"):/ >> >> / inType = lcms.TYPE_RGB_DBL/ >> >> / elif(formatIn == "CMYK"):/ >> >> / inType = lcms.TYPE_CMYK_DBL/ >> >> // >> >> / if(intent == "perceptual"):/ >> >> / m_intent = lcms.INTENT_PERCEPTUAL/ >> >> // >> >> / if(BPC):/ >> >> / m_BPC = lcms.cmsFLAGS_BLACKPOINTCOMPENSATION/ >> >> / else:/ >> >> / m_BPC = 0/ >> >> / transform = lcms.cmsCreateTransform(inputProfile, inType, >> labProfile, lcms.TYPE_Lab_DBL, m_intent, m_BPC)/ >> >> // >> >> */ lcms.cmsDoTransform(transform,inputColor, LabColor, DIM_OUT)/* >> >> / return LabColor/ >> >> // >> >> How I am supposed to do it? >> >> Thanks, >> >> Jordi G.C. >> >> >> >> ------------------------------------------------------------------------------ >> Check out the vibrant tech community on one of the world's most >> engaging tech sites, Slashdot.org!http://sdm.link/slashdot >> >> >> _______________________________________________ >> Lcms-user mailing list >> Lcm...@li... >> https://lists.sourceforge.net/lists/listinfo/lcms-user > |
From: Aaron B. <bo...@gm...> - 2018-03-27 14:31:18
|
On Tue, Mar 27, 2018 at 10:22 AM, John Jefferies via Lcms-user < lcm...@li...> wrote: > > Hi, > The first thing, cmsCIExyY() shouldn't be used as the white point of the > Lab profile. It is initialised to (0, 0, 0) which obviously isn't right. > You probably want cmsD50_xyY() instead. > > The second thing. The format of the RGB data is TYPE_RGB_DBL. That doesn't > match the [255, 255, 255] that's used. Use TYPE_RGB_8 instead. > Doesn't [255,255,255] create an array of dimension 255x255x255 ? On 27/03/2018 10:12, Gonzalez Cano, Jordi wrote: I would like to use the LCMS with python, but when I want to call the function cmsDoTransform the following error appears: *TypeError: in method 'cmsDoTransform', argument 2 of type 'void const *'* What I am sending to the cmsDoTransform si the following: *array = [255,255,255]* *labColor = lcmsF.transformToLab(array,profileInURL,"RGB","perceptual")* *--------------- * *def transformToLab(inputColor, profileInURL, formatIn, intent, BPC = True):* * LabColor = []* * labProfile = lcms.cmsCreateLab4Profile(lcms.cmsCIExyY())* * inputProfile = lcms.cmsOpenProfileFromFile(profileInURL, "r")* * if(formatIn == "RGB"):* * inType = lcms.TYPE_RGB_DBL* * elif(formatIn == "CMYK"):* * inType = lcms.TYPE_CMYK_DBL* * if(intent == "perceptual"):* * m_intent = lcms.INTENT_PERCEPTUAL* * if(BPC):* * m_BPC = lcms.cmsFLAGS_BLACKPOINTCOMPENSATION* * else:* * m_BPC = 0* * transform = lcms.cmsCreateTransform(inputProfile, inType, labProfile, lcms.TYPE_Lab_DBL, m_intent, m_BPC)* * lcms.cmsDoTransform(transform,inputColor, LabColor, DIM_OUT)* * return LabColor* How I am supposed to do it? Thanks, Jordi G.C. ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Lcms-user mailing lis...@li...https://lists.sourceforge.net/lists/listinfo/lcms-user > ------------------------------------------------------------ > ------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Lcms-user mailing list > Lcm...@li... > https://lists.sourceforge.net/lists/listinfo/lcms-user > > |
From: John J. <j.j...@nt...> - 2018-03-27 14:35:31
|
On 27/03/2018 15:31, Aaron Boxer wrote: > > On Tue, Mar 27, 2018 at 10:22 AM, John Jefferies via Lcms-user > <lcm...@li... > <mailto:lcm...@li...>> wrote: > > > Hi, > The first thing, cmsCIExyY() shouldn't be used as the white point > of the Lab profile. It is initialised to (0, 0, 0) which > obviously isn't right. You probably want cmsD50_xyY() instead. > > The second thing. The format of the RGB data is TYPE_RGB_DBL. That > doesn't match the [255, 255, 255] that's used. Use TYPE_RGB_8 instead. > > > > Doesn't [255,255,255] create an array of dimension 255x255x255 ? No, it creates a 3 element list. John |