Vous êtes sur la page 1sur 7

Assosa University

College of Computing and Informatics


Department of Computer Science
Chapter 6: Colour Models and 3D Graphics

Color Models
PROPERTIES OF LIGHT

What we perceive as 'light", or different colors, is a narrow frequency band within the
electromagnetic spectrum. A few of the other frequency bands within this spectrum are
called radio waves, microwaves, infrared waves, and X-rays.
Figure: shows the approximate frequency ranges for some of the electromagnetic bands.
Each frequency value within the visible band corresponds to a distinct color. At the low-
frequency end is a red color (4.3 X 10" hertz), and the highest frequency we can see is a
violet color (7.5 X 10" hertz).
We perceive EM radiation with in the 400-700 nm range, the tiny piece of spectrum
between infra-red and ultraviolet

The purpose of a color model is to facilitate the specification of colors in some standard
generally accepted way. In essence, a color model is a specification of a 3-D coordinate
system and a subspace within that system where each color is represented by a single
point.
Each industry that uses color employs the most suitable color model.
For example, the RGB color model is used in computer graphics, YUV are used in video
systems and so on. Transferring color information from one industry to another requires
transformation from one set of values to another.

1
RGB Color Model
In the RGB model, each color appears as a combination of red, green, and blue. This
model is called additive, and the colors are called primary colors. The primary colors can
be added to produce the secondary colors of light (see Figure "Primary and Secondary
Colors for RGB and CMYK Models") - magenta (red plus blue), cyan (green plus blue),
and yellow (red plus green). The combination of red, green, and blue at full intensities
makes white.

Primary and Secondary Colors for RGB and CMYK Models

The color subspace of interest is a cube shown in Figure "RGB and CMY Color Models"
(RGB values are normalized to 0..1), in which RGB values are at three corners; cyan,
magenta, and yellow are the three other corners, black is at their origin; and white is at
the corner farthest from the origin.

The gray scale extends from black to white along the diagonal joining these two points.
The colors are the points on or inside the cube, defined by vectors extending from the
origin.
Thus, images in the RGB color model consist of three independent image planes, one for
each primary color.

The importance of the RGB color model is that it relates very closely to the way that the
human eye perceives color. RGB is a basic color model for computer graphics because
color displays use red, green, and blue to create the desired color. Therefore, the choice
of the RGB color space simplifies the architecture and design of the system. Besides, a
system that is designed using the RGB color space can take advantage of a large number
of existing software routines, because this color space has been around for a number of
years.

RGB and CMY Color Models

2
However, RGB is not very efficient when dealing with real-world images. To generate any
color within the RGB color cube, all three RGB components need to be of equal pixel
depth and display resolution. Also, any modification of the image requires modification
of all three planes.

CMYK Color Model

The CMYK color model is a subset of the RGB model and is primarily used in color print
production. CMYK is an acronym for cyan, magenta, and yellow along with black (noted
as K). The CMYK color space is subtractive, meaning that cyan, magenta, yellow and
black pigments or inks are applied to a white surface to subtract some color from white
surface to create the final color.

For example (see Figure "Primary and Secondary Colors for RGB and CMYK Models"),
cyan is white minus red, magenta is white minus green, and yellow is white minus blue.
Subtracting all colors by combining the CMY at full saturation should, in theory, render
black. However, impurities in the existing CMY inks make full and equal saturation
impossible, and some RGB light does filter through, rendering a muddy brown color.
Therefore, the black ink is added to CMY. The CMY cube is shown in Figure "RGB and
CMY Color Models", in which CMY values are at three corners; red, green, and blue are
the three other corners, white is at the origin; and black is at the corner farthest from
the origin.
Assumption: ink printed on pure white paper
CMY = White RGB:
C = 1 R, M = 1 G, Y = 1 B
CMYK from CMY (K is black ink):

3
K = min(C, M, Y)
C = C K, M = M K, Y = Y - K

YIQ Color Model

The YIQ color model is the basic color model used in analogue color TV broadcasting.
Initially YIQ is the re-coding of RGB for transmission efficiency (minimizing bandwidth)
and for downward compatibility with black-and white television. The YIQ color space is
derived from the RGB space. It comprises the luminance (Y) and two color difference
(I, Q) components. The luminance can be computed as a weighted sum of red, green and
blue components; the color difference, or chrominance, components are formed by
subtracting luminance from blue and from red.

The principal advantage of the YUV model in image processing is decoupling of


luminance and color information. The importance of this decoupling is that the
luminance component of an image can be processed without affecting its color
component. For example, the histogram equalization of the color image in the YUV
format may be performed simply by applying histogram equalization to its Y component.

HSV and HLS Color Models

The HLS (hue, lightness, saturation) and HSV (hue, saturation, value) color models were
developed to be more intuitive in manipulating with color and were designed to
approximate the way humans perceive and interpret color.

Hue defines the color itself. The values for the hue axis vary from 0 to 360 beginning and
ending with red and running through green, blue and all intermediary colors.

Saturation indicates the degree to which the hue differs from a neutral gray. The values
run from 0, which means no color saturation, to 1, which is the fullest saturation of a
given hue at a given illumination.

4
Intensity component - lightness (HLS) or value (HSV), indicates the illumination level.
Both vary from 0 (black, no light) to 1 (white, full illumination). The difference between
the two is that maximum saturation of hue (S=1) is at value V=1 (full illumination) in the
HSV color model, and at lightness L=0.5 in the HLS color model.

The HSV color space is essentially a cylinder, but usually it is represented as a cone or
hexagonal cone (hexcone) as shown in the Figure "HSV Solid", because the hexcone
defines the subset of the HSV space with valid RGB values. The value V is the vertical
axis, and the vertex V=0 corresponds to black color. Similarly, a color solid, or 3D-
representation, of the HLS model is a double hexcone (Figure "HSV Solid") with lightness
as the axis, and the vertex of the second hexcone corresponding to white.

HSV Solid

HLS Solid

5
Drawing 3-D Objects

OpenGL comes with a number of built-in routines for generating common 3-D objects,
such as cubes, cones and cylinders.

Example

The following function will be new to you:

glutWireCone(0.12,0.6,12,9);

This function draws a wireframe cone - you can also draw a solid cone with the similar
function glutSolidCone. Both take 4 arguments - the radius of the cone at its base, the
height of the cone, and the number of slices and stacks that make up the cone.
glPushMatrix();
...
glPopMatrix();

When we only want the transformation to apply to a specific object, we need to 'save'
the current modelview matrix before applying it, and then 'restore' it afterwards.
OpenGL provides a stack for this purpose. Before applying any transformation that is
specific to an object or objects, we push the current matrix onto the stack, and after we
have finished with the transformations, we pop it back again, so that it will not be
applied to all subsequent objects.

6
The following is a summary of the built-in routines for generating standard 3-D objects in
OpenGL/glut:

Cube: glutWireCube(GLdouble size), glutSolidCube(GLdouble size)


Sphere: glutWireSphere(GLdouble radius, GLint nSlices, GLint nstacks),
glutSolidSphere(GLdouble radius, GLint nSlices, GLint nstacks)
Torus: glutWireTorus(GLdouble inRad, GLdouble outRad, GLint nSlices, GLint nStacks),
glutSolidTorus(GLdouble inRad, GLdouble outRad, GLint nSlices, GLint nStacks)
Cone: glutWireCone(GLdouble baseRad, GLdouble height, GLint nSlices, GLint nStacks),
glutSolidCone(GLdouble baseRad, GLdouble height, GLint nSlices, GLint nStacks)
Teapot: glutWireTeapot(GLdouble size), glutSolidTeapot(GLdouble size)
Tetrahedron: glutWireTetrahedron(), glutSolidTetrahedron()
Octahedron: glutWireOctahedron(), glutSolidOctahedron()
Dodecahedron: glutWireDodecahedron(), glutSolidDodecahedron()
Icosahedron: glutWireIcosahedron(), glutSolidIcosahedron()

In summary, OpenGL has many built-in routines for generating 3-D objects. By combining
these objects and varying the arguments used to create them, it is possible to build a
wide range of complex objects. But remember that if you want to apply modelview
transformations that are specific to an object or objects, you should set the current
matrix to be the modelview matrix (using glMatrixMode), push the current matrix onto
the stack, and pop it back again afterwards.

Vous aimerez peut-être aussi