Module 1 CGV
Module 1 CGV
com/channel/0029VaA9uVVIiRp0RS5li20r
Module 1
Q1. What is computer graphics? Explain the applications of computer graphics.
Ans : Computer graphics is an art of drawing pictures, lines, charts, etc. using computers with the
help of programming. Computer graphics image is made up of number of pixels. Pixel is the smallest
addressable graphical unit represented on the computer screen.
• Graphs & charts are commonly used to summarize functional, statistical, mathematical,
engineering and economic data for research reports, managerial summaries and other types
of publications.
• Typically examples of data plots are line graphs, bar charts, pie charts, surface graphs,
contour plots and other displays showing relationships between multiple parameters in two
dimensions, three dimensions, or higher-dimensional spaces
b. Computer-Aided Design
• A major use of computer graphics is in design processes-particularly for engineering and
architectural systems.
• CAD, computer-aided design or CADD, computer-aided drafting and design methods are
now routinely used in the automobiles, aircraft, spacecraft, computers, home appliances.
• Circuits and networks for communications, water supply or other utilities are constructed
with repeated placement of a few geographical shapes.
• Animations are often used in CAD applications. Real-time, computer animations using wire-
frame shapes are useful for quickly testing the performance of a vehicle or system.
c. Virtual-Reality Environments
• Animations in virtual-reality environments are often used to train heavy-equipment
operators or to analyze the effectiveness of various cabin configurations and control
placements.
• With virtual-reality systems, designers and others can move about and interact with objects
in various ways. Architectural designs can be examined by taking simulated “walk” through
the rooms or around the outsides of buildings to better appreciate the overall effect of a
particular design.
• With a special glove, we can even “grasp” objects in a scene and turn them over or move
them from one place to another.
d. Data Visualizations
• Producing graphical representations for scientific, engineering and medical data sets and
processes is another fairly new application of computer graphics, which is generally referred
to as scientific visualization. And the term business visualization is used in connection with
data sets related to commerce, industry and other nonscientific areas.
Join Whatsapp Channel: https://whatsapp.com/channel/0029VaA9uVVIiRp0RS5li20r
• There are many different kinds of data sets and effective visualization schemes depend on
the characteristics of the data. A collection of data can contain scalar values, vectors or
higher-order tensors.
• Some simulators have no video screens,for eg: flight simulator with only a control panel for
instrument flying
f. Computer Art
• The picture is usually painted electronically on a graphics tablet using a stylus, which can
simulate different brush strokes, brush widths and colors.
• Fine artists use a variety of other computer technologies to produce images. To create
pictures the artist uses a combination of 3D modeling packages, texture mapping, drawing
programs and CAD software etc.
• Commercial art also uses theses “painting” techniques for generating logos & other designs,
page layouts combining text & graphics, TV advertising spots & other applications.
g. Entertainment
• Television production, motion pictures, and music videos routinely a computer graphics
methods.
• Sometimes graphics images are combined a live actors and scenes and sometimes the films
are completely generated a computer rendering and animation techniques.
• Some television programs also use animation techniques to combine computer generated
figures of people, animals, or cartoon characters with the actor in a scene or to transform an
actor’s face into another shape.
h. Image Processing
• The modification or interpretation of existing pictures, such as photographs and TV scans is
called image processing.
• Methods used in computer graphics and image processing overlap, the two areas are
concerned with fundamentally different operations.
• Image processing methods are used to improve picture quality, analyze images, or recognize
visual patterns for robotics applications.
Join Whatsapp Channel: https://whatsapp.com/channel/0029VaA9uVVIiRp0RS5li20r
• Image processing methods are often used in computer graphics, and computer graphics
methods are frequently applied in image processing.
• Medical applications also make extensive use of image processing techniques for picture
enhancements in tomography and in simulations and surgical operations.
• A major component of graphical interface is a window manager that allows a user to display
multiple, rectangular screen areas called display windows.
• Each screen display area can contain a different process, showing graphical or non-graphical
information, and various methods can be used to activate a display window.
• Using an interactive pointing device, such as mouse, we can active a display window on
some systems by positioning the screen cursor within the window display area and pressing
the left mouse button.
Q2. Define Computer Graphics. Explain the basic operation of video monitors based on
standard CRT design. OR With a neat diagram explain the electrostatic deflection of the
electron beam in a CRT.
Ans :
The standard Cathode-Ray Tube (CRT) design has been a fundamental technology in video monitors
for many years.
◦ Acceleration: These electrons are then accelerated towards the screen by applying a high positive
voltage to the anode. This high voltage causes the electrons to gain kinetic energy as they travel
through the vacuum inside the CRT.
Join Whatsapp Channel: https://whatsapp.com/channel/0029VaA9uVVIiRp0RS5li20r
◦ Focusing: The electron beam is focused to a small, precise point on the screen. This is achieved
using electrostatic or magnetic focusing systems. In electrostatic focusing, the beam passes through
a positively charged metal cylinder that helps concentrate the electrons into a narrow beam.
Magnetic focusing uses magnetic fields generated by coils to achieve the same result.
3. Deflection Systems:
◦ Magnetic Deflection: CRTs commonly use magnetic deflection to direct the electron beam to
different parts of the screen. Two pairs of magnetic deflection coils are used: one pair controls
horizontal deflection (mounted on opposite sides of the CRT neck) and the other controls vertical
deflection (mounted on the top and bottom of the CRT neck). The magnetic fields created by these
coils steer the electron beam across the screen.
◦ Light Emission: As these excited phosphor electrons return to their ground state, they release
energy in the form of light photons. This emitted light forms the visible image on the screen. The
brightness of the image is dependent on the number of electrons striking the phosphor and the
efficiency of the phosphor material.
◦ Persistence: Different phosphors have varying persistence levels, which affect how long they
continue to emit light after being struck by the electron beam. Lower persistence phosphors require
higher refresh rates to avoid noticeable flicker.
6. Resolution:
◦ Definition: The resolution of a CRT monitor refers to the maximum number of distinct points (or
pixels) that can be displayed without overlap. This is determined by the type of phosphor used, the
focusing system, and the deflection accuracy.
◦ High-Definition: CRT monitors with high resolutions are often referred to as high-definition
systems, as they can display more detail and clearer images due to their ability to render finer points.
2. Electron Guns: The CRT features three separate electron guns, each dedicated to one of the
primary colors: red, green, or blue. These guns emit electrons that are aimed at the
phosphor-coated screen.
3. Shadow Mask Grid: Positioned just behind the phosphor-coated screen is a shadow mask
grid. This grid contains a series of precisely aligned holes that correspond to the arrangement
of the phosphor dots.
4. Beam Focusing and Deflection: bThe electron beams from the three guns are deflected and
focused as a group onto the shadow mask. The purpose of the shadow mask is to ensure
that each electron beam passes through the corresponding hole and activates only its
designated color dot in the dot triangle.
5. Color Activation: When an electron beam passes through a hole in the shadow mask, it
excites the corresponding color phosphor dot in the dot triangle. Each dot emits light of its
specific color (red, green, or blue). The combination of these colors at each pixel position
produces various colors on the screen.
6. Color Mixing: By adjusting the intensity of each of the three electron beams, the CRT can
produce a wide spectrum of colors. The color seen on the screen results from the additive
mixing of the red, green, and blue light emitted by the activated phosphor dots.
Q4 . Raster Scan Displays vs Random Scan Displays ALSO Briefly explain the
characteristics of raster scan displays method.
Ans: Characteristics of Raster-Scan Displays
1. Scanning Method: In raster-scan displays, the electron beam sweeps across the screen one
row at a time from top to bottom. This process is known as scanning or refreshing.
2. Pattern Creation: As the beam moves across each row, its intensity is modulated to create a
pattern of illuminated spots. This pattern forms the displayed image on the screen.
3. Frame Rate: The scanning process is repeated continuously, with each complete scan of the
screen called a frame. The rate at which these frames are refreshed is known as the frame
rate, typically ranging from 60 to 80 frames per second (60 Hz to 80 Hz).
Join Whatsapp Channel: https://whatsapp.com/channel/0029VaA9uVVIiRp0RS5li20r
4. Frame Buffer: Picture definition is stored in a memory area called the frame buffer. This
buffer holds the intensity values for all screen points, with each point referred to as a pixel
(picture element).
5. Aspect Ratio: The aspect ratio of a raster-scan display is defined as the number of pixel
columns divided by the number of scan lines that can be displayed by the system.
These characteristics define how raster-scan displays generate and refresh images on the screen,
enabling the visualization of both monochrome and color graphics.
2. Line Drawing: Pictures are created as line drawings. The electron beam follows the
component lines of the image one by one, making random-scan displays also known as
vector displays, stroke-writing displays, or calligraphic displays.
3. Order of Drawing: The component lines can be drawn and refreshed in any specified order,
allowing for flexible image rendering.
4. Pen Plotter Similarity: A pen plotter operates similarly to a random-scan display by drawing
lines on paper, making it a hard-copy example of this display technology.
5. Refresh Rate: The refresh rate in a random-scan system depends on the number of lines to
be displayed. Random-scan displays typically refresh all lines 30 to 60 times per second and
can handle up to 100,000 short lines in the display list.
7. Refresh Cycle Management: After processing all line-drawing commands, the system cycles
back to the first command in the list. When a small number of lines is to be displayed,
refresh cycles may be delayed to prevent excessively high refresh rates that could damage
the phosphor.
These characteristics define how random-scan displays render and refresh images, focusing on
drawing and updating lines rather than the entire screen.
• Figure shows one way to organize the components of a raster system that contains a
separate display processor, sometimes referred to as a graphics controller or a display
coprocessor.
• The purpose of the display processor is to free the CPU from the graphics chores.
• In addition to the system memory, a separate display-processor memory area can be
provided.
Scan conversion:
A major task of the display processor is digitizing a picture definition given in an
application program into a set of pixel values for storage in the frame buffer.
This digitization process is called scan conversion.
Using outline:
➔ For characters that are defined as outlines, the shapes are scan-converted into the frame
buffer by locating the pixel positions closest to the outline.
i)Run-length encoding:
• The first number in each pair can be a reference to a color value, and the second
number can specify the number of adjacent pixels on the scan line that are to be
displayed in that color.
• This technique, called run-length encoding, can result in a considerable saving is
storage space if a picture is to be constructed mostly with long runs of a single color
each.
• A similar approach can be taken when pixel colors change linearly.
ii)Cell encoding:
• Another approach is to encode the raster as a set of rectangular areas (cell encoding).
1) Beam-penetration technique:
• This technique is used with random scan monitors.
• In this technique inside of CRT coated with two phosphor layers usually red and green.
Join Whatsapp Channel: https://whatsapp.com/channel/0029VaA9uVVIiRp0RS5li20r
Disadvantages:
➢ It is a low cost technique to produce color in random scan monitors.
➢ It can display only four colors.
➢ Quality of picture is not good compared to other techniques.
2)Shadow-mask technique
• It produces wide range of colors as compared to beam-penetration technique.
• This technique is generally used in raster scan displays. Including color TV.
• In this technique CRT has three phosphor color dots at each pixel position.
• One dot for red, one for green and one for blue light. This is commonly known as Dot
triangle.
• Here in CRT there are three electron guns present, one for each color dot. And a shadow
mask grid just behind the phosphor coated screen.
• The shadow mask grid consists of series of holes aligned with the phosphor dot pattern.
• Three electron beams are deflected and focused as a group onto the shadow mask and
when they pass through a hole they excite a dot triangle.
• In dot triangle three phosphor dots are arranged so that each electron beam can activate
only its corresponding color dot when it passes through the shadow mask.
• A dot triangle when activated appears as a small dot on the screen which has color of
combination of three small dots in the dot triangle.
• By changing the intensity of the three electron beams we can obtain different colors in
the shadow mask CRT.
1. Emissive displays: - the emissive display or emitters are devices that convert
electrical energy into light. For Ex. Plasma panel, thin film electroluminescent
displays and light emitting diodes.
2. Non emissive displays: - non emissive display or non emitters use optical
effects to convert sunlight or light from some other source into graphics patterns.
For Ex. LCD (Liquid Crystal Display).
• A series of vertical conducting ribbons is placed on one glass panel and a set of horizontal
ribbon is built into the other glass panel.
• Firing voltage is applied to a pair of horizontal and vertical conductors cause the gas at the
intersection of the two conductors to break down into glowing plasma of electrons and ions.
• Picture definition is stored in a refresh buffer and the firing voltages are applied to refresh
the pixel positions, 60 times per second.
• Alternating current methods are used to provide faster application of firing voltages and thus
brighter displays.
• Separation between pixels is provided by the electric field of conductor.
• One disadvantage of plasma panels is they were strictly monochromatic device that means
shows only one color other than black like black and white.
2. Pixmap:
Definition: A pixmap is similar to a bitmap but is used for color images. It stores the color
values for each pixel, with each entry using multiple bits to represent color. For true color
Join Whatsapp Channel: https://whatsapp.com/channel/0029VaA9uVVIiRp0RS5li20r
displays, a pixmap typically uses 24 bits per pixel (8 bits for each of the red, green, and blue
color channels).
3. Aspect Ratio:
Definition: The aspect ratio of a display refers to the ratio of the number of pixel columns to
the number of scan lines (rows) that can be displayed. It defines the proportional relationship
between the width and height of the display area.
4. Frame Buffer:
Definition: The frame buffer is a memory area where the image data for display is stored. It
holds the intensity values or color information for each pixel on the screen. This data is used
to refresh and display the image on the monitor.
5. Resolution:
Definition: Resolution refers to the number of distinct pixels displayed on the screen,
typically described as the width by the height (e.g., 1920x1080). It determines the clarity and
detail of the image shown.
6. Pixel:
Definition: A pixel, short for "picture element," is the smallest unit of a digital image or
display. Each pixel represents a single point of color or intensity in the image and is the
fundamental building block of a raster image.
• Case 2: ∣m∣>1 (Shallow lines where y changes more rapidly than x):
• Increment y by 1 unit each step.
• Compute the corresponding x value using xk+1=xk+m1, where m=dy/dx.
• Case 3: m=1 (Diagonal lines):
• Increment both x and y by 1 unit each step.
4. Implementation Notes:
• If the line's starting point is at the right of the ending point or if the line has a
negative slope, adjust the increments accordingly:
• For ∣m∣<1 with a right-starting endpoint: x decreases and y updates using
yk+1=yk−m.
• For ∣m∣>1 with a right-starting endpoint: y decreases and x updates using
xk+1=xk−m1.
5. Algorithm Efficiency:
• The DDA algorithm is efficient as it avoids multiplication and uses only addition and
rounding operations to determine pixel positions. This makes it faster compared to
algorithms that involve direct multiplication for each pixel calculation.
Sample Code:
#include <stdlib.h>
#include <math.h>
setPixel(round(x), round(y));
for (k = 0; k < steps; k++) {
x += xIncrement;
y += yIncrement;
setPixel(round(x), round(y));
}
}
In this code, setPixel(x, y) is a placeholder function that would be replaced with actual code to
draw a pixel on the screen.
The DDA algorithm is a fundamental method in computer graphics for drawing lines and is valued
for its simplicity and efficiency.
1. Calculate Constants:
• Determine the initial decision parameter p0:
• p0=2Δx−Δy
• Compute the increments for the decision parameter:
• 2Δx
• 2Δx−2Δy
2. Iterative Plotting:
• Start from (x0,y0) and iterate for each y-coordinate until y reaches yEnd:
• If pk<0: Plot the next point at (xk,yk+1) and update pk+1 as:
• pk+1=pk+2Δx
• Otherwise: Plot the next point at (xk+1,yk+1) and update pk+1 as:
• pk+1=pk+2Δx−2Δy
Example
Consider drawing a line from (2,2) to (8,5).
1. Initialization:
• Δx=8−2=6
• Δy=5−2=3
• Initial decision parameter: p0=2Δy−Δx=2×3−6=0
2. Plotting Points:
• Start at (2,2)
Join Whatsapp Channel: https://whatsapp.com/channel/0029VaA9uVVIiRp0RS5li20r
The algorithm efficiently determines pixel positions using integer arithmetic and avoids the need for
floating-point calculations, making it both fast and suitable for real-time applications.
Code:
#include <stdlib.h>
#include <math.h>
/* Bresenham line-drawing procedure for |m| < 1.0 */
void lineBres(int x0, int y0, int xEnd, int yEnd) {
int dx = abs(xEnd - x0); // Change in x
int dy = abs(yEnd - y0); // Change in y
int p = 2 * dy - dx; // Initial decision parameter
int twoDy = 2 * dy; // 2 * dy
int twoDyMinusDx = 2 * (dy - dx); // 2 * (dy - dx)
int x, y;
Q10. Describe the basic structure of an OpenGL graphics program with the necessary
OpenGL functions. OR Explain the operations for displaying a picture using GLUT.
Ans : The basic structure of an OpenGL graphics program using the provided context involves
setting up the OpenGL environment, defining the graphics to be displayed, and managing the display
window. Here’s a step-by-step breakdown of how to structure an OpenGL program using the
OpenGL Utility Toolkit (GLUT) for window management:
2. Initialization Function
Create an initialization function to set up your OpenGL environment. This typically includes setting
the background color and specifying the projection parameters:
void init(void) {
glClearColor(1.0, 1.0, 1.0, 0.0); // Set background color to white.
glMatrixMode(GL_PROJECTION); // Set the projection matrix mode.
gluOrtho2D(0.0, 200.0, 0.0, 150.0); // Set the 2D orthogonal projection.
}
3. Display Function
Define a display function to specify what to draw. This function is called by GLUT to render the
graphics:
void lineSegment(void) {
glClear(GL_COLOR_BUFFER_BIT); // Clear the display window.
glColor3f(0.0, 0.4, 0.2); // Set the drawing color to dark green.
4. Main Function
The main function initializes GLUT, sets up the display window, and enters the GLUT main loop:
int main(int argc, char** argv) {
glutInit(&argc, argv); // Initialize GLUT.
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); // Set display mode to single buffer
and RGB color.
glutInitWindowPosition(50, 100); // Set the position of the window.
glutInitWindowSize(400, 300); // Set the size of the window.
glutCreateWindow("An Example OpenGL Program"); // Create a window with a title.
Summary
1. Include Headers: Use #include <GL/glut.h> to access OpenGL and GLUT functions.
2. Initialization (init Function): Set up background color and projection parameters.
3. Display (lineSegment Function): Clear the screen, set colors, draw graphics, and flush the
drawing commands.
4. Main Function: Initialize GLUT, set display mode, configure window size and position, create
the window, and enter the GLUT event loop.
This basic structure sets up a simple OpenGL program that opens a window, draws a line segment,
and maintains the display.
// Initialization function
void init(void) {
glClearColor(1.0, 1.0, 1.0, 0.0); // Set the background color to white
glMatrixMode(GL_PROJECTION); // Set the matrix mode to projection
gluOrtho2D(0.0, 200.0, 0.0, 150.0); // Define the 2D orthographic projection
}
// Display function
void lineSegment(void) {
glClear(GL_COLOR_BUFFER_BIT); // Clear the display window
glColor3f(0.0, 0.4, 0.2); // Set the drawing color to dark green
// Main function
int main(int argc, char** argv) {
glutInit(&argc, argv); // Initialize GLUT
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); // Set the display mode to
single buffer and RGB color
glutInitWindowPosition(50, 100); // Set the window position
on the screen
glutInitWindowSize(400, 300); // Set the window size
glutCreateWindow("An Example OpenGL Program"); // Create a window with a
title
return 0; // Main function should not return, as GLUT takes over the
program's control flow
}