groff
[Top][All Lists]

## Re: [Groff] Re: CMYK <-> RGB

 From: Tadziu Hoffmann Subject: Re: [Groff] Re: CMYK <-> RGB Date: Fri, 5 Oct 2001 20:04:53 +0200

```>
> >       r = 1 - c + ck - k
> >       r = (1 - c)(1 - k)
>
> Sorry to take this off-topic, but why is the `+ ck' there?  Why isn't
> it
>
>     r = 1 - c - k
>
> on the basis of cmy to cmyk is
>
>     k = min(c, m, y)
>     c, m, y = c - k, m - k, y - k
>
> so cmyk to cmy is
>
>     c, m, y = c + k, m + k, y + k
>
> and cmy to rgb is
>
>     r, g, b = 1 - c, 1 - m, 1 - y
>
> I'm obviously wrong on this but can't see why at the moment.

You're not obviously wrong there (or other people are, too).
In fact, this is (almost) what Adobe gives in the Red Book:

RGB -> CMYK:

c = 1.0 - red
m = 1.0 - green
y = 1.0 - blue
k = min(c, m, y)
cyan = min(1.0, max(0.0, c - UCR(k)))
magenta = min(1.0, max(0.0, m - UCR(k)))
yellow = min(1.0, max(0.0, y - UCR(k)))
black = min(1.0, max(0.0, BG(k)))

BG (black generation) and UCR (undercolor removal) are
user-specifiable functions that allow you to tweak how much
black is added and how much of the other colors is removed
(duh!).  In the simplest case, these functions are the identity.

CMYK -> RGB:

red = 1.0 - min(1.0, cyan + black)
green = 1.0 - min(1.0, magenta + black)
blue = 1.0 - min(1.0, yellow + black)

The min() is necessary because their scheme allows you
to have "extra black".

On account of all this, I'd like to join the circle of puzzled
souls and ask the related question, why are {cmy} scaled by
(maxval-k)/maxval in the formula

{rgb} = maxval - min(maxval, {cmy}*(maxval-k)/maxval + k)

?

Cheers,