0% found this document useful (0 votes)
28 views249 pages

CG - Unit - 1

Uploaded by

Mayuresh kadam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views249 pages

CG - Unit - 1

Uploaded by

Mayuresh kadam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 249

COMPUTER GRAPHICS

INTRODUCTION TO
C OMPUTER G RAPHICS
INTRODUCTION OF
C OMPUTER G RAPHIC S
 The Process of transformation and
presentation of information in a visual form.

 Ex-Any product(car) manufacturing company - - want


to show the sale of for five years-- charts and
graphs. data in pictorial form.

 A picture can be understood easily just with a single


look.
C OMPUTER G RAPHICS:
 methods for digitally synthesizing and manipulating
visual content.

 Computer Graphics is the creation of pictures with the


help of a computer.

 To create and manipulate pictures on a display


device. It comprises of software techniques to create,
store, modify, represents pictures.
WHY COM PUTER GRAPHIC S
U SED?

 To represent data in pictorial form.

 communication between computer & users.


(interfacing)

 The computer will receive signals from the input


device, and the picture is modified accordingly.
Picture will be changed quickly when we apply
command.(GUI)
Application of computer graphics
Application of Computer Graphics
Computer Art:
create fine and commercial art - animation
packages, paint packages.- provide facilities for
designing object shapes and specifying object
motion. Cartoon drawing, paintings, logo design
Computer Aided Drawing:
Designing of buildings, automobile,
aircraft is done with the help of computer
aided drawing, this helps in providing
minute details to the drawing and
producing more accurate and sharp
drawings with better specifications.
Presentation Graphics:
For the preparation of reports for the financial,
statistical, mathematical, scientific, economic
data for research reports, managerial reports,
moreover creation of bar graphs, pie charts,
time chart, can be done using the tools present
in computer graphics.
Entertainment:
Computer graphics finds a major part of its
utility in the movie industry and game industry.
Used for creating motion pictures , music
video, television shows, cartoon animation
films. In the game industry where focus and
interactivity are the key players, computer
graphics helps in providing such features in the
efficient way.
Games/Movies

Application of Computer Graphics


Visual effects is the process by which
imagery is created or manipulated outside
the context of a live-action shot in
filmmaking and video production. The
integration of live-action footage and other
live-action footage or CGI elements to
create realistic imagery is called VFX
Visualisation:
need of visualisation -in many advance
technologies ,
Data visualisation helps in finding insights of
the data , to check and study the behavior of
processes around us .
Image Processing:
Various kinds of photographs or images
require editing in order to be used in different
places.
Processing of existing images into refined
ones for better interpretation is one of the
many applications of computer graphics.
Machine Drawing:
used for designing, modifying and creation of
various parts of machine, it provides precision and
clarity for safe manufacturing of machine using
these drawings.
Graphical User Interface:
The use of pictures, images, icons, pop-up
menus, graphical objects helps in creating
a user friendly environment, where
working is easy and pleasant, using
computer graphics we can create such an
atmosphere where everything can be
automated and anyone can get the desired
action performed in an easy fashion.
Education:
Computer generated models are extremely useful for
teaching huge number of concepts and fundamentals
in an easy to understand and learn manner. Using
computer graphics many educational models can be
created through which more interest can be generated
among the students regarding the subject.

Training:
Specialised system for training like simulators can be
used for training the candidates in a way that can be
grasped in a short span of time with better
understanding. Creation of training modules using
computer graphics is simple and very useful.
 1. Education and Training: Computer-generated
model of the physical, financial and economic system
is often used as educational aids. Model of physical
systems, physiological system, population trends or
equipment can help trainees to understand the
operation of the system.
 2. Use in Biology: Molecular biologist can display a
picture of molecules and gain insight into their
structure with the help of computer graphics.
 3. Computer-Generated Maps: Town planners and
transportation engineers can use computer-generated
maps which display data useful to them in their
planning work.
APPLICATIONS OF
C OMPU TER G RAPHIC S
 4. Architect: Architect can explore an alternative
solution to design problems at an interactive graphics
terminal. In this way, they can test many more solutions
that would not be possible without the computer.
 5. Presentation Graphics: Example of presentation
Graphics are bar charts, line graphs, pie charts and other
displays showing relationships between multiple
parameters. Presentation Graphics is commonly used to
summarize
 Financial Reports
 Statistical Reports
 Mathematical Reports
 Scientific Reports
 Economic Data for research reports
 Managerial Reports
 Consumer Information Bulletins
 And other types of reports
 6. Computer Art: Computer Graphics are also used
in the field of commercial arts. It is used to generate
television and advertising commercial.
 7. Entertainment: Computer Graphics are now

commonly used in making motion pictures, music


videos and television shows.
 8. Visualization: It is used for visualization of

scientists, engineers, medical personnel, business


analysts for the study of a large amount of
information.
 9. Educational Software: Computer Graphics is

used in the development of educational software for


making computer-aided instruction.
 10. Printing Technology: Computer Graphics is

used for printing technology and textile design.


Application of Computer
Graphics
Photoshop, Sketch, Illustrator,
InDesign, and After Effects are among
the best software for graphic design.
Photoshop. -- graphic editor - used for
image editing. ...
Sketch. - vector-based tool available on
Mac and focuses on web, app, and
interface design. ...
Illustrator. ...
InDesign. ...
After Effects.
Bump mapping is a texture mapping technique
in computer graphics for simulating bumps and
wrinkles on the surface of an object.

