Thread: [Lcms-user] Apply profile with PCS = cmsSigXYZData, Color Space = cmsSigGrayData
An ICC-based CMM for color management
Brought to you by:
mm2
|
From: Aaron B. <bo...@gm...> - 2017-02-20 06:04:37
|
Hello, I have a jpeg 2000 file with an ICC profile. PCS is cmsSigXYZData and color space is cmsSigGrayData. The file can be found here: https://github.com/GrokImageCompression/grok/issues/38 I am working on a library that decodes the jpeg 2000 file and applies the ICC profile, using LCMS. Currently, I have this code: in_type = TYPE_GRAY_8; out_type = TYPE_RGB_8; out_prof = cmsCreate_sRGBProfile(); and I can create the transform and apply the ICC profile, but the output is an RGB file. What I would like is to output a grayscale file. So, if I instead call out_prof = cmsCreateGrayProfile(NULL,NULL); then cmsCreateTransform returns NULL and I can't apply the profile. What is the best way of creating a transform for this kind of grayscale image ? Thanks so much, Aaron |
|
From: Noel C. <NCa...@Pr...> - 2017-02-20 16:23:12
|
Hi Aaron, What do you mean by "applies the ICC profile"? Are you trying to convert the image to be displayed accurately on a monitor? If so, wouldn't you want the output type to be RGB and use the monitor's profile as the output profile? Perhaps I'm not understanding at all what you're trying to accomplish. -Noel From: Aaron Boxer [mailto:bo...@gm...] Sent: Mon, February 20, 2017 1:04 AM To: lcm...@li... Subject: [Lcms-user] Apply profile with PCS = cmsSigXYZData, Color Space = cmsSigGrayData Hello, I have a jpeg 2000 file with an ICC profile. PCS is cmsSigXYZData and color space is cmsSigGrayData. The file can be found here: https://github.com/GrokImageCompression/grok/issues/38 I am working on a library that decodes the jpeg 2000 file and applies the ICC profile, using LCMS. Currently, I have this code: in_type = TYPE_GRAY_8; out_type = TYPE_RGB_8; out_prof = cmsCreate_sRGBProfile(); and I can create the transform and apply the ICC profile, but the output is an RGB file. What I would like is to output a grayscale file. So, if I instead call out_prof = cmsCreateGrayProfile(NULL,NULL); then cmsCreateTransform returns NULL and I can't apply the profile. What is the best way of creating a transform for this kind of grayscale image ? Thanks so much, Aaron |
|
From: Aaron B. <bo...@gm...> - 2017-02-20 16:35:04
|
Thanks, Noel. This is not for display on monitor. JPEG 2000 supports embedded ICC profiles, and I am trying to use the profile when decoding the image. On Mon, Feb 20, 2017 at 11:23 AM, Noel Carboni < NCa...@pr...> wrote: > Hi Aaron, > > > > What do you mean by "applies the ICC profile"? Are you trying to convert > the image to be displayed accurately on a monitor? > > > > If so, wouldn't you want the output type to be RGB and use the monitor's > profile as the output profile? > > > > Perhaps I'm not understanding at all what you're trying to accomplish. > > > > -Noel > > > > > > *From:* Aaron Boxer [mailto:bo...@gm...] > *Sent:* Mon, February 20, 2017 1:04 AM > *To:* lcm...@li... > *Subject:* [Lcms-user] Apply profile with PCS = cmsSigXYZData, Color > Space = cmsSigGrayData > > > > Hello, > > > I have a jpeg 2000 file with an ICC profile. > > PCS is cmsSigXYZData and color space is cmsSigGrayData. > > The file can be found here: https://github.com/GrokImageCompression/grok/ > issues/38 > > I am working on a library that decodes the jpeg 2000 file and applies the > ICC profile, using LCMS. > > Currently, I have this code: > > in_type = TYPE_GRAY_8; > out_type = TYPE_RGB_8; > out_prof = cmsCreate_sRGBProfile(); > > and I can create the transform and apply the ICC profile, but the output > is an RGB file. > What I would like is to output a grayscale file. > > So, if I instead call > > out_prof = cmsCreateGrayProfile(NULL,NULL); > > then cmsCreateTransform returns NULL and I can't apply the profile. > > What is the best way of creating a transform for this kind of grayscale > image ? > > Thanks so much, > > Aaron > > > > > > > > ------------------------------------------------------------ > ------------------ > 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...> - 2017-02-20 17:01:46
|
Thanks, Noel. That is a good point. For TIFF, I can store the profile in the TIFF file, and avoid transforming. For other formats, such as PNG, I would need to transform. On Mon, Feb 20, 2017 at 11:49 AM, Noel Carboni < NCa...@pr...> wrote: > > Thanks, Noel. This is not for display on monitor. JPEG 2000 supports > embedded ICC profiles, and I am > > > trying to use the profile when decoding the image. > > > > I guess I'm still not clear: Why are you transforming the data into > another color space? > > > > If you're trying to decode it then save it as another kind of file (e.g., > .tiff or .jpg or something that can carry its own color profile tag), maybe > you should consider just maintaining the color profile it's already got. > > > > What I'm saying is that maybe you just want to decode the data, then save > the data in another file, and tag that file with the same profile the > JPEG2000 file started with, making no color transformation on the decoded > data at all. LittleCMS need not be involved with that. > > > > As Marti mentioned, if you DO want to transform the color values into a > different color space, you need to specify what that color space is. > > > > -Noel > > > |
|
From: Noel C. <NCa...@Pr...> - 2017-02-20 17:20:54
|
> For other formats, such as PNG, I would need to transform. I believe a PNG file can carry a color profile tag, but there are certainly formats that can't. Not to belabor this, but does your design specify what color space the data will be in if it saved in an image file format that does not carry a profile tag? There is no standard for what color space untagged images should be stored in. Because of the mix of computers in the world and the things that have been done in the past, you might meet expectations more of the time if you were save color images in the sRGB IEC61966-2.1 color space. Windows has been described as embracing "sRGB by default", for example. But that's up to you. If you are anticipating prompting the user for target color space information, then that could resolve the problem. -Noel From: Aaron Boxer [mailto:bo...@gm...] Sent: Mon, February 20, 2017 12:02 PM To: Noel Carboni Cc: lcm...@li... Subject: Re: [Lcms-user] Apply profile with PCS = cmsSigXYZData, Color Space = cmsSigGrayData Thanks, Noel. That is a good point. For TIFF, I can store the profile in the TIFF file, and avoid transforming. For other formats, such as PNG, I would need to transform. On Mon, Feb 20, 2017 at 11:49 AM, Noel Carboni <NCa...@pr...> wrote: > Thanks, Noel. This is not for display on monitor. JPEG 2000 supports embedded ICC profiles, and I am > trying to use the profile when decoding the image. I guess I'm still not clear: Why are you transforming the data into another color space? If you're trying to decode it then save it as another kind of file (e.g., .tiff or .jpg or something that can carry its own color profile tag), maybe you should consider just maintaining the color profile it's already got. What I'm saying is that maybe you just want to decode the data, then save the data in another file, and tag that file with the same profile the JPEG2000 file started with, making no color transformation on the decoded data at all. LittleCMS need not be involved with that. As Marti mentioned, if you DO want to transform the color values into a different color space, you need to specify what that color space is. -Noel |
|
From: Aaron B. <bo...@gm...> - 2017-02-20 17:58:37
|
Noel, do you know where I could find sample code to read/write ICC profiles for PNG format? Thanks, Aaron On Mon, Feb 20, 2017 at 12:20 PM, Noel Carboni < NCa...@pr...> wrote: > > For other formats, such as PNG, I would need to transform. > > > > I believe a PNG file can carry a color profile tag, but there are > certainly formats that can't. > > > > Not to belabor this, but does your design specify what color space the > data will be in if it saved in an image file format that does not carry a > profile tag? > > > > There is no standard for what color space untagged images should be stored > in. Because of the mix of computers in the world and the things that have > been done in the past, you might meet expectations more of the time if you > were save color images in the sRGB IEC61966-2.1 color space. Windows has > been described as embracing "sRGB by default", for example. But that's up > to you. > > > > If you are anticipating prompting the user for target color space > information, then that could resolve the problem. > > > > -Noel > > > > *From:* Aaron Boxer [mailto:bo...@gm...] > *Sent:* Mon, February 20, 2017 12:02 PM > *To:* Noel Carboni > *Cc:* lcm...@li... > *Subject:* Re: [Lcms-user] Apply profile with PCS = cmsSigXYZData, Color > Space = cmsSigGrayData > > > > Thanks, Noel. That is a good point. For TIFF, I can store the profile in > the TIFF file, and avoid transforming. > > For other formats, such as PNG, I would need to transform. > > > > On Mon, Feb 20, 2017 at 11:49 AM, Noel Carboni < > NCa...@pr...> wrote: > > > Thanks, Noel. This is not for display on monitor. JPEG 2000 supports > embedded ICC profiles, and I am > > > trying to use the profile when decoding the image. > > > > I guess I'm still not clear: Why are you transforming the data into > another color space? > > > > If you're trying to decode it then save it as another kind of file (e.g., > .tiff or .jpg or something that can carry its own color profile tag), maybe > you should consider just maintaining the color profile it's already got. > > > > What I'm saying is that maybe you just want to decode the data, then save > the data in another file, and tag that file with the same profile the > JPEG2000 file started with, making no color transformation on the decoded > data at all. LittleCMS need not be involved with that. > > > > As Marti mentioned, if you DO want to transform the color values into a > different color space, you need to specify what that color space is. > > > > -Noel > > > > > |
|
From: Martí M. <mar...@li...> - 2017-02-20 16:29:05
|
Hi, You need to specify white point and transfer function to cmsCreateGrayProfile(), see manual page 28 Regards Marti On 20/02/2017 7:04, Aaron Boxer wrote: > Hello, > > I have a jpeg 2000 file with an ICC profile. > > PCS is cmsSigXYZData and color space is cmsSigGrayData. > > The file can be found here: > https://github.com/GrokImageCompression/grok/issues/38 > > I am working on a library that decodes the jpeg 2000 file and applies > the ICC profile, using LCMS. > > Currently, I have this code: > > in_type = TYPE_GRAY_8; > out_type = TYPE_RGB_8; > out_prof = cmsCreate_sRGBProfile(); > > and I can create the transform and apply the ICC profile, but the > output is an RGB file. > What I would like is to output a grayscale file. > > So, if I instead call > > out_prof = cmsCreateGrayProfile(NULL,NULL); > > then cmsCreateTransform returns NULL and I can't apply the profile. > > > What is the best way of creating a transform for this kind of > grayscale image ? > > Thanks so much, > Aaron > > > > > > > > > ------------------------------------------------------------------------------ > 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: Martí M. <mar...@li...> - 2017-02-20 16:56:32
|
Hi,
>Thanks, Marti. Is the white point and transfer function not already
specified in the profile? Pardon my ignorance,
>not that familiar with colour transforms.
No worries, if you use a real profile, yes, it is included in the
profile. If you use a built-in profile, that is a template to generate
profiles, so you need parameters.
Try this:
// A gamma-2.2 gray space
static
cmsHPROFILE Create_Gray22(void)
{
cmsHPROFILE hProfile;
cmsToneCurve* Curve = cmsBuildGamma(DbgThread(), 2.2);
if (Curve == NULL) return NULL;
hProfile = cmsCreateGrayProfileTHR(DbgThread(), cmsD50_xyY(), Curve);
cmsFreeToneCurve(Curve);
return hProfile;
}
Regards
Marti
On 20/02/2017 17:33, Aaron Boxer wrote:
> Thanks, Marti. Is the white point and transfer function not already
> specified in the profile? Pardon my ignorance,
> not that familiar with colour transforms.
>
> On Mon, Feb 20, 2017 at 11:28 AM, Martí Maria
> <mar...@li... <mailto:mar...@li...>> wrote:
>
>
> Hi,
>
> You need to specify white point and transfer function to
> cmsCreateGrayProfile(), see manual page 28
>
> Regards
>
> Marti
>
> On 20/02/2017 7:04, Aaron Boxer wrote:
>> Hello,
>>
>> I have a jpeg 2000 file with an ICC profile.
>>
>> PCS is cmsSigXYZData and color space is cmsSigGrayData.
>>
>> The file can be found here:
>> https://github.com/GrokImageCompression/grok/issues/38
>> <https://github.com/GrokImageCompression/grok/issues/38>
>>
>> I am working on a library that decodes the jpeg 2000 file and
>> applies the ICC profile, using LCMS.
>>
>> Currently, I have this code:
>>
>> in_type = TYPE_GRAY_8;
>> out_type = TYPE_RGB_8;
>> out_prof = cmsCreate_sRGBProfile();
>>
>> and I can create the transform and apply the ICC profile, but the
>> output is an RGB file.
>> What I would like is to output a grayscale file.
>>
>> So, if I instead call
>>
>> out_prof = cmsCreateGrayProfile(NULL,NULL);
>>
>> then cmsCreateTransform returns NULL and I can't apply the profile.
>>
>>
>> What is the best way of creating a transform for this kind of
>> grayscale image ?
>>
>> Thanks so much,
>> Aaron
>>
>>
>>
>>
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> 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...
>> <mailto:Lcm...@li...>
>> https://lists.sourceforge.net/lists/listinfo/lcms-user
>> <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...
> <mailto:Lcm...@li...>
> https://lists.sourceforge.net/lists/listinfo/lcms-user
> <https://lists.sourceforge.net/lists/listinfo/lcms-user>
>
|
|
From: Aaron B. <bo...@gm...> - 2017-02-20 17:02:56
|
On Mon, Feb 20, 2017 at 11:56 AM, Martí Maria <mar...@li...>
wrote:
>
> Hi,
> >Thanks, Marti. Is the white point and transfer function not already
> specified in the profile? Pardon my ignorance,
> >not that familiar with colour transforms.
>
>
> No worries, if you use a real profile, yes, it is included in the profile.
> If you use a built-in profile, that is a template to generate profiles, so
> you need parameters.
>
May I ask what you mean by "real profile" ? Thanks for the code below, I
will try it out, but would the original profile contain information on
gamma and white point ?
Thanks,
Aaron
> Try this:
> // A gamma-2.2 gray space
> static
> cmsHPROFILE Create_Gray22(void)
> {
> cmsHPROFILE hProfile;
> cmsToneCurve* Curve = cmsBuildGamma(DbgThread(), 2.2);
> if (Curve == NULL) return NULL;
>
> hProfile = cmsCreateGrayProfileTHR(DbgThread(), cmsD50_xyY(), Curve);
> cmsFreeToneCurve(Curve);
>
> return hProfile;
> }
>
> Regards
>
> Marti
>
>
> On 20/02/2017 17:33, Aaron Boxer wrote:
>
> Thanks, Marti. Is the white point and transfer function not already
> specified in the profile? Pardon my ignorance,
> not that familiar with colour transforms.
>
> On Mon, Feb 20, 2017 at 11:28 AM, Martí Maria <mar...@li...>
> wrote:
>
>>
>> Hi,
>>
>> You need to specify white point and transfer function to
>> cmsCreateGrayProfile(), see manual page 28
>>
>> Regards
>>
>> Marti
>> On 20/02/2017 7:04, Aaron Boxer wrote:
>>
>> Hello,
>>
>> I have a jpeg 2000 file with an ICC profile.
>>
>> PCS is cmsSigXYZData and color space is cmsSigGrayData.
>>
>> The file can be found here: https://github.com/GrokImageCo
>> mpression/grok/issues/38
>>
>> I am working on a library that decodes the jpeg 2000 file and applies the
>> ICC profile, using LCMS.
>>
>> Currently, I have this code:
>>
>> in_type = TYPE_GRAY_8;
>> out_type = TYPE_RGB_8;
>> out_prof = cmsCreate_sRGBProfile();
>>
>> and I can create the transform and apply the ICC profile, but the output
>> is an RGB file.
>> What I would like is to output a grayscale file.
>>
>> So, if I instead call
>>
>> out_prof = cmsCreateGrayProfile(NULL,NULL);
>>
>> then cmsCreateTransform returns NULL and I can't apply the profile.
>>
>>
>> What is the best way of creating a transform for this kind of grayscale
>> image ?
>>
>> Thanks so much,
>> Aaron
>>
>>
>>
>>
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> 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...://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: Martí M. <mar...@li...> - 2017-02-20 17:05:05
|
Hi,
I just C&P from testbed, sorry.
A portable function should be like this:
static
cmsHPROFILE Create_Gray22(void)
{
cmsHPROFILE hProfile;
cmsToneCurve* Curve = cmsBuildGamma(0, 2.2);
if (Curve == NULL) return NULL;
hProfile = cmsCreateGrayProfileTHR(0, cmsD50_xyY(), Curve);
cmsFreeToneCurve(Curve);
return hProfile;
}
Regards
Marti
>
> On 20/02/2017 17:33, Aaron Boxer wrote:
>> Thanks, Marti. Is the white point and transfer function not already
>> specified in the profile? Pardon my ignorance,
>> not that familiar with colour transforms.
>>
>> On Mon, Feb 20, 2017 at 11:28 AM, Martí Maria
>> <mar...@li... <mailto:mar...@li...>> wrote:
>>
>>
>> Hi,
>>
>> You need to specify white point and transfer function to
>> cmsCreateGrayProfile(), see manual page 28
>>
>> Regards
>>
>> Marti
>>
>> On 20/02/2017 7:04, Aaron Boxer wrote:
>>> Hello,
>>>
>>> I have a jpeg 2000 file with an ICC profile.
>>>
>>> PCS is cmsSigXYZData and color space is cmsSigGrayData.
>>>
>>> The file can be found here:
>>> https://github.com/GrokImageCompression/grok/issues/38
>>> <https://github.com/GrokImageCompression/grok/issues/38>
>>>
>>> I am working on a library that decodes the jpeg 2000 file and
>>> applies the ICC profile, using LCMS.
>>>
>>> Currently, I have this code:
>>>
>>> in_type = TYPE_GRAY_8;
>>> out_type = TYPE_RGB_8;
>>> out_prof = cmsCreate_sRGBProfile();
>>>
>>> and I can create the transform and apply the ICC profile, but
>>> the output is an RGB file.
>>> What I would like is to output a grayscale file.
>>>
>>> So, if I instead call
>>>
>>> out_prof = cmsCreateGrayProfile(NULL,NULL);
>>>
>>> then cmsCreateTransform returns NULL and I can't apply the profile.
>>>
>>>
>>> What is the best way of creating a transform for this kind of
>>> grayscale image ?
>>>
>>> Thanks so much,
>>> Aaron
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> 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...
>>> <mailto:Lcm...@li...>
>>> https://lists.sourceforge.net/lists/listinfo/lcms-user
>>> <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...
>> <mailto:Lcm...@li...>
>> https://lists.sourceforge.net/lists/listinfo/lcms-user
>> <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: Aaron B. <bo...@gm...> - 2017-02-20 17:50:01
|
Thanks very much, Marti. Colour spaces are quite interesting!
I will play around with this code.
On Mon, Feb 20, 2017 at 12:04 PM, Martí Maria <mar...@li...>
wrote:
>
> Hi,
>
> I just C&P from testbed, sorry.
>
> A portable function should be like this:
>
> static
> cmsHPROFILE Create_Gray22(void)
> {
> cmsHPROFILE hProfile;
> cmsToneCurve* Curve = cmsBuildGamma(0, 2.2);
> if (Curve == NULL) return NULL;
>
> hProfile = cmsCreateGrayProfileTHR(0, cmsD50_xyY(), Curve);
> cmsFreeToneCurve(Curve);
>
> return hProfile;
> }
> Regards
> Marti
>
>
>
> On 20/02/2017 17:33, Aaron Boxer wrote:
>
> Thanks, Marti. Is the white point and transfer function not already
> specified in the profile? Pardon my ignorance,
> not that familiar with colour transforms.
>
> On Mon, Feb 20, 2017 at 11:28 AM, Martí Maria <mar...@li...>
> wrote:
>
>>
>> Hi,
>>
>> You need to specify white point and transfer function to
>> cmsCreateGrayProfile(), see manual page 28
>>
>> Regards
>>
>> Marti
>> On 20/02/2017 7:04, Aaron Boxer wrote:
>>
>> Hello,
>>
>> I have a jpeg 2000 file with an ICC profile.
>>
>> PCS is cmsSigXYZData and color space is cmsSigGrayData.
>>
>> The file can be found here: https://github.com/GrokImageCo
>> mpression/grok/issues/38
>>
>> I am working on a library that decodes the jpeg 2000 file and applies the
>> ICC profile, using LCMS.
>>
>> Currently, I have this code:
>>
>> in_type = TYPE_GRAY_8;
>> out_type = TYPE_RGB_8;
>> out_prof = cmsCreate_sRGBProfile();
>>
>> and I can create the transform and apply the ICC profile, but the output
>> is an RGB file.
>> What I would like is to output a grayscale file.
>>
>> So, if I instead call
>>
>> out_prof = cmsCreateGrayProfile(NULL,NULL);
>>
>> then cmsCreateTransform returns NULL and I can't apply the profile.
>>
>>
>> What is the best way of creating a transform for this kind of grayscale
>> image ?
>>
>> Thanks so much,
>> Aaron
>>
>>
>>
>>
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> 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...://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
>
> ------------------------------------------------------------------------------
> 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...://lists.sourceforge.net/lists/listinfo/lcms-user
>
>
|
|
From: Noel C. <NCa...@Pr...> - 2017-02-20 17:34:52
|
Oh, and one more thing I meant to mention... A tone curve with a pure 2.2 gamma function is very different than an sRGB tone curve where it really counts - down in the small values (near black). Just thought I'd throw that out there as food for thought. -Noel |
|
From: Aaron B. <bo...@gm...> - 2017-02-20 17:53:07
|
Noel, thank you! I am beginning to understand. Currently, in my design, the user cannot specify the colour space that they will save the data in. I think this needs to be implemented. Currently, we always assume sRGB. But, for grayscale, this may not be the best approach, as you mentioned. Following your suggestion, for TIFF, I am now simply storing the ICC information in the TIFF file and NOT applying a transform. I will also look into doing this for PNG. For other formats, I will need to allow the user to specify the gamma and white point, I suppose. On Mon, Feb 20, 2017 at 12:34 PM, Noel Carboni < NCa...@pr...> wrote: > Oh, and one more thing I meant to mention... > > > > A tone curve with a pure 2.2 gamma function is very different than an sRGB > tone curve where it really counts - down in the small values (near black). > > > > Just thought I'd throw that out there as food for thought. > > > > -Noel > |
|
From: Noel C. <NCa...@Pr...> - 2017-02-20 19:02:51
|
>Noel, do you know where I could find sample code to read/write ICC profiles for PNG format? Sorry, I really don't, offhand. I'd probably rely heavy on Google for that. -Noel |
|
From: Marco F. <Mar...@en...> - 2017-02-21 08:02:55
|
Aaron, I might be able to help a little. You need to write the iCCP chunk. Also make sure you have no conflicting entries in other chunks (sRGB, gAMA, cHRM chunk). PNG is a bit delicate in terms of possible ambiguous color space info in header. You also need to know, that some PNG readers don’t handle the color space chucks gracefully (specifically gAMA, cHRM – even Photoshop is clunky in that aspect, at least if no iCCP chunk is present). Do you use libpng ? If so, you need to do call png_set_iCCP() during your file creation to write the ICC profile. Marco Von: Noel Carboni [mailto:NCa...@Pr...] Gesendet: Montag, 20. Februar 2017 13:03 An: 'Aaron Boxer' Cc: lcm...@li... Betreff: Re: [Lcms-user] Apply profile with PCS = cmsSigXYZData, Color Space = cmsSigGrayData >Noel, do you know where I could find sample code to read/write ICC profiles for PNG format? Sorry, I really don't, offhand. I'd probably rely heavy on Google for that. -Noel |
|
From: Aaron B. <bo...@gm...> - 2017-02-21 13:34:05
|
Hi Marco, Thanks a lot! Would you be able to take a quick look at my changes ? Commit is here: https://github.com/GrokImageCompression/grok/commit/8d62e2252fefd4a15124cac73c7f47a65fde651d and complete file is here: https://github.com/GrokImageCompression/grok/blob/master/src/bin/jp2/convertpng.cpp Existing code already had some code for gamma curve, so perhaps I need to disable that? Cheers, Aaron On Tue, Feb 21, 2017 at 2:28 AM, Marco Freudenberger < Mar...@en...> wrote: > Aaron, > > > > I might be able to help a little. > > > > You need to write the iCCP chunk. Also make sure you have no conflicting > entries in other chunks (sRGB, gAMA, cHRM chunk). PNG is a bit delicate in > terms of possible ambiguous color space info in header. > > You also need to know, that some PNG readers don’t handle the color space > chucks gracefully (specifically gAMA, cHRM – even Photoshop is clunky in > that aspect, at least if no iCCP chunk is present). > > > > Do you use libpng ? If so, you need to do call > > png_set_iCCP() > > during your file creation to write the ICC profile. > > > > Marco > > > > *Von:* Noel Carboni [mailto:NCa...@Pr...] > *Gesendet:* Montag, 20. Februar 2017 13:03 > *An:* 'Aaron Boxer' > *Cc:* lcm...@li... > *Betreff:* Re: [Lcms-user] Apply profile with PCS = cmsSigXYZData, Color > Space = cmsSigGrayData > > > > >Noel, do you know where I could find sample code to read/write ICC > profiles for PNG format? > > Sorry, I really don't, offhand. I'd probably rely heavy on Google for > that. > > > > -Noel > > > |
|
From: Aaron B. <bo...@gm...> - 2017-02-21 18:00:05
|
Marco, Thanks so much for the code review, really appreciate the level of detail in your posts. It will take me some time to digest this information. One question - you mention that my current PNG reader might "creates issues if the file have “correct” embedded gAMA of 1/2.2 or something even better." Do you mean that the ICC profile may have a better gAMA than 1 ? In this case, if there is an ICC profile, I suppose I should not set gAMA, yes? Side note - one of the applications for my library is in medical imaging, CT scans etc. where I understand there is no need for a gamma curve. Thanks again, Aaron On Tue, Feb 21, 2017 at 11:51 AM, Marco Freudenberger < Mar...@en...> wrote: > Oh, and Aaron: > > > > I just saw you are setting compression to Z_BEST_COMPRESSION (9). That is > probably not a good idea either, because it can be REALLY slow with little > or none advantage in regards to the resulting file size. But that depends > on your application as well, if you rarely write images and they are > targeting the web, it MIGHT be the right thing to do. Although – I did > tests with some images and found that many times lower compression rates > even give you smaller file sizes. I ended up with using level 3, which is > ways faster and not really much worse, But that may really depend on the > images and perhaps on more detailed compression settings like compression > buffer sizes (of which libpng specification basically says “leave them > alone unless you know exactly what you are doing” – I didn’t so I left them > at defaults). > > > > Marco > > > > > > *Von:* Marco Freudenberger > *Gesendet:* Dienstag, 21. Februar 2017 10:45 > *An:* 'Aaron Boxer' > *Cc:* Noel Carboni; lcm...@li... > *Betreff:* AW: [Lcms-user] Apply profile with PCS = cmsSigXYZData, Color > Space = cmsSigGrayData > > > > > > Just something „cosmetic“: > > 1) I would set parameter 4 to PNG_COMPRESSION_TYPE_BASE rather than > 0 (same value, just more obvious what it means). > > 2) I would try to extract the ICC profile name from the profile > using lcms API (don’t remember how off the top of my head) and supply it as > parameter 3. > > Both are not required, just my love for detail… > > > > In regards to gAMA: I don’t see anything in the code that is writing the > image that actually deals with gAMA. However, there are a view things in > the image READ part regarding gama that make me wonder > > > > 1) The code assumes the gamma is 1.0 when there is no gAMA chunk > present. That is, what some image readers do, but I think this is really > bad practice, because according to the PNG specification you should use the > most likely gAMA of the system writing it. That would normally be either > ~2.2 or 1.8 (the latter if it was written by an old MAC OS). > > 2) Then you use png_set_gamma() to set the SCREEN gamma to 1.0; My > guess it that it’s extremely unlikely that the screen gamma is 1.0; it is > more likely ~2.2 (or 1.8 on old MACs), see above. This basically “fixes” > your assumption of file gamma of 1/1.0, but also creates issues if the file > have “correct” embedded gAMA of 1/2.2 or something even better. Also, I > think png_set_gamma() will “correct” the actual RGB or gray or whatever > values, in 8 bit mode, that means you might lose color precision… > Note that it’s a total misconception that a gamma value of 1.0 is a good > “neutral” or “default” value. For example, when reading files like BMP or > GIF or such without gamma information, you should – if you don’t know > better – that it has the same gamma as your screen, which is “nominally” > either sRGB gamma (~2.2) or 2.2. > > > > There are other things I saw, but it depends on how “serious” you are > about color management. Unfortunately, PNG is a bit complicated because the > specification wanted to make it “all right” and some applications do things > not according to the standard. > > > > 3) You seem to ignore the sRGB chunk, which – if present – > explicitely says an image is in sRGB color space. In that case, gamma = > sRGB gamma (~2.2) > > 4) You ignore the cHRM chunks. Depending on what level of color > management you want to achieve, it CAN be important to evaluate them > (chroma values are a “simplified way” to define a color space). Although, > they are rarely used. Applications that are serious about color management > usually embed ICC profiles in the image. > > 5) Depending on what version of libpng you are using – libpng > internally “explicitely” skips reading one specific sRGB profile > (identified I think by it’s length and name, don’t remember the details) > because the original author states that’s a “known bad” profile. I think it > is actually just a little bit inprecise. Unfortunately, that profile is > wide spread, and what libpng does – totally skipping the profile, leaving > you with no color information at all – is highly controversial, because it > leaves you behind without ANY color space information, although the intent > is that it should be sRGB. There is a configuration to turn that off: > > png_set_option(png, PNG_SKIP_sRGB_CHECK_PROFILE, PNG_OPTION_ON); // > turn “ON” skipping the check for an sRGB profile that is “wrong” in the > libpng author’s opinion -> i.e. allow that profile. > > > > Having that all said, I don’t really know what your exact use case is, > maybe all the above is “nitpicking” when it comes to your use case, but if > you are serious about color management, you should really try to have all > those things (and some more in regards to PNG) right, otherwise you might > be contributing to a lot of issues with the PNG format that are already > “out there”. An ambigious rule in the first version of the PNG > specification (I don’t remember what it was about) makes it even worse. I > think it took me ~2 weeks to fully handle all those cases, but my > application was really a high-precision color management application with > tons of images from different sources from customers. > > Many different applications handle PNG VERY differently unfortunately > (most of them wrong, even Photoshop, the reference app for color management > most of the time does some things about gAMA wrong) and the only way to > avoid any “customer specific maintenance” was to really make sure to go > 100% by the PNG specification and tell customers that THEIR IMAGES might > not be according to the standard. > > > > Marco > > > > > > *Von:* Aaron Boxer [mailto:bo...@gm... <bo...@gm...>] > *Gesendet:* Dienstag, 21. Februar 2017 07:34 > *An:* Marco Freudenberger > *Cc:* Noel Carboni; lcm...@li... > > *Betreff:* Re: [Lcms-user] Apply profile with PCS = cmsSigXYZData, Color > Space = cmsSigGrayData > > > > Hi Marco, > > Thanks a lot! Would you be able to take a quick look at my changes ? > > Commit is here: > > https://github.com/GrokImageCompression/grok/commit/ > 8d62e2252fefd4a15124cac73c7f47a65fde651d > > and complete file is here: > > https://github.com/GrokImageCompression/grok/blob/master/src/bin/jp2/ > convertpng.cpp > > Existing code already had some code for gamma curve, so perhaps I need to > disable that? > > Cheers, > > Aaron > > > > > > On Tue, Feb 21, 2017 at 2:28 AM, Marco Freudenberger <Marco.Freudenberger@ > entrustdatacard.com> wrote: > > Aaron, > > > > I might be able to help a little. > > > > You need to write the iCCP chunk. Also make sure you have no conflicting > entries in other chunks (sRGB, gAMA, cHRM chunk). PNG is a bit delicate in > terms of possible ambiguous color space info in header. > > You also need to know, that some PNG readers don’t handle the color space > chucks gracefully (specifically gAMA, cHRM – even Photoshop is clunky in > that aspect, at least if no iCCP chunk is present). > > > > Do you use libpng ? If so, you need to do call > > png_set_iCCP() > > during your file creation to write the ICC profile. > > > > Marco > > > > *Von:* Noel Carboni [mailto:NCa...@Pr...] > *Gesendet:* Montag, 20. Februar 2017 13:03 > *An:* 'Aaron Boxer' > *Cc:* lcm...@li... > *Betreff:* Re: [Lcms-user] Apply profile with PCS = cmsSigXYZData, Color > Space = cmsSigGrayData > > > > >Noel, do you know where I could find sample code to read/write ICC > profiles for PNG format? > > Sorry, I really don't, offhand. I'd probably rely heavy on Google for > that. > > > > -Noel > > > > > |
|
From: Aaron B. <bo...@gm...> - 2017-02-21 18:59:35
|
> > On Tue, Feb 21, 2017 at 1:15 PM, Marco Freudenberger <Marco.Freudenberger@ > entrustdatacard.com> wrote: > >> No. I’m actually talking about images that do not have an ICC profile >> embedded. Well – maybe all, actually. >> >> >> >> Lines 187-191: >> >> >> >> if( !png_get_gAMA(png, info, &gamma)) >> >> gamma = 1.0; >> >> >> >> /* we're not displaying but converting, screen gamma == 1.0 */ >> >> png_set_gamma(png, 1.0, gamma); >> >> >> >> >> >> >> >> >> >> - You try to read the file gamma. If none found, you set it to >> 1.0. That I think is the first mistake… >> >> - Then you set the screen gamma to 1.0. This is PROBABLY the >> next mistake, as the typical screen gamma is ~ 2.2. Linear gamma is >> unusual. The two “mistakes” might eliminate each other for images with NO >> gAMA chunk (because no correction is done for the screen). >> >> - I think png_set_gamma actually makes sure that the RGB (or >> gray …) values you are getting from the file are adjusted by (file gamma) / >> (screen gamma) – so you are not reading the values originally encoded in >> the file... I might be wrong, I didn’t check the documentation. >> >> So … >> >> - If the file has an embedded gamma of 2.2, you would modify >> the values because the “screen gamma” is set to 1.0 >> >> > Thanks. I tried using 2.2 and it broke a lot of my unit tests. I guess > allowing the user to set the gamma would be best - can blame the user if > something goes wrong :) > >> >> > > >> Another big problem is, that this seems to be applied EVEN THOUGH an ICC >> profile might be embedded in the file, which already does any file color >> space -> screen color space for you. So if you have a file gamma AND an ICC >> profile, you might change values (especially “light intensity” of colors) >> while actually the ICC profile does all of that. >> >> IF you want to use the file gamma to correct images when displaying them >> (or converting to another ICC profile), you should rather generate an “on >> the fly” icc profile based on the file gamma (and given (cHRM chunk) or >> assumed chromatic primaries rather than having libpng modifying the values >> you read for you. This is often an area of confusion with libpng ... I hope >> I expressed that all in a way that it can be understood… I’m not a English >> is not my mothers tongue and I tend to make technical descriptions >> extremely complicated … >> > > Thanks, your writing is crystal clear - just a lot of detail to think > over. I have changed my code so that gamma is only applied if there is no > ICC. > > Best, > Aaron > |
|
From: Marco F. <Mar...@en...> - 2017-02-21 21:07:23
|
PS: A lot of the reaction of course also depend on how you handle the image data once loaded – and obviously what your expected unit test results are. I’ve tried to implement a full “image handling” library a while ago (a layer up from libpng, tiff, …) , when I found that most higher level open source library don’t do a very good job with color management in my opinion, at least not the ones I’ve tested. Unfortunately I didn’t have the time yet to finish it or get it to a point where it is really useful for others, especially the “build system” is more than clunky (I wanted to create cmake environment, so that it is easy to use it cross platform … ) and the unit tests are more manual test entry points than real unit tests at this time. Again haven’t got a lot of time to work on that as it’s a private project and I’m currently loaded with job-work, but if I remember correctly, the PNG READ handling should be OK to some extent. If I also remember correctly, the code to write PNG files is not checked in as I haven’t validated it’s correctness for all color formats and bit depths. The library Itself doesn’t do a lot “upstream” with the image files, although I think the (more manual …) test code had some color space conversion examples, especially like “convert everything to sRGB” if I remember correctly. https://github.com/freudi74/mfimage Hope that helps more than adding more confusion… Marco Von: Marco Freudenberger Gesendet: Dienstag, 21. Februar 2017 14:51 An: 'Aaron Boxer' Cc: Noel Carboni; lcm...@li... Betreff: AW: [Lcms-user] Apply profile with PCS = cmsSigXYZData, Color Space = cmsSigGrayData Well, if you set BOTH gammas to 2.2, it should work. What test cases do you have and what are the expected results? Von: Aaron Boxer [mailto:bo...@gm...] Gesendet: Dienstag, 21. Februar 2017 12:58 An: Marco Freudenberger Cc: Noel Carboni; lcm...@li... Betreff: Re: [Lcms-user] Apply profile with PCS = cmsSigXYZData, Color Space = cmsSigGrayData On Tue, Feb 21, 2017 at 1:15 PM, Marco Freudenberger <Mar...@en...<mailto:Mar...@en...>> wrote: No. I’m actually talking about images that do not have an ICC profile embedded. Well – maybe all, actually. Lines 187-191: if( !png_get_gAMA(png, info, &gamma)) gamma = 1.0; /* we're not displaying but converting, screen gamma == 1.0 */ png_set_gamma(png, 1.0, gamma); - You try to read the file gamma. If none found, you set it to 1.0. That I think is the first mistake… - Then you set the screen gamma to 1.0. This is PROBABLY the next mistake, as the typical screen gamma is ~ 2.2. Linear gamma is unusual. The two “mistakes” might eliminate each other for images with NO gAMA chunk (because no correction is done for the screen). - I think png_set_gamma actually makes sure that the RGB (or gray …) values you are getting from the file are adjusted by (file gamma) / (screen gamma) – so you are not reading the values originally encoded in the file... I might be wrong, I didn’t check the documentation. So … - If the file has an embedded gamma of 2.2, you would modify the values because the “screen gamma” is set to 1.0 Thanks. I tried using 2.2 and it broke a lot of my unit tests. I guess allowing the user to set the gamma would be best - can blame the user if something goes wrong :) Another big problem is, that this seems to be applied EVEN THOUGH an ICC profile might be embedded in the file, which already does any file color space -> screen color space for you. So if you have a file gamma AND an ICC profile, you might change values (especially “light intensity” of colors) while actually the ICC profile does all of that. IF you want to use the file gamma to correct images when displaying them (or converting to another ICC profile), you should rather generate an “on the fly” icc profile based on the file gamma (and given (cHRM chunk) or assumed chromatic primaries rather than having libpng modifying the values you read for you. This is often an area of confusion with libpng ... I hope I expressed that all in a way that it can be understood… I’m not a English is not my mothers tongue and I tend to make technical descriptions extremely complicated … Thanks, your writing is crystal clear - just a lot of detail to think over. I have changed my code so that gamma is only applied if there is no ICC. Best, Aaron |
|
From: Aaron B. <bo...@gm...> - 2017-02-22 15:15:03
|
On Tue, Feb 21, 2017 at 4:07 PM, Marco Freudenberger < Mar...@en...> wrote: > PS: A lot of the reaction of course also depend on how you handle the > image data once loaded – and obviously what your expected unit test results > are. > > > > I’ve tried to implement a full “image handling” library a while ago (a > layer up from libpng, tiff, …) , when I found that most higher level open > source library don’t do a very good job with color management in my > opinion, at least not the ones I’ve tested. Unfortunately I didn’t have the > time yet to finish it or get it to a point where it is really useful for > others, especially the “build system” is more than clunky (I wanted to > create cmake environment, so that it is easy to use it cross platform … ) > and the unit tests are more manual test entry points than real unit tests > at this time. Again haven’t got a lot of time to work on that as it’s a > private project and I’m currently loaded with job-work, but if I remember > correctly, the PNG READ handling should be OK to some extent. If I also > remember correctly, the code to write PNG files is not checked in as I > haven’t validated it’s correctness for all color formats and bit depths. > > > > The library Itself doesn’t do a lot “upstream” with the image files, > although I think the (more manual …) test code had some color space > conversion examples, especially like “convert everything to sRGB” if I > remember correctly. > > > > https://github.com/freudi74/mfimage > Cool project! Thanks for sharing this. > > *Von:* Marco Freudenberger > *Gesendet:* Dienstag, 21. Februar 2017 14:51 > *An:* 'Aaron Boxer' > *Cc:* Noel Carboni; lcm...@li... > *Betreff:* AW: [Lcms-user] Apply profile with PCS = cmsSigXYZData, Color > Space = cmsSigGrayData > > > > Well, if you set BOTH gammas to 2.2, it should work. > > > > What test cases do you have and what are the expected results? > > > > *Von:* Aaron Boxer [mailto:bo...@gm...] > *Gesendet:* Dienstag, 21. Februar 2017 12:58 > *An:* Marco Freudenberger > *Cc:* Noel Carboni; lcm...@li... > *Betreff:* Re: [Lcms-user] Apply profile with PCS = cmsSigXYZData, Color > Space = cmsSigGrayData > > > > > > > > On Tue, Feb 21, 2017 at 1:15 PM, Marco Freudenberger <Marco.Freudenberger@ > entrustdatacard.com> wrote: > > No. I’m actually talking about images that do not have an ICC profile > embedded. Well – maybe all, actually. > > > > Lines 187-191: > > > > if( !png_get_gAMA(png, info, &gamma)) > > > > gamma = 1.0; > > > > > > /* we're not displaying but converting, screen gamma == 1.0 */ > > png_set_gamma(png, 1.0, gamma); > > > > > > > > > > - You try to read the file gamma. If none found, you set it to > 1.0. That I think is the first mistake… > > - Then you set the screen gamma to 1.0. This is PROBABLY the > next mistake, as the typical screen gamma is ~ 2.2. Linear gamma is > unusual. The two “mistakes” might eliminate each other for images with NO > gAMA chunk (because no correction is done for the screen). > > - I think png_set_gamma actually makes sure that the RGB (or > gray …) values you are getting from the file are adjusted by (file gamma) / > (screen gamma) – so you are not reading the values originally encoded in > the file... I might be wrong, I didn’t check the documentation. > > So … > > - If the file has an embedded gamma of 2.2, you would modify the > values because the “screen gamma” is set to 1.0 > > > > Thanks. I tried using 2.2 and it broke a lot of my unit tests. I guess > allowing the user to set the gamma would be best - can blame the user if > something goes wrong :) > > > > > > Another big problem is, that this seems to be applied EVEN THOUGH an ICC > profile might be embedded in the file, which already does any file color > space -> screen color space for you. So if you have a file gamma AND an ICC > profile, you might change values (especially “light intensity” of colors) > while actually the ICC profile does all of that. > > IF you want to use the file gamma to correct images when displaying them > (or converting to another ICC profile), you should rather generate an “on > the fly” icc profile based on the file gamma (and given (cHRM chunk) or > assumed chromatic primaries rather than having libpng modifying the values > you read for you. This is often an area of confusion with libpng ... I hope > I expressed that all in a way that it can be understood… I’m not a English > is not my mothers tongue and I tend to make technical descriptions > extremely complicated … > > > > Thanks, your writing is crystal clear - just a lot of detail to think > over. I have changed my code so that gamma is only applied if there is no > ICC. > > > > Best, > > Aaron > |
|
From: Aaron B. <bo...@gm...> - 2017-02-22 15:16:03
|
On Tue, Feb 21, 2017 at 3:51 PM, Marco Freudenberger <Marco.Freudenberger@ entrustdatacard.com> wrote: > Well, if you set BOTH gammas to 2.2, it should work. > > > > What test cases do you have and what are the expected results? > Unit tests compare decoded image with reference image, which were probably decoded with gamma=1.0 configuration. > >> > > |