CMYK and RGB are two different colour models. The CMYK model is used in the publishing/printing industry as it is based on the four basic colours used for printing colour images on white paper. The four colours of the CMYK model are Cyan, Magenta, Yellow and Black. The CMYK colours are subtractive. This means the colours get darker as you blend them together. This is what happens when you print a colour image on paper as the more ink/pigments you add, the darker the colour gets.
The RGB model on the other hand is base don the opposite effect. Using the RGB model, the colours get brighter as you increase their Red, Green or Blue values. RGB colours are used to represent colours on a computer screen and are hence used for light emission, not pigments. The colours grow brighter as you blend them or increase their intensity.
CMYK values are given either as percentages or values between 0 and 1 (e.g. 50% = 0.5), whereas RGB values are given using an integer value between 0 and 255.
It his possible to convert RGB code into CMYK code and vice versa using the formulas provided below.
CMYK to RGB Conversion Formulas
RGB to CMYK Conversion Formulas
Using a programming language of your choice, create a computer program that:
- Asks the user to choose between two options:
- RGB to CMYK conversion
- CMYK to RGB conversion
- Retrieve the RGB or CMYK values based on the option selected
- Apply the conversion formulas to calculate the matching CMYK or RGB values
- Output the resulting CMYK or RGB values
We have started the code for you, though you still need to complete the main two functions: RGB_to_CMYK() and CMYK_to_RGB()