Environment mapping is generally the fastest


method of rendering a reflective surface.
The Geometry Engine is a special-purpose VLSI processor for computer graphics.
It is a four-component vector, floating point processor for accomplishing three basic
operations in computer graphics:
• matrix transformations,
• clipping
• and mapping to output device coordinates.

It presents the instruction set of the system, its design motivations and the
Geometry System architecture.
Very Large Scale Integration
By incorporating millions of transistors
into a single chip, integrated circuits (ICs)
are produced.

vlsi
The X Window System (X11) is an open
source, cross platform, client-server
computer software system that provides a
GUI in a distributed network environment.

HCI-Graphics is about the visuals on the


screen.
interaction between human and computer
G R APHIC PR IM ITIV E S
 Primitivelow level object or operation
from which higher-level, more complex
objects and operations can be constructed.

 basic elements, such as lines, curves,


and polygons, which can be combined to
create more complex graphical
images.
Images are two
dimensional
+Y
shapes.
The two axes
we will label as
X (horizontal), Y
Axis
and Y
(vertical).

(0,0) X Axis +X

Two Dimensional Images


Graphics Input / Output
Devices

Locator Devices
When queried, locator devices return a position
and/or orientation.

Mouse Trackball Joystick


Locator Devices
(Continued…)

Tablet

Data Gloves

Virtual Reality Trackers Digitizers


Text input

Keyboard
Image Scanners
Trackers

Scanners
Light Pens Touch Panels

MIDI devices
Camera/Vision Based
We want to draw a rectangle, how
do we describe it to a computer?
1. Define a set
(7,9) (14,9)
of points
(vertices) in 2D
space.
2. Given a set
of vertices, (7,3) (14,3)
draw lines
between
consecutive
vertices.
Vertex (pl. Vertices) - a point in 2 or 3 dimensional space.
1. Bitmap: Record every position
Bitmap - a rectangular array of bits mapped one-to-one with pixels.
2. Vector display: Position
relative

Vector display system - graphical output system that was based on strokes
(as opposed to pixels). Also known as: random, calligraphic, or stroke
displays.
Most common method is the VERTEX
method. Define the object as a set of points with
connectivity information.
Why is connectivity important?

Connectivity - information that defines which


vertices are connected to which other vertices via
edges.
Edge - connects two vertices

Representing Objects
v 4 e 4
7 3
7 9
14 9
14 3
1 2 (7,9) (14,9)
2 3
3 4
4 1

(7,3) (14,3)

Model file for rectangle


How do we do this?
1. Text Mode :
In this mode the display screen consists of an array
of characters that holds one AS C I I character.

2. Graphics Mode :
In this mode display screen consists of an array of
pixels. Number of different shapes of an object can be
displayed.

2. M ODES
Basic Concept in Computer
Graphics
Pixel
- The most basic addressable image
element in a screen
CRT - Color triad (RGB phosphor dots)
LCD - Single color element
 Pixel :
a pixel is the smallest piece of information in an image.

Pixels are normally arranged in a regular 2D grid,
and are often represented using dots or squares.

BASIC TERMIN OLO GY


 Each pixel is a sample of an original image, where more
samples typically provide a more accurate representation
of the original.

The intensity of each pixel is variable; in color
systems, each pixel has typically three or four
components such as red, green, and blue, or cyan,
magenta, yellow, and black.
 Resolution is the number of rows that appear from top to
bottom of a screen and in turn the number of pixels or pixel
elements that appear from left to right on each scan line.

 Based on this resolution only the effect of picture appears


on screen.

 In other words greater the resolution greater will be the clarity


of picture. That is resolution value is directly proportional to
clarity of picture.

R E S O LU TION
 Actual resolution is determined by
the video controller.
⚫ Most monitors can operate at several different
resolutions. They are
⚫ 640 X 480
⚫ 800 X 600
⚫ 1024 X 768
⚫ 1152 X 864
⚫ 1280 X 1024
 As the resolution increases, image on
the screen gets smaller.
ASPECT RATIO
Aspect ratio ->horizontal and vertical sizes of computer
graphics.
 Aspect ratio plays an important role in resizing. During resizing, the

aspect ratio must remain same in order to keep the image undistorted.
A distorted aspect ratio leads to stretching of the image.
Screen Resolution - measure of number of
pixels on a screen (x by y)
x - Horizontal screen resolution
y - Vertical screen resolution
e.g. 640 x 480, 1024 x 768 etc
number of pixels across the length and
width of a digital image
Dots per inch is a measure of spatial
printing, video or image scanner dot
density, in particular the number of
individual dots that can be placed in a line
within the span of 1 inch.
PPI describes the resolution in pixels of a digital
image whereas DPI describes the amount of ink
dots on a printed image.
Pitch - Size of a pixel, distance from center
to center of individual pixels.
Rasterisation

Task of taking an image &


described in a format
(shapes) and converting
it into a (pixels or dots)
for output on a video
display or printer, or for
storage in a bitmap file
format.
Aspect ratio
• proportional relationship between
an image's width and height.

• it describes an image's shape.


• Aspect ratios= width / height,
Ex- 3:2
F RAME BU FFER

