Thread: [Lcms-user] How does a transformation work
An ICC-based CMM for color management
Brought to you by:
mm2
From: flap <fb...@oh...> - 2023-12-29 11:06:08
|
Hi list, what I want: an 8 bit grey-scale output for my printer, where the input dot values (0 … 255) are scaled and limited to values of 40 … 240 (…just an example). So I created a simple test input data (256 elements of unsigned char) with a linear ramp from 0 (at index 0) … 255 (at index 255). And I created an array with 4096 short entries beginning with 40 (* 256 for unsigned short) and ramp up linear to 240 (* 256 for unsigned short) and feed it into cmsBuildTabulatedToneCurve16() and cmsCreateGrayProfile() with cmsD50_xyY() as its whitepoint (for the output profile). For the input profile I used cmsBuildGamma() with a value of 1.0 and cmsCreateGrayProfile() with cmsD50_xyY(). After creating the transformation with cmsCreateTransform() with input/output types both TYPE_GRAY_8 and an intent of INTENT_PERCEPTUAL and applying this transformation with cmsDoTransformLineStride () to my simple input data, the output result is still almost linear from 0 to 255 and not limited to 40 … 240. So, I think I'm using the tone curves in a wrong way. But where is my mistake? Cheers, Jürgen |
From: flap <fb...@oh...> - 2023-12-29 13:21:30
|
Am Freitag, 29. Dezember 2023, 14:01:40 CET schrieb mar...@li...: > Hi, > > From your explanation, it seems to me that the transformation you want has nothing to do with color management. You > know nothing about the L* of your grayscale and need only some scaling. I would rather use simple math in this case: > > Gray_out = (Gray_in * 40) /51 + 40; > > You could just use a for() loop. This is going to be faster that using any color management routines. Hmm. It just was a test to understand how it (may) works. The profile I create is used in the muPDF library to create a greyscale out from a PDF document. I would expect, any kind of PDF could be rasterized into a greyscale raster this way. Cheers, Jürgen |
From: <mar...@li...> - 2023-12-29 14:21:17
|
Ok, The procedure to create a gray profile is simple. First measure the transfer function of your gray device to XYZ. That could be a gamma curve or anything. Then measure the white point of your gray space. The adaptation to D50 is already done by lcms. Then create a tone curve with your transfer function. Finally, by using white point and curve, create a profile. Please note you cannot map contone values for input to output since the output profile is unknown. So, you cannot map 0 to 40 and 255 to 240. You can only characterize which XYZ you get with gray = 0 and gray = 255. Example: cmsToneCurve* tone; cmsUInt16Number curve[256]; int i; cmsHPROFILE hProfile; for (i = 0; i < 256; i++) { curve[i] = (cmsUInt16Number) round(65535.0 * pow(i / 255.0, 2.2)); } tone = cmsBuildTabulatedToneCurve16(0, 256, curve); hProfile = cmsCreateGrayProfile(cmsD50_xyY(), tone); cmsFreeToneCurve(tone); cmsSaveProfileToFile(hProfile, "gray_test.icc"); cmsCloseProfile(hProfile); Regards Marti Maria The LittleCMS Project https://www.littlecms.com > -----Original Message----- > From: flap <fb...@oh...> > Sent: Friday, December 29, 2023 2:21 PM > To: lcm...@li... > Subject: Re: [Lcms-user] How does a transformation work > > Am Freitag, 29. Dezember 2023, 14:01:40 CET schrieb > mar...@li...: > > Hi, > > > > From your explanation, it seems to me that the transformation you want > > has > nothing to do with color management. You > > know nothing about the L* of your grayscale and need only some > > scaling. I > would rather use simple math in this case: > > > > Gray_out = (Gray_in * 40) /51 + 40; > > > > You could just use a for() loop. This is going to be faster that using > > any > color management routines. > > Hmm. It just was a test to understand how it (may) works. > The profile I create is used in the muPDF library to create a greyscale out from > a PDF document. I would expect, any kind of PDF could be rasterized into a > greyscale raster this way. > > Cheers, > Jürgen > > > > > > _______________________________________________ > Lcms-user mailing list > Lcm...@li... > https://lists.sourceforge.net/lists/listinfo/lcms-user |
From: <mar...@li...> - 2023-12-29 14:41:43
|
Hi, >From your explanation, it seems to me that the transformation you want has nothing to do with color management. You know nothing about the L* of your grayscale and need only some scaling. I would rather use simple math in this case: Gray_out = (Gray_in * 40) /51 + 40; You could just use a for() loop. This is going to be faster that using any color management routines. Regards Marti Maria The LittleCMS Project https://www.littlecms.com > -----Original Message----- > From: flap <fb...@oh...> > Sent: Friday, December 29, 2023 12:06 PM > To: lcm...@li... > Subject: [Lcms-user] How does a transformation work > > Hi list, > > what I want: an 8 bit grey-scale output for my printer, where the input dot > values (0 … 255) are scaled and limited to values of 40 … 240 (…just an > example). > > So I created a simple test input data (256 elements of unsigned char) with a > linear ramp from 0 (at index 0) … 255 (at index 255). > > And I created an array with 4096 short entries beginning with 40 (* 256 for > unsigned short) and ramp up linear to 240 (* 256 for unsigned short) and feed > it into cmsBuildTabulatedToneCurve16() and cmsCreateGrayProfile() with > cmsD50_xyY() as its whitepoint (for the output profile). > > For the input profile I used cmsBuildGamma() with a value of 1.0 and > cmsCreateGrayProfile() with cmsD50_xyY(). > > After creating the transformation with cmsCreateTransform() with > input/output types both TYPE_GRAY_8 and an intent of INTENT_PERCEPTUAL > and applying this transformation with cmsDoTransformLineStride () to my > simple input data, the output result is still almost linear from 0 to 255 and not > limited to 40 … 240. > > So, I think I'm using the tone curves in a wrong way. But where is my mistake? > > Cheers, > Jürgen > > > > > _______________________________________________ > Lcms-user mailing list > Lcm...@li... > https://lists.sourceforge.net/lists/listinfo/lcms-user |