To appreciate how color images are represented mathematically, we first need to understand grayscale images. Imagine an image as a function $I(x,y)$, this function takes two inputs – spatial coordinates $(x,y)$ – and provides an output, which is the intensity or gray level at those coordinates. When we deal with digital images, both these coordinates and the intensity values are finite and discrete. Digital images are made up of pixels (also known as image elements or pels), where each pixel holds a specific location and an intensity value. In essence, the function $I(x,y)$ indicates the gray value of the image at each pixel, painting a picture in varying shades of gray.
Delving into Color Spaces
A color space can be visualized as a three-dimensional geometric realm, where each possible color perception fits neatly within. This concept is crucial for creating a system that encompasses all possible color combinations. Historically, color perceptions, also called color solids, were envisioned in simple geometric forms like pyramids or cones. The specific shape of a color solid is determined by the spatial axes definitions and their divisions.
In a similar vein to grayscale images, color images use a multi-variable function $I$ but with an important difference, this function maps from:
\begin{equation*} I\!: \: \mathbb{R}^2 \! \rightarrow \mathbb{R}^3\end{equation*}
Meaning, unlike the grayscale function, the output here is a three-dimensional vector. This is because color spaces themselves are three-dimensional. The function $I$ is defined for the image size, meaning it is confined to the dimensions of the rows and columns of the image. Several color spaces have been developed for different applications, such as printing, computer graphics, or even how we perceive color. Notable examples include RGB, CMY, CMYK, HSI, and HSV.
RGB
This is the most commonly used space in computer technology. This space is based on the mixture of the three primary colors Red, Green, and Blue. These primary colors are the reference colors for most image sensors. In this space, the origin (zero vector) represents the color black, and the standard values of the three colors range from 0 to 255 (8-bit channels).
Experimental evidence has established that the 6-7 million cones (eye sensors responsible for color vision) can be divided into three main detection categories roughly corresponding to red, green, and blue. About 65% of all cones are sensitive to red light, 33% to green light, and around 2% to blue light; but, blue cones are the most sensitive.
The image below represents the color solid corresponding to RGB space, the axes (or dimensions) of this solid are Red, Green and Blue, with these three dimensions we can define any color. In this solid, the diagonal line that connects Black (zero vector) and White (maximum value of each color channel) represents the gray shades, where the values of each components are equal to each other, it means that the gray-scale can be understood as a subspace of the RGB space.
CMY
This color space is usually used in color printing and uses Cyan (C), Magenta (M), and Yellow (Y) as its base. Since these colors are the complements of red, green, and blue, a transformation can be made from a vector in RGB space to one in CMY in the following way:
\begin{equation*} \begin{bmatrix} C \\ M \\ Y \end{bmatrix} = \begin{bmatrix} 1 \\ 1 \\ 1 \end{bmatrix} - \begin{bmatrix} R \\ G \\ B \end{bmatrix} \end{equation*}
Where all RGB colors are considered normalized, so the value '1' represents the maximum of these colors. This equation demonstrates that light reflected from a surface coated with pure Cyan does not contain Red (that is, $C = 1 - R$ in the equation), similarly, pure Magenta does not reflect Green, and pure Yellow does not reflect Blue.
CMYK
As explained above, when color printing is required, the CMY color space is often used. However, Cyan, Magenta, and Yellow inks rarely are pure colors, resulting in a brownish color when combined to print black. Since black is widely used in printing, it was decided to add this color (denoted by the letter K) to the CMY color space to form the new CMYK space, but black is added only in the necessary proportions to produce a true black color in prints. To transform from a CMY space to a CMYK space, the following formulas are used:
\begin{equation*} K = \min(C^\prime, M^\prime, Y^\prime) \end{equation*}
\begin{equation*} C = \frac{C^\prime - K}{1 - K}; \quad M = \frac{M^\prime - K}{1 - K}; \quad Y = \frac{Y^\prime - K}{1 - K} \end{equation*}
Where $C^\prime$, $M^\prime$ and $Y^\prime$ are the colors in CMY space, while $C$, $M$, $Y$ and $K$ are the colors in CMYK space, all colors are considered normalized.
This is the most commonly used space in computer technology. This space is based on the mixture of the three primary colors Red, Green, and Blue. These primary colors are the reference colors for most image sensors. In this space, the origin (zero vector) represents the color black, and the standard values of the three colors range from 0 to 255 (8-bit channels).
Final Thoughts
The relevance of these color spaces transcends academic interest, profoundly influencing many aspects of our daily lives. From the vivid displays on our digital devices to the precision of color in print media, our interaction with and perception of digital images is fundamentally shaped by these color spaces. As technological advancements continue and our understanding of color theory deepens, the accuracy in color representation and processing in digital mediums grows increasingly significant. This knowledge is indispensable not only to professionals in fields like graphic design and printing but also enhances personal experiences in photography and visual arts.
In conclusion, the study of color spaces within digital image processing is a remarkable synthesis of science, technology, and artistic expression. It offers a dynamic field of study, rich with opportunities for innovation and creativity, captivating both professionals and enthusiasts alike in the vibrant and ever-progressing world of digital color.