•A framebuffer (frame buffer, or


sometimes framestore) is a portion of
random-access memory (RAM)
containing a bitmap that drives a video
display.
•It is a memory buffer containing data
representing all the pixels in a complete
video frame.
Frame buffer
A frame buffer is a large, contiguous piece
of memory.
The picture is built up in the frame buffer one
bit at a time.
A memory bit has only two states black or
white display
• frame buffer -digital device and the CRT-
an analog device.
• Therefore, a conversion from a digital to
analog signal - when information is read
from the frame buffer and displayed on the
raster CRT graphics device.
• For this- digital to analog converter (DAC).
• Each pixel in the frame buffer must be
accessed and converted before it is visible
on the raster CRT.
 Simple color frame buffer is implemented with
three bit planes, one for each primary color. Each
bit plane drives an individual color gun for each of
the three primary colors used in color video. These
three primaries (red, green, and blue) are
combined at the CRT to yield eight colors.
Display Devices
DISPLAY ADAPTERS
Desktop computer that makes use of a

plug-in- card which performs graphics


processing is display adapters.
Most commonaly referred to as “

Graphics Card” or “Video Card” Display


Settings.
The display settings determine how

much information a video adapter


and driver display and how that
information is updated.
DISPLAY DEVICES
CRT

C RTstands for Cathode Ray Tube.
 used in traditional computer monitors

and televisions.
 firing electrons from the back of the tube

of phosphorus located towards the


front of the screen.
 Once the electron heats the phosphorus,

they light up, and they are projected on a


screen.
 Color on screen is produced by a blend

of red, blue and green light .


C ATHODE RAY TU BE (CRT)
C OMPONENTS OF C R T:
 1. Electron Gun: series of elements, primarily a
heating filament (heater) and a cathode.
creates a source of electrons which are focused into a
narrow beam directed at the face of the CRT.
 2. Control Electrode: electron beam on and off.
 3. Focusing system: f ocusing the electrons into a
narrow beam.
 4. Deflection Yoke: control the direction of the electron
beam.

 5. Phosphorus-coated screen-Phosphors glow when a


high-energy electron beam hits them.
Cathode Ray Tubes (CRTs)
Heating element on the yolk.
Phosphor coated screen
Electrons are boiled off the filament
and drawn to the focusing system.
The electrons are focused into a
beam and “shot” down the cylinder.
The deflection plates “aim” the
electrons to a specific position on the
screen.
CRT Phosphor
Screen
The screen is coated with
phosphor, 3 colors for a
color monitor, 1 for
monochrome.
For a color monitor, three
guns light up red, green,
or blue phosphors.
Intensity is controlled by
the amount of time at a
specific phosphor location.
REFRESH RATE

 The refresh rate of a display is the number of


times per second that the image refreshes on
the screen.

 Forexample, a 60Hz display will update the


screen 60 times per second. Overall, the
refresh rate determines how smoothly motion
appears on your screen.
 What is frequency?
 ElectricalAlternating current (ac) frequency is the number
of cycles per second in an ac sine wave. Frequency is the
rate at which current changes direction per second. It is
measured in hertz (Hz), an international unit of measure
where 1 hertz is equal to 1 cycle per second.
 Hertz (Hz) = One hertz is equal to one cycle per second.
 Cycle = One complete wave of alternating current or
voltage.
 Alternation = One half of a cycle.
 Period = The time required to produce one complete
cycle of a waveform.
 MDA( Monochrome Display Adapter)
 CGA(Color Graphics Adapter)

 EGA(Enhanced Graphics Adapter)

 VGA(Video Graphics Array)

 SVGA(Super Video Graphics Array)

 XGA(Extended Graphics Array)

G RAPHICS ADAPTERS L IST


 Random Scan System uses an electron beam
which operates like a pencil to create a line
image on the C RT screen.
 The picture is constructed out of a sequence of

straight-line segments.
 Each line segment is drawn on the screen by

directing the beam to move from one point on the


screen to the next, where its x & y coordinates
define each point.
 After drawing the picture. The system cycles back to

the first line and design all the lines of the image 30
to 60 time each second.
 The process is shown in fig:

RANDOM S CAN DISPLAY:


RANDOM S CAN PROCESS
RASTER S CAN DISPLAY:
 A Raster Scan Display is based on intensity control of
pixels in the form of a rectangular box called Raster on
the screen. Information of on and off pixels is stored in
refresh buffer or Frame buffer.
 Televisions in our house are based on Raster Scan
Method.
 The raster scan system can store information of each
pixel position, so it is suitable for realistic display
of objects. Raster Scan provides a refresh rate of 60 to
80 frames per second.
Beam refreshing is of two types.
  horizontal retracing and  vertical retracing.

 When the beam starts from the top left
corner and reaches the bottom right scale, it
will again return to the top left side called at
vertical retrace.
 Then it will again more horizontally from
top to bottom call as horizontal retracing
shown in fig:
P R O C E SS
D IF F E R E N TIATE BETW E E N R AND OM
AND
R ASTER S C A N D IS PLAY:
Beam Movement
 The CRT Monitor display by using a
combination of phosphors. The phosphors
are different colors. There are two popular
approaches for producing color displays
with a CRT are:
 1.Beam Penetration Method

 2. Shadow-Mask Method

