Hi all, I have some questions about cmyk in combination with Metapost. Just by using \setupcolors[state=start, cmyk=yes, mpcmyk=yes, rgb=no, ] I get cmy(k=0) graphics, although all used colors are still defined in the rgb color space. This is really a nice feature and the automatic color conversion works relative good. Only (so far I have seen) gray tones have a noticeable tendency to brown (Acroreader 7.09). I have tested one of those gray tones by defining it as cmyk and the result looks ok. RGB(223,223,227) CMY(0.12548, 0.12547, 0.10980) CMYK(0.01762, 0.01760, 0, 0.10980) So is there a way to get cymk instead of cmy? Peter
On 2/2/07, Peter Rolf
Hi all,
I have some questions about cmyk in combination with Metapost. Just by using
\setupcolors[state=start, cmyk=yes, mpcmyk=yes, rgb=no, ]
I get cmy(k=0) graphics, although all used colors are still defined in the rgb color space. This is really a nice feature and the automatic color conversion works relative good. Only (so far I have seen) gray tones have a noticeable tendency to brown (Acroreader 7.09). I have tested one of those gray tones by defining it as cmyk and the result looks ok.
RGB(223,223,227) CMY(0.12548, 0.12547, 0.10980) CMYK(0.01762, 0.01760, 0, 0.10980)
So is there a way to get cymk instead of cmy?
hmm, can you post an example ? luigi
luigi scarso wrote:
On 2/2/07, Peter Rolf
wrote: Hi all,
I have some questions about cmyk in combination with Metapost. Just by using
\setupcolors[state=start, cmyk=yes, mpcmyk=yes, rgb=no, ]
I get cmy(k=0) graphics, although all used colors are still defined in the rgb color space. This is really a nice feature and the automatic color conversion works relative good. Only (so far I have seen) gray tones have a noticeable tendency to brown (Acroreader 7.09). I have tested one of those gray tones by defining it as cmyk and the result looks ok.
RGB(223,223,227) CMY(0.12548, 0.12547, 0.10980) CMYK(0.01762, 0.01760, 0, 0.10980)
So is there a way to get cymk instead of cmy?
hmm, can you post an example ?
Mojca has pointed me to the definition of \convertRGBtoCMYK (colo-ini.tex) and (if I understand it right) this is only a RGB->CMY conversion. The algorithm for the missing CMY->CMYK conversion is simple (see http://www.easyrgb.com/math.php?MATH=M13#text13 ), but "exact" calculation in TeX is no fun at all (at least not for me). I have tried to implement it, but yet without success. In the worst case I have to wait for luatex, which will solve all calculation problems. So think twice, before you waste your time... ;) Maybe I should add this color conversion to the feature request list, so that it will not be forgotten? Peter
luigi _______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Peter Rolf wrote:
luigi scarso wrote:
On 2/2/07, Peter Rolf
wrote: Hi all,
I have some questions about cmyk in combination with Metapost. Just by using
\setupcolors[state=start, cmyk=yes, mpcmyk=yes, rgb=no, ]
I get cmy(k=0) graphics, although all used colors are still defined in the rgb color space. This is really a nice feature and the automatic color conversion works relative good. Only (so far I have seen) gray tones have a noticeable tendency to brown (Acroreader 7.09). I have tested one of those gray
beware, without black component, on paper one indeed get brownish
colors. acrobat reader tries to mimick paper (can be configured) so this is why you don't get gray on screen
when converting colors to gray context does weighted conversion (as with b/w televisions) so 1,0,0 and 0,1,0 give different grays
tones by defining it as cmyk and the result looks ok.
RGB(223,223,227) CMY(0.12548, 0.12547, 0.10980) CMYK(0.01762, 0.01760, 0, 0.10980)
So is there a way to get cymk instead of cmy?
hmm, can you post an example ?
Mojca has pointed me to the definition of
\convertRGBtoCMYK (colo-ini.tex)
and (if I understand it right) this is only a RGB->CMY conversion.
The algorithm for the missing CMY->CMYK conversion is simple (see http://www.easyrgb.com/math.php?MATH=M13#text13 ), but "exact" calculation in TeX is no fun at all (at least not for me). I have tried to implement it, but yet without success. In the worst case I have to wait for luatex, which will solve all calculation problems. So think twice, before you waste your time... ;)
Maybe I should add this color conversion to the feature request list, so that it will not be forgotten?
Peter
luigi _______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
_______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
-- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Hans Hagen wrote:
Peter Rolf wrote:
luigi scarso wrote:
On 2/2/07, Peter Rolf
wrote: Hi all,
I have some questions about cmyk in combination with Metapost. Just by using
\setupcolors[state=start, cmyk=yes, mpcmyk=yes, rgb=no, ]
I get cmy(k=0) graphics, although all used colors are still defined in the rgb color space. This is really a nice feature and the automatic color conversion works relative good. Only (so far I have seen) gray tones have a noticeable tendency to brown (Acroreader 7.09). I have tested one of those gray
beware, without black component, on paper one indeed get brownish
colors. acrobat reader tries to mimick paper (can be configured) so this is why you don't get gray on screen
Yes, I remember playing around with this feature some time ago. Excuse my ignorance as I have no experience with other color space than RGB. ;) But the problem here is, that the conversion is not true RGBtoCMYK, but only RGBtoCMY (k is always sero). All of my graphics are in RGB, but for printing I surely need CMYK. A solution would be to define all used colors in the CMYK color space (although the origin of these colors is RGB). But to my surprise ConTeXt automatically converts my RGB colors (even the MP defined ones), except that the final colors are in the CMY instead of CMYK color space. All I want is a true RGBtoCMYK conversion. I know about the calculating limitations in TeX, so I can wait for an implemetation of that macro in LuaTeX. Best, Peter
when converting colors to gray context does weighted conversion (as with b/w televisions) so 1,0,0 and 0,1,0 give different grays
tones by defining it as cmyk and the result looks ok.
RGB(223,223,227) CMY(0.12548, 0.12547, 0.10980) CMYK(0.01762, 0.01760, 0, 0.10980)
So is there a way to get cymk instead of cmy?
hmm, can you post an example ?
Mojca has pointed me to the definition of
\convertRGBtoCMYK (colo-ini.tex)
and (if I understand it right) this is only a RGB->CMY conversion.
The algorithm for the missing CMY->CMYK conversion is simple (see http://www.easyrgb.com/math.php?MATH=M13#text13 ), but "exact" calculation in TeX is no fun at all (at least not for me). I have tried to implement it, but yet without success. In the worst case I have to wait for luatex, which will solve all calculation problems. So think twice, before you waste your time... ;)
Maybe I should add this color conversion to the feature request list, so that it will not be forgotten?
Peter
luigi _______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
_______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Peter Rolf wrote:
But to my surprise ConTeXt automatically converts my RGB colors (even the MP defined ones), except that the final colors are in the CMY instead of CMYK color space. All I want is a true RGBtoCMYK conversion. I know about the calculating limitations in TeX, so I can wait for an implemetation of that macro in LuaTeX.
but even then ... we need a formula ... Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On 2/4/07, Hans Hagen
Peter Rolf wrote:
But to my surprise ConTeXt automatically converts my RGB colors (even the MP defined ones), except that the final colors are in the CMY instead of CMYK color space. All I want is a true RGBtoCMYK conversion. I know about the calculating limitations in TeX, so I can wait for an implemetation of that macro in LuaTeX.
but even then ... we need a formula ...
Most pages on the internet list the following simple conversion formula: C' = 1 - (R/range) C = (C' - K') / (1 - K') M' = 1 - (G/range) M = (M' - K') / (1 - K') Y' = 1 - (B/range) Y = (Y' - K') / (1 - K') K' = MIN(C',Y',M') K = K' In the special case of K'=1, use (0,0,0,1) (I'm not a TeX guru, but I assume that conversion with current macros should not be much more difficult than conversion with luaTeX.) Mojca
Mojca Miklavec wrote:
On 2/4/07, Hans Hagen
wrote: Peter Rolf wrote:
But to my surprise ConTeXt automatically converts my RGB colors (even the MP defined ones), except that the final colors are in the CMY instead of CMYK color space. All I want is a true RGBtoCMYK conversion. I know about the calculating limitations in TeX, so I can wait for an implemetation of that macro in LuaTeX.
but even then ... we need a formula ...
Most pages on the internet list the following simple conversion formula:
C' = 1 - (R/range) C = (C' - K') / (1 - K') M' = 1 - (G/range) M = (M' - K') / (1 - K') Y' = 1 - (B/range) Y = (Y' - K') / (1 - K') K' = MIN(C',Y',M') K = K'
In the special case of K'=1, use (0,0,0,1)
(I'm not a TeX guru, but I assume that conversion with current macros should not be much more difficult than conversion with luaTeX.)
this is what we have now \def\doconvertRGBtoCMYK#1\to#2% {\colordimen#1\points \multiply\colordimen \plusthousand \colorcount\colordimen \advance\colorcount \medcard \divide\colorcount \maxcard \colorcount-\colorcount \advance\colorcount \plusthousand \edef#2{\realcolorvalue\colorcount}} \def\convertRGBtoCMYK#1#2#3% {\doconvertRGBtoCMYK#1\to\@@cl@@c \doconvertRGBtoCMYK#2\to\@@cl@@m \doconvertRGBtoCMYK#3\to\@@cl@@y \let\@@cl@@k\@@cl@@z} well, you can spent the rest of the evening writing an alternative ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On 2/4/07, Hans Hagen
Mojca Miklavec wrote:
On 2/4/07, Hans Hagen
wrote: Peter Rolf wrote:
But to my surprise ConTeXt automatically converts my RGB colors (even the MP defined ones), except that the final colors are in the CMY instead of CMYK color space. All I want is a true RGBtoCMYK conversion. I know about the calculating limitations in TeX, so I can wait for an implemetation of that macro in LuaTeX.
but even then ... we need a formula ...
Most pages on the internet list the following simple conversion formula:
C' = 1 - (R/range) C = (C' - K') / (1 - K') M' = 1 - (G/range) M = (M' - K') / (1 - K') Y' = 1 - (B/range) Y = (Y' - K') / (1 - K') K' = MIN(C',Y',M') K = K'
In the special case of K'=1, use (0,0,0,1)
(I'm not a TeX guru, but I assume that conversion with current macros should not be much more difficult than conversion with luaTeX.)
this is what we have now
\def\doconvertRGBtoCMYK#1\to#2% {\colordimen#1\points \multiply\colordimen \plusthousand \colorcount\colordimen \advance\colorcount \medcard \divide\colorcount \maxcard \colorcount-\colorcount \advance\colorcount \plusthousand \edef#2{\realcolorvalue\colorcount}}
\def\convertRGBtoCMYK#1#2#3% {\doconvertRGBtoCMYK#1\to\@@cl@@c \doconvertRGBtoCMYK#2\to\@@cl@@m \doconvertRGBtoCMYK#3\to\@@cl@@y \let\@@cl@@k\@@cl@@z}
well, you can spent the rest of the evening writing an alternative
Since writing reports can sometimes be really boring, you can test if the following works, but please don't ask me what it does ;) I copy-pasted the code (which should be better written with e-TeX, I suppose, or well ... lua is not that bad after all ;). % RGB -> CMYK % c' = 1 - r % m' = 1 - g % y' = 1 - b % k' = MIN(c',y',m') % c = (c' - k') / (1 - k') % m = (m' - k') / (1 - k') % y = (y' - k') / (1 - k') % k = k' % CMYK -> CMY % c = (c * (1 - k) + k) % m = (m * (1 - k) + k) % y = (y * (1 - k) + k) % CMY -> CMYK % k' = min(c,m,y) % if (k==1) % (0,0,0,1) % else % c = (c' - k') / (1 - k') % m = (m' - k') / (1 - k') % y = (y' - k') / (1 - k') % k = k' \unprotect \def\doconvertRGBtoCMY#1\to#2% {\colordimen#1\points \multiply\colordimen \plusthousand \colorcount\colordimen \advance\colorcount \medcard \divide\colorcount \maxcard \colorcount-\colorcount \advance\colorcount \plusthousand \edef#2{\realcolorvalue\colorcount}} \def\doconvertCMYtoCMYK#1\k#2\to#3%% {\colordimen#1\thousandpoint % \colorcount = 1000c \colorcount\colordimen % check if k<1 \colordimen#2\thousandpoint \ifdim\colordimen<\thousandpoint % #3 = (#1-#2)/(1-#2) \advance\colorcount-\colordimen % \colorcount = 1000(c-k) \colordimen-\colordimen % \colordimen = -1000k \divide\colordimen \plusthousand % \colordimen = -k \advance\colordimen \onepoint % \colordimen = 1-k \divide\colorcount \colordimen % \colorcount = 1000(c-k)/(1-k) % TODO: rounding error! \edef#3{\realcolorvalue\colorcount}% \else % if k==1, the component is zero \let#3\@@cl@@z% \fi} \def\convertRGBtoCMY#1#2#3% {\doconvertRGBtoCMY#1\to\@@cl@@c \doconvertRGBtoCMY#2\to\@@cl@@m \doconvertRGBtoCMY#3\to\@@cl@@y \let\@@cl@@k\@@cl@@z} \def\convertRGBtoCMYK#1#2#3% {\edef\@@cl@@r{#1}\edef\@@cl@@g{#2}\edef\@@cl@@b{#3}% \convertRGBtoCMY\@@cl@@r\@@cl@@g\@@cl@@b% \convertCMYtoCMYK\@@cl@@c\@@cl@@m\@@cl@@y} \def\convertCMYtoCMYK#1#2#3% {\edef\@@cl@@c{#1}\edef\@@cl@@m{#2}\edef\@@cl@@y{#3}% % calculate k = min(c,m,y) % k = 1 \colordimen\onepoint \colorcount\colordimen % if (k>c): k=c \ifdim\colordimen>#1\points% \colordimen#1\points \fi % if (k>m): k=m \ifdim\colordimen>#2\points% \colordimen#2\points \fi % if (k>y): k=y \ifdim\colordimen>#3\points% \colordimen#3\points \fi \multiply\colordimen \plusthousand \colorcount\colordimen \advance\colorcount \medcard \divide\colorcount \maxcard % z = min(c,m,y) \edef\@@cl@@k{\realcolorvalue\colorcount}% % \doconvertCMYtoCMYK#1\k\@@cl@@k\to\@@cl@@c \doconvertCMYtoCMYK#2\k\@@cl@@k\to\@@cl@@m \doconvertCMYtoCMYK#3\k\@@cl@@k\to\@@cl@@y } \protect \setupcolors[state=start, cmyk=yes, mpcmyk=yes, rgb=no, ] \pdfcompresslevel=0 \starttext \startMPcode fill unitsquare scaled 3cm withcolor (223/255,223/255,227/255); % CMY(0.12548, 0.12547, 0.10980) % CMYK(0.01762, 0.01760, 0, 0.10980) % results in (0.016, 0.016, 0, 0.110) \stopMPcode \stoptext Mojca
Mojca Miklavec wrote:
On 2/4/07, Hans Hagen
wrote: Mojca Miklavec wrote:
On 2/4/07, Hans Hagen
wrote: Peter Rolf wrote:
But to my surprise ConTeXt automatically converts my RGB colors (even the MP defined ones), except that the final colors are in the CMY instead of CMYK color space. All I want is a true RGBtoCMYK conversion. I know about the calculating limitations in TeX, so I can wait for an implemetation of that macro in LuaTeX.
but even then ... we need a formula ...
Most pages on the internet list the following simple conversion formula:
C' = 1 - (R/range) C = (C' - K') / (1 - K') M' = 1 - (G/range) M = (M' - K') / (1 - K') Y' = 1 - (B/range) Y = (Y' - K') / (1 - K') K' = MIN(C',Y',M') K = K'
In the special case of K'=1, use (0,0,0,1)
(I'm not a TeX guru, but I assume that conversion with current macros should not be much more difficult than conversion with luaTeX.)
this is what we have now
\def\doconvertRGBtoCMYK#1\to#2% {\colordimen#1\points \multiply\colordimen \plusthousand \colorcount\colordimen \advance\colorcount \medcard \divide\colorcount \maxcard \colorcount-\colorcount \advance\colorcount \plusthousand \edef#2{\realcolorvalue\colorcount}}
\def\convertRGBtoCMYK#1#2#3% {\doconvertRGBtoCMYK#1\to\@@cl@@c \doconvertRGBtoCMYK#2\to\@@cl@@m \doconvertRGBtoCMYK#3\to\@@cl@@y \let\@@cl@@k\@@cl@@z}
well, you can spent the rest of the evening writing an alternative
Since writing reports can sometimes be really boring, you can test if the following works, but please don't ask me what it does ;)
I doubt that writing such macros is a better activity ;) Thanks to you Mojca for this nice and clean structured solution. The conversion works ok, but the accuracy is not good enough. I have translated some parts into etex (better accuracy in divisions using dim|numexpr), but it's still lacks of accuracy. I will try to use a special macro (blow up numerator) for all divisions.
I copy-pasted the code (which should be better written with e-TeX, I suppose, or well ... lua is not that bad after all ;).
:)) Best, Peter \beginETEX \def\doconvertRGBtoCMY#1\to#2% {\colordimen#1\points \multiply\colordimen \plusthousand \colorcount\numexpr-\numexpr\colordimen+\medcard\relax/\maxcard+\plusthousand\relax \edef#2{\realcolorvalue\colorcount}} \def\doconvertCMYtoCMYK#1\k#2\to#3% {\colorcount\dimexpr#1\thousandpoint\relax \colordimen#2\thousandpoint \ifdim\colordimen<\thousandpoint \advance\colorcount-\colordimen \colordimen\dimexpr-\colordimen/\plusthousand+\onepoint\relax \colorcount\numexpr\colorcount/\colordimen\relax \edef#3{\realcolorvalue\colorcount}% \else \let#3\@@cl@@z \fi} \def\convertCMYtoCMYK#1#2#3% {\edef\@@cl@@c{#1}\edef\@@cl@@m{#2}\edef\@@cl@@y{#3}% \colordimen\onepoint \ifdim\colordimen>\@@cl@@c\points \colordimen\@@cl@@c\points\fi \ifdim\colordimen>\@@cl@@m\points \colordimen\@@cl@@m\points\fi \ifdim\colordimen>\@@cl@@y\points \colordimen\@@cl@@y\points\fi \multiply\colordimen \plusthousand \colorcount\numexpr\numexpr\colordimen+\medcard\relax/\maxcard\relax \edef\@@cl@@k{\realcolorvalue\colorcount}% \doconvertCMYtoCMYK#1\k\@@cl@@k\to\@@cl@@c \doconvertCMYtoCMYK#2\k\@@cl@@k\to\@@cl@@m \doconvertCMYtoCMYK#3\k\@@cl@@k\to\@@cl@@y } \endETEX
% RGB -> CMYK % c' = 1 - r % m' = 1 - g % y' = 1 - b % k' = MIN(c',y',m')
% c = (c' - k') / (1 - k') % m = (m' - k') / (1 - k') % y = (y' - k') / (1 - k') % k = k'
% CMYK -> CMY % c = (c * (1 - k) + k) % m = (m * (1 - k) + k) % y = (y * (1 - k) + k)
% CMY -> CMYK % k' = min(c,m,y) % if (k==1) % (0,0,0,1) % else % c = (c' - k') / (1 - k') % m = (m' - k') / (1 - k') % y = (y' - k') / (1 - k') % k = k'
\unprotect
\def\doconvertRGBtoCMY#1\to#2% {\colordimen#1\points \multiply\colordimen \plusthousand \colorcount\colordimen \advance\colorcount \medcard \divide\colorcount \maxcard \colorcount-\colorcount \advance\colorcount \plusthousand \edef#2{\realcolorvalue\colorcount}}
\def\doconvertCMYtoCMYK#1\k#2\to#3%% {\colordimen#1\thousandpoint % \colorcount = 1000c \colorcount\colordimen % check if k<1 \colordimen#2\thousandpoint \ifdim\colordimen<\thousandpoint % #3 = (#1-#2)/(1-#2) \advance\colorcount-\colordimen % \colorcount = 1000(c-k) \colordimen-\colordimen % \colordimen = -1000k \divide\colordimen \plusthousand % \colordimen = -k \advance\colordimen \onepoint % \colordimen = 1-k \divide\colorcount \colordimen % \colorcount = 1000(c-k)/(1-k) % TODO: rounding error! \edef#3{\realcolorvalue\colorcount}% \else % if k==1, the component is zero \let#3\@@cl@@z% \fi}
\def\convertRGBtoCMY#1#2#3% {\doconvertRGBtoCMY#1\to\@@cl@@c \doconvertRGBtoCMY#2\to\@@cl@@m \doconvertRGBtoCMY#3\to\@@cl@@y \let\@@cl@@k\@@cl@@z}
\def\convertRGBtoCMYK#1#2#3% {\edef\@@cl@@r{#1}\edef\@@cl@@g{#2}\edef\@@cl@@b{#3}% \convertRGBtoCMY\@@cl@@r\@@cl@@g\@@cl@@b% \convertCMYtoCMYK\@@cl@@c\@@cl@@m\@@cl@@y}
\def\convertCMYtoCMYK#1#2#3% {\edef\@@cl@@c{#1}\edef\@@cl@@m{#2}\edef\@@cl@@y{#3}% % calculate k = min(c,m,y) % k = 1 \colordimen\onepoint \colorcount\colordimen % if (k>c): k=c \ifdim\colordimen>#1\points% \colordimen#1\points \fi % if (k>m): k=m \ifdim\colordimen>#2\points% \colordimen#2\points \fi % if (k>y): k=y \ifdim\colordimen>#3\points% \colordimen#3\points \fi \multiply\colordimen \plusthousand \colorcount\colordimen \advance\colorcount \medcard \divide\colorcount \maxcard % z = min(c,m,y) \edef\@@cl@@k{\realcolorvalue\colorcount}% % \doconvertCMYtoCMYK#1\k\@@cl@@k\to\@@cl@@c \doconvertCMYtoCMYK#2\k\@@cl@@k\to\@@cl@@m \doconvertCMYtoCMYK#3\k\@@cl@@k\to\@@cl@@y }
\protect
\setupcolors[state=start, cmyk=yes, mpcmyk=yes, rgb=no, ]
\pdfcompresslevel=0
\starttext
\startMPcode fill unitsquare scaled 3cm withcolor (223/255,223/255,227/255); % CMY(0.12548, 0.12547, 0.10980) % CMYK(0.01762, 0.01760, 0, 0.10980) % results in (0.016, 0.016, 0, 0.110) \stopMPcode
\stoptext
Mojca _______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
On 2/5/07, Peter Rolf
Mojca Miklavec wrote:
On 2/4/07, Hans Hagen
wrote: Mojca Miklavec wrote:
On 2/4/07, Hans Hagen
wrote: Peter Rolf wrote:
But to my surprise ConTeXt automatically converts my RGB colors (even the MP defined ones), except that the final colors are in the CMY instead of CMYK color space. All I want is a true RGBtoCMYK conversion. I know about the calculating limitations in TeX, so I can wait for an implemetation of that macro in LuaTeX.
but even then ... we need a formula ...
Most pages on the internet list the following simple conversion formula:
C' = 1 - (R/range) C = (C' - K') / (1 - K') M' = 1 - (G/range) M = (M' - K') / (1 - K') Y' = 1 - (B/range) Y = (Y' - K') / (1 - K') K' = MIN(C',Y',M') K = K'
In the special case of K'=1, use (0,0,0,1)
(I'm not a TeX guru, but I assume that conversion with current macros should not be much more difficult than conversion with luaTeX.)
this is what we have now
\def\doconvertRGBtoCMYK#1\to#2% {\colordimen#1\points \multiply\colordimen \plusthousand \colorcount\colordimen \advance\colorcount \medcard \divide\colorcount \maxcard \colorcount-\colorcount \advance\colorcount \plusthousand \edef#2{\realcolorvalue\colorcount}}
\def\convertRGBtoCMYK#1#2#3% {\doconvertRGBtoCMYK#1\to\@@cl@@c \doconvertRGBtoCMYK#2\to\@@cl@@m \doconvertRGBtoCMYK#3\to\@@cl@@y \let\@@cl@@k\@@cl@@z}
well, you can spent the rest of the evening writing an alternative
Since writing reports can sometimes be really boring, you can test if the following works, but please don't ask me what it does ;)
I doubt that writing such macros is a better activity ;) Thanks to you Mojca for this nice and clean structured solution.
Nice and clean structured??? I hope that you're joking ... ;)
The conversion works ok, but the accuracy is not good enough. I have translated some parts into etex (better accuracy in divisions using dim|numexpr), but it's still lacks of accuracy. I will try to use a special macro (blow up numerator) for all divisions.
The problem with accuracy appears at more steps: - I used RGB->CMY->CMYK conversion, CMY is round off to 3 decimal places - I almost surely "forgot" to round the result - (c-k)/(1-k) probably works disastrous for large values of k - (I had quite some problems understanding how conversion between counters and dimensions works, and even more problems to find a clean solution - eTeX is surely a better choice) Mojca (no ConTeXt on this computer, so I'll reply about the rest later)
Mojca Miklavec wrote:
On 2/5/07, Peter Rolf
wrote: Mojca Miklavec wrote:
Mojca Miklavec wrote:
On 2/4/07, Hans Hagen
wrote: Peter Rolf wrote:
> But to my surprise ConTeXt automatically converts my RGB colors (even > the MP defined ones), except that the final colors are in the CMY > instead of CMYK color space. All I want is a true RGBtoCMYK conversion. > I know about the calculating limitations in TeX, so I can wait for an > implemetation of that macro in LuaTeX. > > but even then ... we need a formula ...
Most pages on the internet list the following simple conversion formula:
C' = 1 - (R/range) C = (C' - K') / (1 - K') M' = 1 - (G/range) M = (M' - K') / (1 - K') Y' = 1 - (B/range) Y = (Y' - K') / (1 - K') K' = MIN(C',Y',M') K = K'
In the special case of K'=1, use (0,0,0,1)
(I'm not a TeX guru, but I assume that conversion with current macros should not be much more difficult than conversion with luaTeX.)
this is what we have now
\def\doconvertRGBtoCMYK#1\to#2% {\colordimen#1\points \multiply\colordimen \plusthousand \colorcount\colordimen \advance\colorcount \medcard \divide\colorcount \maxcard \colorcount-\colorcount \advance\colorcount \plusthousand \edef#2{\realcolorvalue\colorcount}}
\def\convertRGBtoCMYK#1#2#3% {\doconvertRGBtoCMYK#1\to\@@cl@@c \doconvertRGBtoCMYK#2\to\@@cl@@m \doconvertRGBtoCMYK#3\to\@@cl@@y \let\@@cl@@k\@@cl@@z}
well, you can spent the rest of the evening writing an alternative Since writing reports can sometimes be really boring, you can test if
On 2/4/07, Hans Hagen
wrote: the following works, but please don't ask me what it does ;) I doubt that writing such macros is a better activity ;) Thanks to you Mojca for this nice and clean structured solution.
Nice and clean structured??? I hope that you're joking ... ;)
:)) It's working and this is more than I can say from my first attempt. But you are right. There is much room for optimization. I'll try to cook up something new tomorrow and then send you the result. Calculating in TeX can be so much fun ;)
The conversion works ok, but the accuracy is not good enough. I have translated some parts into etex (better accuracy in divisions using dim|numexpr), but it's still lacks of accuracy. I will try to use a special macro (blow up numerator) for all divisions.
The problem with accuracy appears at more steps: - I used RGB->CMY->CMYK conversion, CMY is round off to 3 decimal places - (c-k)/(1-k) probably works disastrous for large values of k - (I had quite some problems understanding how conversion between counters and dimensions works, and even more problems to find a clean solution - eTeX is surely a better choice)
Mojca
(no ConTeXt on this computer, so I'll reply about the rest later) _______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
participants (4)
-
Hans Hagen
-
luigi scarso
-
Mojca Miklavec
-
Peter Rolf