Page 22 - DCAP504_Computer Graphics
P. 22
Unit 2: Colors in Computer Graphics
2.2 Setting the Color Attributes of Pixels
Before discussing how to set color attributes of pixels, let us understand the meaning of color attribute.
The color attribute is nothing but the visual qualities of saturation, hue, or brightness.
Did you know? Famous physiologist Ewald Hering was the first to understand the color attributes
during the 19 century.
th
The color attribute of pixel is nothing but the visual qualities of saturation, hue, or brightness with
reference to a pixel. In computer graphics, the most primal process is the setting of color attributes of
individual pixels. It is generally carried out by creating system library calls to write the respective
values into the frame buffer. A three-element array, which is a type of aggregate data structure, is
generally used to characterize the three primary color components. In spite of image type, which is
nothing but direct coding versus lookup table, there are two possible protocols for the specification of
pixel co-ordinates and color values.
In a single protocol, the application offers both color information and co-ordinate information
simultaneously.
Suppose rgb is a three-element array with rgb [0] = r, rgb [1], and rgb [2] = b.
Therefore, a call of setting a pixel at location (x, y) in a 24 bit image to color (r, g,
b) would look like setPixel (x, y, rgb).
Alternatively, if the image in the above example uses a lookup table and assuming that the color is
defined in the table, the call would look like setPixel (x, y, i), where i is the entry address containing
(r,g,b).
One more protocol is based on the existence of an existing color. This color is preserved by the system
and can be set by calls that look like setColor (rgb) for direct coding or setColor (i) for lookup table
representation. Now, the calls to set pixels need to provide only the co-ordinate information and would
look like setPixel (x, y) for both image types. The graphical system will robotically use the most recently
specified current color to carry out the operation.
Now, a lookup table’s entries can be set by a call that looks like setEntry (i, rgb), which sets color (r, g, b)
in the entry with address i. On the other hand, values in the lookup table can be interpreted back to the
application with a call that looks like getEntry (i, rgb). This returns the color value in entry i array rgb.
Most of the times, a situation may arise, where two versions of the calls will specify the RGB values.
One of these versions takes RGB values as floating point numbers in the range of [0.0, 1, 0], and the
other version takes RGB values as integers in the range of [0, 225]. Even though, the floating point
values are mapped by the graphics system into integer values before being written into the frame
buffer.
To provide fundamental support for pixel based image processing, there are calls that look like getPixel
(x, y, rgb) for direct coding, or getPixel (x, y, i) for the lookup table representation, in order to return the
color or index value of the pixel at (x, y) back to the application.
There are few calls that read and write rectangular blocks of pixels. A useful example would be a call to
set all pixels to a definite background color and then make a call that looks like clear() in order to
achieve the goal.
2.3 Mandelbrot Set
The Mandelbrot set is a meticulous mathematical set of points, whose border generates a distinctive and
easily recognizable two-dimensional fractal shape.
Did you know? The Mandelbrot set is named after Benoit Mandelbrot, and it is called as
Apfelmännchen (apple-man) in German language.
LOVELY PROFESSIONAL UNIVERSITY 15