C OLOR C R T M ONITORS
1. BEAM PENETRATION
M ETHOD:
 The Beam-Penetration method has been used with random-
scan monitors.
 In this method, the C RT screen is coated with two layers
of phosphor, red and green and the displayed color
depends on how far the electron beam penetrates the
phosphor layers
 This method produces four colors only, red, green, orange and
yellow.
 A beam of slow electrons excites the outer red layer only;
hence screen shows red color only. A beam of high-speed
electrons excites the inner green layer. Thus screen
shows a green color.
2.S HADOW-M ASK M ETHOD:
 Shadow Mask Method is commonly used in Raster-Scan
System because they produce a much wider range of
colors than the beam-penetration method.
 It is used in the majority of color TV sets and monitors.
 Construction: A shadow mask C RT has 3 phosphor color
dots at each pixel position.
 One phosphor dot emits: red light
 Another emits: green light
 Third emits: blue light
 This type of C RT has 3 electron guns, one for each color dot
and a shadow mask grid just behind the phosphor coated
screen.
Shadow mask grid is pierced {to manage to go through or into something वस्‍तु में से
गुज़र जाना }with small round holes in a triangular pattern.
Figure shows the delta-delta shadow mask method
commonly used in color C RT system.
प्रकाशाचे ध्रुवीकरण
What is meant by polarization of light?
Hint: Polarisation of light is a property
shown by transverse waves. The light
waves which travel only in a single plane
are known as polarized light waves. The
process of transforming unpolarized light
waves to polarized light waves is called
the polarisation of light.
Polarization, in Physics, is defined as a
phenomenon caused due to the wave
nature of electromagnetic radiation.
A polarizer is a material which allows
passing the light from it having a certain
direction only.
Light with remaining angle is blocked.
Also divided into pixels, but without an
electron gun firing at a screen, LCDs have
cells that either allow light to flow
through, or block it.

Liquid Crystal Displays (LCDs)


 Advantages:
 A C RT has the electron beam directed only to the

parts of the screen where an image is to be


drawn.
 Produce smooth line drawings.

 High Resolution

 Disadvantages:
 Random-Scan monitors cannot display realistic

shades scenes.

ADVANTAGES AND
DISADVANTAGES
DIRECT VIEW S TORAG E
TU BES:
 DVST terminals also use the random scan approach to
generate the image on the C RT screen. The term
"storage tube" refers to the ability of the screen to
retain the image which has been projected against it,
thus avoiding the need to rewrite the image constantly.
 Function of guns: Two guns are used in DVST

 Primary guns: It is used to store the picture

pattern.
 Flood gun or Secondary

gun: It is used to maintain


picture display.
 The Flat-Panel display refers to a class of video
devices that have reduced volume, weight and
power requirement compare to CRT.
 Example: Small T.V. monitor, calculator, pocket

video games, laptop computers, an advertisement


board in elevator.

F LAT PANEL DISPLAY:


 1. Emissive Display: The emissive displays are
devices that convert
electrical energy into light. Examples are
Plasma Panel, thin film electroluminescent
display and L E D (Light Emitting Diodes).
 2. Non-Emissive Display: The Non-Emissive

displays use optical effects to convert sunlight


or light from some other source into graphics
patterns. Examples are L C D (Liquid Crystal
Device).
PLASM A PANEL DISPLAY:
 Plasma-Panels are also called as Gas-Discharge
Display. It consists of an array of small lights. Lights
are fluorescent in nature. The essential components of
the plasma-panel display are:
 1.Cathode: It consists of fine wires. It delivers
negative voltage to gas cells. The voltage is released
along with the negative axis.
 2.Anode: It also consists of line wires. It delivers
positive voltage. The voltage is supplied along positive
axis.
 3.Fluorescent cells: It consists of small pockets of
gas liquids when the voltage is applied to this liquid
(neon gas) it emits light.
 4.Glass Plates: These plates act as capacitors. The
voltage will be applied, the cell will glow
continuously.
 The gas will slow when there is a significant voltage
difference between horizontal and vertical wires. The
voltage level is kept between 90 volts to 120 volts. Plasma
level does not require refreshing. Erasing is done by
reducing the voltage to 90 volts.
 Each cell of plasma has two states, so cell is said to be
stable. Displayable point in plasma panel is made by the
crossing of the horizontal and vertical grid. The resolution
of the plasma panel can be up to 512 * 512 pixels.
 Figure shows the state of cell in plasma panel
display:
 In an L E D, a matrix of diodes is organized to
form the pixel positions in the display and picture
definition is stored in a refresh buffer.

 Data is read from the refresh buffer and


converted to voltage levels that are applied to the
diodes to produce the light pattern in the display.

L E D (LIG HT E MITTING
DIODE):
L C D (LIQU ID C RYSTAL
DISPLAY):
 Liquid Crystal Displays are the devices that produce a
picture by passing polarized light from the surroundings
or from an internal light source through a liquid-crystal
material that transmits the light.
 L C D uses the liquid-crystal material between two glass
plates; each plate is the right angle to each other between
plates liquid is filled. One glass plate consists of rows of
conductors arranged in vertical direction. Another glass
plate is consisting of a row of conductors arranged in
horizontal direction. The pixel position is determined by
the intersection of the vertical & horizontal conductor.
This position is an active part of the screen.
 Liquid crystal display is temperature dependent. It is
