Close

Color format types and conversions

A project log for M5Stack Color Maker

With this device, you can copy the color of an object or create a new color with your imagination.

airpocketAIRPOCKET 10/08/2021 at 02:130 Comments

The RGB format divides the intensity of the three primary colors of light (red, green, and blue) into 256 steps, and combines them to represent 1667216 colors.

In printing, on the other hand, colors are represented by combining the three primary colors of color cyan, magenta, and yellow with black. The CMYK color format is a format for representing colors in this type of system.
Color maker uses the CMYK format to mix paints to create new paint colors. On the other hand, the color sensor that reads the color of an object uses the RGB format, so we will learn how to convert from RGB to CMYK.

The conversion from RGB to CMYK is very simple and can be expressed by the following formula

First, convert the RGB with values from 0 to 255 from 0 to 1.

R' = R/255

G' = G/255

B' = B/255


From the obtained RGB values, the K value is calculated, and then the CMY value is calculated.

K = 1-max(R', G', B')

C = (1-R'-K) / (1-K)

M = (1-G'-K) / (1-K)

Y = (1-B'-K) / (1-K)

Discussions