7 Replies Latest reply: Aug 24, 2010 4:38 AM by Lou Dina RSS

    Conversion formulas from RGB to CMYK




      I've been writing a Colour swatch tool (in excel! hell yeah!) which allows me to pick a bunch of colours, generate complimentary colours from them, blend between 2 colours in a set number of steps and a whole bunch of other cool stuff, and then output this as a photoshop or illustrator swatch file.


      As part of this tool I want to be able to covert the rgb values to cmyk. There is very little information on this on the web and what there is is fairly inaccurate.


      For example,



      Converts to CMYK 61,0,0,50 (%) using the formula found at easyrgb.com (this formula is the most prevalent one on the web/web forums)

      Photoshop converts these RGB values as CMYK: 80,33,48,8 (%)


      While these two colour values are *similar* the ones generated by the easyrgb formulas are nowhere near the photoshop values.

      See? stupid useless formulas. (I am aware of the differences and overlap of the two gamuts)



      Whilst I know that the conversion done in photoshop is done using ICC templates, and that often these conversions are device dependant, there must be a more realiable way of converting from one colour space to another using good old reliable cold hard maths.


      Does anyone know what that might be? you guys at Adobe: I AM LOOKING AT YOU.

      Hope you guys can help,




      For reference I have included and commented the easyrgb formulas:


      First: RGB -> CMY


      C = 1 - ( R / 255 )
      M = 1 - ( G / 255 )
      Y = 1 - ( B / 255 )


      Second: CMY -> CMYK


      var_K = 1


      Initally sets var_K as 1, although this is dependant on variables below

      if ( C < var_K )   var_K = C
      if ( M < var_K )   var_K = M
      if ( Y < var_K )   var_K = Y


      This bit finds the smallest value from the CMY range and sets this value as var_K

      if ( var_K == 1 ) { //Black
          C = 0
          M = 0
          Y = 0


      If var_K (the value that K is calculated from) is 1, then all the CMY values are reset to 0

      else {
      = ( C - var_K ) / ( 1 - var_K )
          M = ( M - var_K ) / ( 1 - var_K )
          Y = ( Y - var_K ) / ( 1 - var_K )


      If the value of var_K is anything other than 1 then use the smallest value from the CMY range

      K = var_K


      The value of K as filtered out from the conditions above

        • 1. Re: Conversion formulas from RGB to CMYK
          Lou Dina Community Member



          A set of color numbers expressed as RGB or CMYK mean nothing "UNLESS" a profile is attached.  The profile establishes the boundaries of the RB or CMYK gamut.  RGB and CMYK are "device dependent", meaning that you can get different colors with the same set of numbers.


          For example, 240R/25G/30B is definitely a Red, but exactly what color red?  If you send that color to your inkjet printer, you will see red all right, but the precise color of red depends on the inkset, printer, resolution, and paper.  With a wide gamut inkset, a good hi rez printer, and a wide gamut glossy photo paper, that color will be a vibrant red.  If printed on uncoated copy paper on a mediocre printer, those same numbers will result in a rather washed out red.  Same scenario with CMYK....it is device dependent, and the profile gives the numbers meaning.  No profile, no meaning. It's like walking into a video electronics store and looking at 100 TVs, each playing the same station, but they color, contrast and brightness of each TV is different.  Which one is right?


          Lab color space is "device independent", so a specific set of Lab numbers always means the same thing, regardless of the output device.  Of course, not every output device can output all colors.  Lab (or a variant) is usually the universal translator that helps devices see color consistently.  Since it is based on human vision, it doesn't need a profile, but RGB and CMYK definitely do.


          If you want to learn more, check out www.BruceLindbloom.com and go over his information.  He has formulas and translators galore, and more than enough information to choke a mule.


          Hope this helps some.



          • 2. Re: Conversion formulas from RGB to CMYK
            Oliver Krylow

            Thanks Lou,


            that clarified the relationship of the numeric color value and color profiles for me.


            So are there any "meta" color profiles out there ,that come with their own RGB <-> LAB <-> CMYK conversions, or must every piece of software come up with its own conversion between profiles?

            • 3. Re: Conversion formulas from RGB to CMYK
              warzenbeisser Community Member

              Hello Oliver,


              There are many RGB and CMYK colour spaces that could be considered "standard" – the choice is, however, always arbitrary. For practical purposes, the way to go would be to pick a suitable pair, say sRGB and "SWOP coated v2" (for a workflow from sRGB office documents to U.S. standard web offset printing), and then specify that the conversions you derive thereof just apply for said combination of colour spaces. Unfortunately, there is just no "one size fits all" approach to colour management as explained in the previous answer you received.


              Edit: Maybe I misunderstood your question. As per the ICC standard, each ICC colour profile comes with embedded conversion tables from/to the profiled colour space to/from the standard profile connection space (CIE XYZ or CIELAB) for each of four possible rendering intents (perceptive, relative colorimetric, absolute colorimetric, and [maximum] saturation). So the "meta" space you look for is neither RGB nor CMYK but the PCS, i.e. LAB. The conversions themselves are governed by the ICC's specifications, and these are plain math, although different CMMs (colour management modules) might yield slightly different values due to the mapping of out-of-gamut-colours in particular ... Yes, colour science can be very confusing. ;-)



              • 4. Re: Conversion formulas from RGB to CMYK
                Lou Dina Community Member



                I'm not sure what you mean by the term 'meta' color profiles, but I'll take a stab at what I "think" you are asking.  There are some fairly widely accepted "standards" out there for both RGB and CMYK.


                In the RGB world, for example, sRGB, Adobe RGB (and to some extent, ProPhoto RGB) have a fairly wide following. These are all ICC profiles, which nail down the boundaries of the color gamut and the definitions of any tri-stimulus combination of red, green and blue. Basically, they are matrix profiles that establish the positions of the Red, Green and Blue primaries, and these positions define the outer limits, or color gamut, of the color space. sRGB is a relatively small color space, so some viewable and printable colors get clipped (sRGB is the general internet, email standard and is widely assumed for many non-color managed appplications, printers, etc). sRGB can handle a fairly wide range of colors, but does clip some colors in brightly colored originals. It has the advantage of being the most widely adopted standard, plus the steps between colors are very close together. I use sRGB for average images, most people pictures, etc. Adobe RGB spreads the primaries further apart, so it describes a wider color gamut. Because the primaries are further apart, the steps are slightly larger from one color to the next, but marginally so. I use Adobe RGB for most of my brightly colored images that will get clipped in sRGB. Adobe RGB is also generally a good choice for images that will ultimately go to a printing press or inkjet. ProPhoto RGB pushes the primaries WAY apart, so it describes a HUGE color gamut...in fact, many of the colors that can be defined in ProPhoto fall outside human vision, and certainly monitors and printers.Due to the wide spacing of steps in ProPhoto RGB, images should be worked in in 16 bit, otherwide you may see some banding and posterization if large edits are made.


                In the CMYK world, certain "standards" have been established, mainly for commercial offset printers (both web and sheetfed presses). By creating a standard, they are trying to establish the ink limit, densities, color gamut, dynamic range, gray balance, etc, of a "generic" sheet of commercial printing paper on the average well-maintained press using standard ISO inks, using good process control, mesurements, etc. By it's nature, this process has to encompass a wide cross section of presses, so it may act as a limitation on what some modern presses are capable of, but that's what standards usually do. If a good printer, with a modern press and great process control decides to sidestep the standard, they can probably extend color gamut, dynamic range, etc, but at the cost of no longer being "standardized". If commercial printers are "truly" trying to meet the standard, they will run tests, take measurements, and adjust their entire workflow so it matches the standard, within acceptable tolerances. Lots of shops "claim" to adhere to SWOP or GRACoL standards, but the majority of them don't. Standards for presses make some sense, because blending CMYK inks together (especially if they use ISO standard inks) on paper usually has a reasonably narrow range that works, though the paper makes a huge difference. (the same cannot be said for inkjets, monitors and many other processes, so they generally do not have standards). So for presses, there are standards for matte and coated papers, web presses, sheetfed presses, newsprint, etc. Each of these standards has its own ICC profile (or a family of profiles) that establishes ink limits, color gamuts, etc.


                All ICC profiles have the necessary tags and data to comply with the ICC specification. One of those requirements is a "profile connection space", which is usually L*a*b* or a variant. So, an file on your computer may be tagged as an Adobe RGB file, and if you wish to prepare it for a sheetfed press using glossy stock, you could convert the file to GRACoL2006_Coated1v2.ICC (an industry standard profile for No. 1 coated stock on a sheetfed press). Since both files have the ability to "speak Lab" a translation can be made from one color space to the other. The numbers in the Adobe RGB file will be converted to L*a*b* (the universal translator), and then the L*a*b* numbers will be converted to CMYK, specifically GRACoL2006_Coated1v2.ICC. So, now you have a file in CMYK space with new numbers. It is worth noting that RGB has only three colorants to define colors, but CMYK has four. So, while in RGB there is only one way to define a specific color, in CMYK, there are many possible combinations that can generate many colors. This adds complexity to the equation. The CMY colors are called subtractive primaries, and are opposites of RGB (additive primaries). The "K" (black ink) is added for text, line art, neutrality, extra Dmax, and because the CMY inks are not pure and don't deliver a true black all by themselves. If the inks and paper were perfect, you could theoretically get away with CMY all by themselves, except for registration issues, text, line art, etc. Also, the additional "K" ink can help reduce the total ink limit, save ink, reduce costs, and improve quality.


                Sorry for the book. This is not a simple subject, and we have only touched the surface.



                • 5. Re: Conversion formulas from RGB to CMYK
                  Oliver Krylow Community Member

                  Thanks for the book.


                  I see now, that asking for a standardized colour space describing RGB, CMYK, LAB all at once was pretty naive, considering all the output devices dealing with colour.


                  Still, coming back to the conversion formulas between those "standard" profiles, it seems to me that everybody is just left to implement a formula on his/her own.

                  Is, for example, the conversion in the Adobe CS, somehow accessible / readable ?

                  • 6. Re: Conversion formulas from RGB to CMYK
                    warzenbeisser Community Member

                    Yes and no; the conversion look-up tables in an ICC profile are accessible while the algorithms in the Adobe CMM used by the Creative Suite are proprietary and probably not publicly documented. An actual conversion uses both the LUTs and the CMM that interpolates all values between the samples specified by the LUT.

                    • 7. Re: Conversion formulas from RGB to CMYK
                      Lou Dina Community Member



                      Still, coming back to the conversion formulas between those  "standard" profiles, it seems to me that everybody is just left to  implement a formula on his/her own. Is, for example, the conversion in the Adobe CS, somehow accessible / readable ?


                      I'm not sure how that would be accomplished (I'm not saying it can't be done). There are a number of things happening in a conversion from one profile to the other.


                      1. The source and destination profiles have lookup tables and/or curves that define colors, relating each color to the universal translator "profile connection space" (usually Lab or a derivative).


                      2. Then, there is a color management module (CMM) or "engine" that performs the math, does interpolation, rounding, or whatever it does in the background. This module or engine looks at the two profiles and reconciles the data and actually performs the conversion.


                      3. Not all CMMs are identical, and you may get slightly different results depending on the one used (Apple, MS, Adobe, Kodak, etc).


                      4. The above assumes you already have source and destination for conversion, and that you simply want to go from one space to another. Creating these profiles is a whole other science, with a lot of tweaking, black magic and visual adjustment thrown into the mix.


                      I'd probably start with the ICC (International Color Consortium), looking at their specs, data, papers, etc. You can also look at Bruce Lindbloom's website, which has a lot of color information, theory, formulas, etc. www.brucelindbloom.com. You can also check out Chromix.com. They make various software products, like ColorThink Pro, that can do much or what you are trying to do. But, the formulas are in the background and not visible to the user.