between zero to seventy degree Celsius. It is flat and
requires very little power to operate.
Reflective Projection System Transmittive Projection
System

Basic Projector Designs


(Images from Phillips Research)
 Head-Mounted Displays (HMDs)
◦ The display and a position tracker are attached to the
user’s head
 Head-Tracked Displays (HTDs)
◦ Display is stationary, tracker tracks the user’s head
relative to the display.
◦ Example: CAVE, Workbench, Stereo monitor

Displays in Virtual Reality


3D Glasses

3D Display

3D Object
Graphics Memory 16
Original
colors
256 colors
LEDs work on the principle of Electroluminescence.
On passing a current through the diode, minority charge carriers and majority
charge carriers recombine at the junction.
On recombination, energy is released in the form of photons.
INTRODUCTION TO O PEN G L
 OpenGL (Open Graphics Library) is a software interface to graphics
hardware.

 The interface consists of over 250 different function calls which can be
used to draw complex two and three-dimensional scenes from simple
geometric primitives such as points, lines, and polygons.

 There are also routines for rendering the scenes with control over
lighting, object surface properties, transparency, anti- aliasing and texture
mapping.

 OpenGL was developed by Silicon Graphics Inc. in 1992 to be a more


'open' (portable) version of their early SGI GL Graphics Library.

 OpenGL is designed as a streamlined, hardware-independent interface
to be implemented on many different graphics hardware platforms.
 A common way to utilize the OpenGL graphics library of routines is by
making calls to the routines from C programs. In order to utilize the
OpenGL library,

 you will need to #include <GL/gl.h> in your C program. All OpenGL


library functions begin with the letters gl and capitalize words (example
functions: glClear, glClearColor, and codeglVertex2f).
The OpenGL library provides a powerful but primitive set of rendering
commands. Higher level libraries provide additional functionality.
These include:
 OpenGL Utility Toolkit (GLUT) The GLUT is a window system-
independent toolkit written to hide the complexities of differing window
system APIs.

 It is much easier to use and more portable but far less featured than the GLX
library. Functions performed include window definition, window control, and
monitoring of keyboard and mouse input.

 GLUT also has limited support for creating pop-up menus. If you are going
to use the GLUT library you will need use #include <GL/glut.h> instead of
#include
 Routines in the OpenGL graphics library can be called from
most major languages.

 Window management is not supported in the basic version of


OpenGL but there are additional libraries built on top of
OpenGL

 which you can use for many of the things which OpenGL
itself does not support.
 OpenGL Utility Library (GLU)

 The GLU is included with OpenGL and built using low-level OpenGL
commands.
 It contains routines for setting up viewing and projection matrices,
polygonal tesselation and surface rendering.
 When using the GLU library you will need to #include
<GL/glu.h> in your program. GLU routines begin with the prefix glu.
 OpenGL Extension to the X Window System (GLX)OpenGL does not
include any routines for handling windowing operations so the GLX was
developed to fill this gap with regard to the X Window System.

 Using GLX, you can enable your OpenGL programs to draw into a
window under the X Window System. GLX routines begin with the
prefix glx.

 <GL/gl.h> in your program (Note that glut.h includes


gl.h, glu.h, and glx.h automatically). GLUT routines begin with the
prefix glut.
1) S CAN C ONVERSION :

 Display processor digitizes a picture definition


given in an application program into a set of pixel
intensity values for storage in the frame buffer.
 This digitization process is called scan conversion.
 Point can be specified by giving pair of numbers (x, y),
where x represents horizontal distance and y
represents vertical distance. Every line is described by
the equation such that if a point (x, y) satisfies the
equation, then that point is on the line. If the two
points used to specify a line are (x1, y1) and (x2, y2)
then the equation of line will be,

L IN ES AND L IN E
S EGM EN TS:
 Above equation justify that slope between any point on
the line and point (x1, y1) is the same as the slope
between (x1, y1) and (x2, y2). Slope is usually denoted
by m and is defined as the change in height divided by
the change in width for any two points on the line.
Slope m is defined in equation form as follows:
 There is a difference between line and line segment. The lines can
extend forever both forward and backward direction but a line
segment is a piece of line lying in between two end points P1 and
P2. If the end points are P1 = (x1, y1) and (x1, y1) = (x2, y2) and
these two points yield a equation y = mx +b then point P3 = (x3,
y3) lies on the segment if y3 = m x3 + b, x3 is in between x1 and
x2 and y3 is in between y1 and y2. We can identify where two
lines are intersecting. Two lines are crossing or intersecting
means they share common point. That point satisfies the equation
for both the lines. The intersection point is given by below
equation:
3) VECTORS AND VECTOR
G EN ERATION:
 Vector has a single direction and length.
A vector is denoted by [Dx, Dy], where Dx
indicates how far to move in x-axis
direction and Dy indicates how far to
move in y-axis direction. Vectors specify
how far and in what direction to move,
but don’t specify from where to start.
 If vector V1 = [Dx1, Dy1] and
= [Dx1 + Dx2, Dy1 + Dy2 ]
 vector V2 = [Dx2, Dy2]

 then resultant vector can be derived as:

 V1 + V2 = [Dx1, Dy1] + [Dx2, Dy2]


 We can multiply vector by a number and length of the vector can be given

