News
Map
About

 


UserTalk CMYK to RGB Conversion

This is a fat web page containing workspace.["TIP: CMYK to RGB Conversion"].


On June 26th, Dave Babbitt asked the following question:

Does anybody know how to take data like 10% yellow, 30% magenta, 20% cyan and convert it into RGB values (and vise versa)? I already know how to change percentages into hex values.

Scott Sandeman-Allen responded:

Dave,

I don't read the Frontier lists much anymore but happened to catch this one. I hope I'm not too late to save you some labour...

I suspect that you were looking for a simpler way to convert from RGB and CMY. The two methodes provided on the list [using other application such as Quark] are fairly accurate ways to convert colours within a given environment. [However, these are either slow, unrealistic or imposible (because you don't have the apps).]

Unfortunately RGB and CMYK are not standards but colour models instead. RGB is an additive colour model (add more light to make colours lighter etc.) and CMY is subtractive (add pigmentation to remove light from a reflecting surface and make colours darker). The K in CMYK is purely a "Luminance" value or in laymans terms makes a colour darker but has no effect on what colour it is i.e. will change light red to darker red but wont effect the fact it is red.

This means that CMYK for one press or ink-jet printer will be different from the next. Even the same type of press may use different inks and change the colour representation.

Enough colour theory stuff.

It is simple to state, in a perfect world, that RGB is equal and opposite to CMY values (they are reciprocal). If you have 128 R, G & B it will represent 50% C, M & Y - or middle grey.

The only other thing to note is the "Gamma" or contrast of the devices you are representing. Fortunately, a Mac monitor and a sheetfed offset printing press have the same contrast. A PC monitor is a little contrasier (about 10% more -the difficulty here is the gamma equation is non-linear so the 10% is at the 50% point but less at both 25 and 75%).

Okay, if you are looking for a "quick 'n dirty' conversion so you get a red colour in both models, then do this:

     Swap R values for C values and invert the percentage.
     Swap G values for M   "
     Swap B values for Y   "

Example 20C, 30M, 10Y will turn into 80R, 70G, 90B (values in %) or to get the 8-bit value divide by 100.0 and multiply by 255 (or just multiply by 2.55 to save a step).

I could write you the code but that would take the fun out of it <ggg>. Besides, I don't know if you are looking for something quick or not.

Note: If there is a black value, then I'd guess at dividing it's value by two or three and then adding/subtracting it equally to all three colours. Black is generated from the equal parts of the colours (the neutrals, in the example there would be 10% grey because there is 10% of all three colours... I hope this makes sence as I'm trying to simplify here). Also, because printing inks are translucent, 100% of all four colours does not make a colour four times darker but only 50% or so darker than 100% C, M & Y.

Anyway, if you need the code I guess it would look something like

« ______ local script to convert CMYK to RGB values
on convertToRGB( CMYK_list ) 
 
    local 
        red     = 0 « initialise variables
        green   = 0
        blue    = 0
        « convert cyan to decimal from %
        cyan    = CMYK_list[ 1] / 100.0
        magenta = CMYK_list[ 2] / 100.0
        yellow  = CMYK_list[ 3] / 100.0
        black   = CMYK_list[ 4] / 100.0
        kFactor = 2.0 « the factor of Black
        «               transparency/translucence
     
    red 	= number( 255 - ( ( cyan + \
        ( black / kFactor ) ) * 255 ) )
    green 	= number( 255 - ( ( magenta + \
        ( black / kFactor ) ) * 255 ) )
    blue 	= number( 255 - ( ( yellow + \
        ( black / kFactor ) ) * 255 ) )
     
    return( { red, green, blue } )
     
window.msg( convertToRGB( { 20, 30, 10, 0 } ) )

This could further be simplified to:

« ______ local script to convert CMYK to RGB values
on convertToRGB( CMYK_list ) 
     
    local 
        red     = 0 « initialise variables
        green   = 0
        blue    = 0
        « convert to 8-bit value
        cyan    = CMYK_list[ 1] * 2.55
        magenta = CMYK_list[ 2] * 2.55
        yellow  = CMYK_list[ 3] * 2.55
        black   = CMYK_list[ 4] * 2.55
        kFactor = 2.0 « the factor of Black
        «               transparency/trnaslucence
     
    red 	= number( 255 - ( cyan + \
        ( black / kFactor ) ) )
    green 	= number( 255 - ( magenta + \
        ( black / kFactor ) ) )
    blue 	= number( 255 - ( yellow + \
        ( black / kFactor ) ) )
     
    return( { red, green, blue } )
     
window.msg( convertToRGB( { 20, 30, 10, 0 } ) )

I would do the oposite to get back to CMYK, but forget calculating the black. If you must, then find out which colour is the lowest (this dictates the ammount of black) then take half of that value and assign it to black.

I hope this helps,

Scott

PS. If you have any further questions, please eMail the list and cc my eMail. I will do the same. I don't monitor the list much so this will get you a quicker response and others can chip in too.

PPS. If you are displaying colours in Photoshop, you will find that the CMY versions are duller than RGB. This is because PS is trying to simulate presses which cannot print as bright as monitors can display. Try turning CMYK preview on with an RGB image and the colours will be much closer.


News - Map - About ScriptMeridian

Copyright © 1998 ScriptMeridian. All rights reserved
All trademarks are the property of their respective owners.
6:56:42 PM Sunday, July 12, 1998