UNIT 4
Segments, Illumination models, colour models and shading
Syllabus
• Segments: Introduction, Segment table, segment creation, closing,
deleting, renaming, and visibility.
• Illumination models: Light sources, ambient light, diffuse light,
specular reflection, the Phong model, combined diffuse and specular
reflections with multiple light sources.
• Color Models: CIE Chromaticity Diagram, Color Gamut, RGB, CMY,
YCbCr,HSVcolor models.
• Shading Algorithms: Constant intensity shading, Halftone, Gourand
and Phong Shading.
Segment
• To view an entire image or a part of image with various attributes, we
need to organize image information in a particular manner since
existing structure of display file does not satisfy our requirements of
viewing an image. To achieve this display, file is divided
into Segments.
• Dividing the display file into subparts is called as segments.
• Each segment corresponds to a component and is associated with a set
of attributes and image transformation parameters like scaling, rotation.
Presence of Segment allows :
• Subdivision of picture.
• Visualization of particular part of picture.
• Scaling, rotation and translation of picture.
Types of Segments :
• Posted Segment : When visible attribute of segment is set to 1, it is
called Posted segment. This is included in active segment list.
• Unposted Segment : When visible attribute of segment is set to 0, it is
called Unposted segment. This is not included in active segment list.
Segment Operations
Segment Creation :
• Segment must be created or opened when no other segment is open,
since two segments can’t be opened at the same time because it’s
difficult to assign drawing instruction to particular segment.
• The segment created must be given a name to identify it which must be
a valid one and there should be no segment with the same name.
• After this, we initialize items in segment table under our segment name
and the first instruction of this segment is allocated at next free storage
in display file and attributes of segments are initialized to default.
Algorithm :
• If any segment is open, give error message : “Segment is still
open” and go to step 8.
• Read the name of the new segment.
• If the segment name is not valid, give error message : “Segment name
not a valid name” and go to step 8.
• If given segment name already exists, give error message : “Segment
name already exists in name list” and go to step 8.
• Make next free storage area in display file as start of new segment.
• Initialize size of new segment to 0 and all its attributes to their default
values.
• Inform that the new segment is now open.
• Stop.
Closing a Segment :
After completing entry of all display file instructions, the segment needs
to be closed for which it has to be renamed, which is done by changing
the name of currently open segment as 0.
Now the segment with name 0 is open i.e. unnamed segment is open and
if two unnamed segments are present in display file one needs to be
deleted.
Algorithm :
If any segment is not open, give error message : “No segment is open
now” and go to step 6.
• Change the name of currently opened segment to any unnamed
segment, lets say 0.
• Delete any other unnamed segment instruction which may have been
saved and initialize above unnamed segment with no instructions.
• Make the next free storage area available in display file as start of the
unnamed segment.
• Initialize size of unnamed segment to 0.
• Stop.
Deleting a Segment :
To delete a particular segment from display file, we must just delete that one
segment without destroying or reforming the entire display and recover space
occupied by this segment.
Use this space for some other segment.
The method to achieve this depends upon the data structure used to represent
display file. In case of arrays, the gap left by deleted segment is filled by shifting
up all the segments following it.
Renaming a Segment :
• This is done to achieve Double Buffering i.e. the idea of storing two
images, one to show and other to create, alter and for animation.
Algorithm :
If both old and new segment names are not valid, give error
message : “Segment names are not valid names” and go to step 6.
• If any of two segments is open, give error message : “Segments are
still open” and go to step 6.
• If new segment name given already exists in the display list, give error
message : “Segment name already exists” and go to step 6.
• The old segment table entry are copied into new position.
• Delete the old segment.
• Stop.
Advantages of using segmented display :
• Segmentation allows to organize display files in sub-picture structure.
• It allows to apply different set of attributes to different portions of
image.
• It makes it easier to the picture by changing/replacing segments.
• It allows application of transformation on selective portions of image
Basic Illumination Models
• Illumination model, also known as Shading model or Lightning model,
is used to calculate the intensity of light that is reflected at a given point
on surface. There are three factors on which lightning effect depends on:
• Light Source :
Light source is the light emitting source. There are three types of light
sources:
• Point Sources – The source that emit rays in all directions (A bulb in a room).
• Parallel Sources – Can be considered as a point source which is far from the
surface (The sun).
• Distributed Sources – Rays originate from a finite area (A tubelight).
Light reflecting sources
All objects which are not emitting light are grouped under separate
category, which is called as light reflecting sources.
1. Ambient Illumination :
Assume you are standing on a road, facing a building with glass
exterior and sun rays are falling on that building reflecting back
from it and the falling on the object under observation.
• This would be Ambient Illumination. In simple words, Ambient
Illumination is the one where source of light is indirect.
• The light which is reflected from somewhere is called as background
light or ambient light.
2. Diffuse Reflection :
• When a light falls on any surface, it can be absorbed by the surface,
while the rest will be reflected or retransmitted.
• In this model, incoming light is scattered almost in all direction.
• Diffuse reflection occurs on the surfaces which are rough or grainy. In
this reflection the brightness of a point depends upon the angle made
by the light source and the surface.
• The ratio of light reflected from the surface to the total incoming light
is called as the coefficient of reflection or reflectivity
3. Specular Reflection :
When light falls on any shiny or glossy surface most of it is reflected
back, such reflection is known as Specular Reflection.
• Specular reflection is a type of reflection which occurs at the surface of
mirror.
• Phong Model is an empirical model for Specular Reflection which
provides us with the formula for calculation the reflected intensity I spec:
Shading algorithms
1. Constant intensity shading
2. Gouraud shading
3. Phong shading
4. Halftone shading
Constant shading
It is also called as Flat Shading.
For each polygon a single intensity is calculated and then with the same
intensity value all points on that surface of the polygon are displayed.
This method is useful when we want to display the appearance of curved
surfaces quickly.
It cannot handle specular reflection
Gourad Shading
Gourad shading is an example of intensity interpolation method.
renders a polygon surface by linear interpolating intensity value across
the surface.
Intensity values for each polygon are coordinate with the value of
adjacent polygons along the common edges, thus eliminating the
intensity discontinuities that can occur in flat shading.
Each polygon surface is rendered with Gouraud Shading by performing
the following calculations:
• Determining the average unit normal vector at each polygon vertex.
• Apply an illumination model to each vertex to determine the vertex
intensity.
• Linear interpolate the vertex intensities over the surface of the
polygon.
Phong shading
A more accurate method for rendering a polygon surface is to interpolate the
normal vector and then apply the illumination model to each surface point.
It is also called as Phong Shading or normal vector Interpolation Shading.
• Determine the average unit normal vector at each polygon vertex.
• Linearly & interpolate the vertex normals over the surface of the polygon.
• Calculate the pixel intensity of each scan line.
Halftone shading
• Halftone is the reprographic technique that simulates continuous-tone imagery
through the use of dots, varying either in size or in spacing, thus generating a
gradient-like effect.
• Where continuous-tone imagery contains an infinite range of
colors or greys, the halftone process reduces visual
reproductions to an image that is printed with only one
color of ink, in dots of differing size
(pulse-width modulation) or spacing (frequency modulation) or both.