by Pythagorean
theorem.

 If we multiply a vector by reciprocal of its length then the resultant


vector is of length equal to 1 and such a vector is called unit vector.
The process of “Turning ON” the pixels for a line segment is called
a vector generation. Whenever we need to draw a line, we need to
turn ON the pixels on that line i.e. we need to change the intensity
of the pixels present on the line. Two well known algorithms used
for vector generation are Digital Differential Analyzers (DDA) and
Bresenhans Line Drawing Algorithm. Both the algorithms make use
of increment method.
DDA
L IN E DRAWING
 Bresenham’s Line Drawing Algo

ALGO RITHMS
DDA stands for Digital Differential Analyzer.

It is an incremental method of scan conversion of line.

In this method calculation is performed at each step but


by using results of previous steps.
 Procedure-
 Given-
 Starting coordinates = (X 0 , Y0)
 Ending coordinates = (X n , Yn )

 The points generation using D DA Algorithm involves


the following steps-

 Step-01:
 Calculate Δ X, Δ Y and M from the given input.
 These parameters are calculated as-
 Δ X = X n – X0
 Δ Y =Y n – Y 0 DDA
 M = ΔY / ΔX
 Step-02:

 Find the number of steps or points in between
the starting and ending coordinates.

 if (absolute (ΔX) > absolute (ΔY))
 Steps = absolute (ΔX);

 else

 Steps = absolute (ΔY);


 Step-03:
 Suppose the current point is (X , Y ) and the next
p p
point is (Xp+1 , Yp+1 ).
 Find the next point by following the below three
cases-
 Step-04:

 Keep repeating Step-03 until the end point is


reached or the number of generated new points
(including the starting and ending points) equals
to the steps count.
P R A C T I C E P R O B L E M S B A S E D O N D DA
A LG O R I T H M -
 Problem-01:
 Calculate the points between the starting point (5, 6)
and ending point (8, 12).

 Solution-
 Given-
 Starting coordinates = (X 0 , Y0 ) = (5, 6)
 Ending coordinates = (X n , Y n ) = (8, 12)

 Step-01:
 Calculate Δ X, Δ Y and M from the given input.
 ΔX = Xn – X0 = 8 – 5 = 3
 Δ Y =Y n – Y 0 = 12 – 6 = 6
 M = ΔY / ΔX = 6 / 3 = 2
 Step-02:
 Calculate the number of steps.

 As | Δ X | < | Δ Y | = 3 < 6, so number of steps =

ΔY
=6

 Step-03:
 As M > 1, so case-03 is satisfied.

 Now, Step-03 is executed until Step-04 is

satisfied.
 Problem-02:

 Calculate the points between the starting point (5, 6)


and ending point (13, 10).

 Solution-

 Given-
 Starting coordinates = (X 0 , Y0 ) = (5, 6)
 Ending coordinates = (X n , Y n ) = (13, 10)

 Step-01:
 Calculate Δ X, Δ Y and M from the given input.
 Δ X = X n – X 0 = 13 – 5 = 8
 Δ Y =Y n – Y 0 = 10 – 6 = 4
 M = Δ Y / Δ X = 4 / 8 = 0.50
 Step-02:
 Calculate the number of steps.

 As | Δ X | > | Δ Y | = 8 > 4, so number of steps =

ΔX
=8

 Step-03:
 As M < 1, so case-01 is satisfied.

 Now, Step-03 is executed until Step-04 is

satisfied.
To chooses the next one between the bottom pixel S and top pixel T.
If S is chosen(case 1)
We have xi+1=xi+1 and yi+1=yi
If T is chosen(case 2)
We have xi+1=xi+1 and yi+1=yi+1
 Procedure-

 Given-
 Starting coordinates = (X , Y )
0 0

 Ending coordinates = (X n , Yn )

 The points generation using Bresenham Line


Drawing Algorithm involves the following steps-
BRESENHAM L INE
DRAWING ALG ORITHM
 Step-01:

 Calculate Δ X and Δ Y from the given input.


 These parameters are calculated as-

 ΔX = X – X
n 0

 Δ Y =Y n – Y 0

 Step-02:

 Calculate the decision parameter P k .


 It is calculated as- P k = 2 Δ Y – Δ X
 Step-03:
 Suppose the current point is (X , Y ) and the next
k k
point is (X k+1 , Y k+1 ).
 Find the next point depending on the value of
decision
parameter P k .
 Follow the below two cases-
 Step-04:

 Keep repeating Step-03 until the end point is


reached or number of iterations equals to (ΔX-1)
times.
 Problem-01:
 Calculate the points between the starting coordinates

(9, 18) and ending coordinates (14, 22).

 Solution-
 Given-

 Starting coordinates = (X , Y ) = (9, 18)


0 0

 Ending coordinates = (X n , Y n ) = (14, 22)

 Step-01:
 Calculate Δ X and Δ Y from the given input.

 Δ X = X – X = 14 – 9 = 5
n 0

 Δ Y =Y n – Y 0 = 22 – 18 = 4
 Step-02:
 Calculate the decision parameter.
 P k = 2ΔY – Δ X
 =2x4–5
 =3
 So, decision parameter P k = 3

 Step-03:
 As P k >= 0, so case-02 is satisfied.

 Thus,
 P k + 1 = P k + 2 Δ Y – 2 Δ X = 3 + (2 x 4) – (2 x 5) = 1
 X k + 1 = X k + 1 = 9 + 1 = 10
 Y k + 1 = Y k + 1 = 18 + 1 = 19

 Similarly, Step-03 is executed until the end point is
reached or number of iterations equals to 4 times.
 (Number of iterations = Δ X – 1 = 5 – 1 = 4)
 Problem-02:

 Calculate the points between the starting coordinates
(20, 10) and ending coordinates (30, 18).

 Solution-

 Given-
 Starting coordinates = (X 0 , Y0 ) = (20, 10)
 Ending coordinates = (X n , Y n ) = (30, 18)

 Step-01:

 Calculate Δ X and Δ Y from the given input.
 Δ X = X n – X 0 = 30 – 20 = 10
 Δ Y =Y n – Y 0 = 18 – 10 = 8
 Step-02:

 Calculate the decision parameter.
 Pk
 = 2ΔY – ΔX
 = 2 x 8 – 10
 =6
 So, decision parameter P k = 6

 Step-03:

 As P k >= 0, so case-02 is satisfied.

 Thus,
 P k + 1 = P k + 2 Δ Y – 2 Δ X = 6 + (2 x 8) – (2 x 10) = 2
 X k + 1 = X k + 1 = 20 + 1 = 21
 Y k + 1 = Y k + 1 = 10 + 1 = 11

 Similarly, Step-03 is executed until the end point is reached or
number of iterations equals to 9 times.
 (Number of iterations = Δ X – 1 = 10 – 1 = 9)
A D VAN TAG ES O F B R E S E N H AM L I N E
D R AWIN G A L G O R ITH M -
 The advantages of Bresenham Line Drawing Algorithm
are-
 It is easy to implement.

 It is fast and incremental.

 It executes fast but less faster than DDA

Algorithm.
 The points generated by this algorithm are more accurate

than D DA Algorithm.
 It uses fixed points only.

 It involves only integer arithmetic, so it is simple.

 It avoids the generation of duplicate points.

 It can be implemented using hardware because it does not use


D ISA D VAN TAG ES O F B R E S E N H AM L I N E
D R AWIN G A L G O R ITH M -
 The disadvantages of Bresenham Line Drawing
Algorithm are-
 Though it improves the accuracy of generated

points but still the resulted line is not smooth.


 This algorithm is for the basic line drawing.

 It can not handle diminishing jaggies.


C IR C L E D R AWIN G AL G OR ITHM S-
 Given the centre point and radius of circle,
 Mid Point Circle Drawing Algorithm attempts to

generate the points of one octant.

M ID P O I N T C IR C L E D R AWIN G
A L G O R ITH M -
 Procedure-

 Given-
 Centre point of Circle = (X 0 , Y0)
 Radius of Circle = R

 The points generation using Mid Point Circle Drawing
Algorithm involves the following steps-

 Step-01:

 Assign the starting point coordinates (X 0 , Y0) as-
 X0 = 0
 Y0 = R
 Step-02:

 Calculate the value of initial decision parameter P 0 as-
 P0 = 1 – R
 Step-03:
 Suppose the current point is (X , Y ) and the next
k k
point is (X k+1 , Y k+1 ).
 Find the next point of the first octant depending
on the
value of decision parameter P k .
 Follow the below two cases-
 Step-04:
 If the given centre point (X , Y ) is not (0, 0), then
0 0
do the following and plot the point-
 X
plot = X c + X 0

 Y plot = Y c + Y 0

 Here, (X c , Yc ) denotes the current value of X and
Y coordinates.

 Step-05:

 Keep repeating Step-03 and Step-04 until X plot >=
Y plot .
 Step-06:
 Step-05 generates all the points for one octant.
 To find the points for other seven octants, follow the eight symmetry
property of circle.
 This is depicted by the following figure-
P R AC T I C E P RO B L E M S BASED O N MID
P O I N T C I R C L E D R AW I N G
A LG O R I T H M -
 Problem-01:

 Given the centre point coordinates (0, 0) and radius as 10,
generate all the points to form a circle.

 Solution-

 Given-
 Centre Coordinates of Circle (X 0 , Y0 ) = (0, 0)
 Radius of Circle = 10

 Step-01:

 Assign the starting point coordinates (X 0 , Y0 ) as-
 X0 = 0
 Y 0 = R = 10
 Step-02:

 Calculate the value of initial decision parameter
P 0 as-
 P0 = 1 – R
 P 0 = 1 – 10
 P 0 = -9

 Step-03:

 As P initial < 0, so case-01 is satisfied.

 Thus,
 Xk + 1 = X k + 1 = 0 + 1 = 1
 Y k + 1 = Y k = 10
 P k + 1 = P k + 2 x X k + 1 + 1 = -9 + (2 x 1) + 1 = -6
 Step-04:
 This step is not applicable here as the given centre point
coordinates is (0, 0).
 Step-05:
 Step-03 is executed similarly until X k + 1 >= Y k + 1 as follows-
 Algorithm calculates all the points of octant-1 and terminates.
 Now, the points of octant-2 are obtained using the mirror effect by
swapping X and Y coordinates.
 Now, the points for rest of the part are generated by following the signs of other
quadrants.
 The other points can also be generated by calculating each octant separately.
 Here, all the points have been generated with respect to quadrant-1-
 The advantages of Mid Point Circle Drawing
Algorithm are-
 It is a powerful and efficient algorithm.

 The entire algorithm is based on the simple

equation of circle X 2 + Y 2 = R 2 .
 It is easy to implement from the programmer’s

perspective.
 This algorithm is used to generate curves on

raster displays.
A D VAN TAG ES O F M ID P O I N T C I R C L E
D R AWIN G A L G O R ITH M -
 The disadvantages of Mid Point Circle Drawing
Algorithm are-
 Accuracy of the generating points is an issue in

this algorithm.
 The circle generated by this algorithm is not

smooth.
 This algorithm is time consuming.

D ISA D VAN TAG ES O F M ID P O I N T C IR C L E


D R AWIN G A L G O R ITH M -
 Circle drawing algorithms take the advantage of
8 symmetry property of circle.
 Every circle has 8 octants and the circle drawing
algorithm generates all the points for one octant.
 The points for other 7 octants are generated by
changing the sign towards X and Y coordinates.
 To take the advantage of 8 symmetry property,
the circle must be formed assuming that the
centre point coordinates is (0, 0).
 If the centre coordinates are other than (0, 0),
then we add the X and Y coordinate values with
IMPOR
each pointTANT P OIN
of circle with TS
the coordinate values
generated by assuming (0, 0) as centre point.
B R E S E N H AM C IR C L E D R AWIN G
A L G O R ITH M -
 Given the centre point and radius of circle,
 Bresenham Circle Drawing Algorithm attempts to generate
the points of one octant.
 Procedure-
 Given-
 Centre point of Circle = (X 0 , Y0)
 Radius of Circle = R
 The points generation using Bresenham Circle Drawing
Algorithm involves the following steps-

 Step-01:
 Assign the starting point coordinates (X 0 , Y0) as-
 X0 = 0
 Y0 = R

 Step-02:
 Calculate the value of initial decision parameter P 0 as-
 P =3–2xR
 Step-03:
 Suppose the current point is (X k , Y k ) and the next point is (X k+1 , Yk+1 ).
 Find the next point of the first octant depending on the value of decision
parameter P k .
 Follow the below two cases-
 Step-04:

 If the given centre point (X 0 , Y0) is not (0, 0), then do the
following and plot the point-

X plot = X c + X 0

 Y plot = Y c + Y 0
 Here, (X c , Yc) denotes the current value of X and Y
coordinates.

 Step-05:

 Keep repeating Step-03 and Step-04 until Xplot => Y plot .

 Step-06:

 Step-05 generates all the points for one octant.
 To find the points for other seven octants, follow the eight
symmetry property of circle.
 Problem-01:
 Given the centre point coordinates (0, 0) and radius as 8,
generate all the points to form a circle.

 Solution-
 Given-
 Centre Coordinates of Circle (X 0 , Y0) = (0, 0)
 Radius of Circle = 8

 Step-01:
 Assign the starting point coordinates (X 0 , Y0) as-
 X0 = 0
 Y0 = R = 8

 Step-02:
 Calculate the value of initial decision parameter P 0 as-
 P0 = 3 – 2 x R
 P0 = 3 – 2 x 8
 P 0 = -13
 Step-03:
 As P initial < 0, so case-01 is satisfied.
 Thus,
 Xk + 1 = X k + 1 = 0 + 1 = 1
 Yk + 1 = Y k = 8
 P k + 1 = P k + 4 x X k + 1 + 6 = -13 + (4 x 1) + 6 = -3

 Step-04:

 This step is not applicable here as the given centre


point coordinates is (0, 0).

 Step-05:
 Step-03 is executed similarly until X k + 1 >= Y k + 1 as
follows-
 Algorithm calculates all the points of octant-1 and
terminates.
 Now, the points of octant-2 are obtained using the
mirror effect by swapping X and Y coordinates.
 Now, the points for rest of the part are generated by following the signs
of other quadrants.
 The other points can also be generated by calculating each octant
separately.
 Here, all the points have been generated with respect to quadrant-1-
A D VAN TAG ES O F B R E S E N H AM C IR C L E
D R AWIN G A L G O R ITH M -
 The advantages of Bresenham Circle Drawing
Algorithm are-
 The entire algorithm is based on the simple

equation of circle X 2 + Y 2 = R 2 .
 It is easy to implement.
 The disadvantages of Bresenham Circle
Drawing Algorithm are-
 Like Mid Point Algorithm, accuracy of the
generating points is an issue in this
algorithm.
 This algorithm suffers when used to

generate
complex and high graphical images.
 There is no significant enhancement with

respect to performance.
D ISA D VAN TAG ES O F B R E S E N H AM C IR C L E
D R AWIN G A L G O R ITH M -
ALIASIN G
 In computer graphics, the process by which smooth
curves and other lines become jagged because the
resolution of the graphics device or file is not high
enough to represent a smooth curve.
 In the line drawing algorithms, we have seen that

all rasterized locations do not match with the true


line and we have to select the optimum raster
locations to represent a straight line. This problem
is severe in low resolution screens. In such screens
line appears like a stair-step, as shown in the figure
below. This effect is known as aliasing.
ANTIALIASING M ETHODS

You might also like