Introduction to
Computer
Graphic
Dr. Abdulkadir Jeilani
Writer, Programmer, Data scientistic, Researcher
Chapter Objectives
1 2 3 4 5
To Describe the To select a suitable To run and To run and To run and
term of Statistics. statistical interpret the interpret the mean interpret the cross
technique in order frequencies of continues or tabulation of
to perform your ordinal variable variables
data analysis
9/3/20XX Presentation Title 2
Define of Computer Graphics
Computer Graphics is
an art of drawing
images(pictures) on
computer screen
using programming
language.
It is a rendering
It involves
tool for
creation,
generation and
manipulation of
manipulation
data.
images.
9/3/20XX Presentation Title 3
Define of Computer Graphics
Resolution:
Computer Computer
The
Graphic: is to Graph: To Graphic: is a
maximum
plot some plot some rendering
number of
points on pixels on a tool for
pixels in a
graph to computer generation of
computer
make an screen to images and
screen
image. make an manipulation
without
image. of images.
overlap.
9/3/20XX Presentation Title 4
Applications of Computer Graphics
CAD
( Computer
Aided Design)
Presentation
Visualization
Graphics
Entertainme Education &
nt Training
Image
Computer Art
processing
9/3/20XX Presentation Title 5
Computer Graphics
• Computers has to care to 2- things
- Pixels ( which pixel to plot )
- Computation
9/3/20XX Presentation Title 6
9/3/20XX Presentation Title 7
Introduction
• Output primitives are the basic geometric structures
which facilitate or describe a scene/picture. Example of
these include:
• points, lines, curves (circles, conics etc), surfaces, fill colour,
character string etc.
Points
• A point is shown
by illuminating a
pixel on the
screen
Lines
• A line segment is completely defined in terms of its two
endpoints.
• A line segment is thus defined as:
Line_Seg = { (x1, y1), (x2, y2) }
Lines
• A line is y
produced by
means of
illuminating a
set of y2
intermediary
pixels
between the y1
two
endpoints.
x
x1 x2
Lines
• Lines is digitized into a set of discrete integer positions
that approximate the actual line path.
• Example: A computed line position of (10.48, 20.51) is
converted to pixel position (10, 21).
Line Drawing Algorithms
• A straight line segment is defined by the coordinate
position for the end points of the segment.
• Given Points (x1, y1) and (x2, y2)
Line Drawing Algorithms
• There are two algorithms for line drawing
• DDA Digital Differential Analyzer
• Bresenham’s Line Drawing Algorithm
9/3/20XX Presentation Title 14
Line
• All line drawing algorithms make use of the
fundamental equations:
• Line Eqn. y = m.x + b
• Slope m = y2 − y1 / x2 − x1 = Δy / Δx
• y-intercept b = y1 − m.x1
• x-interval→Δx = Δy / m
• y-interval→ Δy = m Δx
DDA Algorithm (Digital Differential Analyzer)
• A line algorithm Based on calculating either Δy or Δx
using the above equations.
• There are two cases:
• Positive slope
• Negative slope
DDA- Line with positive Slope
If m ≤ 1 then take Δx = 1
• Compute successive y by
yk+1 = yk + m (1)
• Subscript k takes integer values starting from 1, for the
first point, and increases by 1 until the final end point is
reached.
• Since 0.0 < m ≤ 1.0, the calculated y values must be
rounded to the nearest integer pixel position.
DDA
• If m > 1, reverse the role of x and y and take Δy = 1,
calculate successive x from
xk+1 = xk + 1/m (2)
• In this case, each computed x value is rounded to the
nearest integer pixel position.
• The above equations are based on the assumption that
lines are to be processed from left endpoint to right
endpoint.
DDA
• In case the line is processed from Right endpoint to Left
endpoint, then
Δx = −1, yk+1 = yk − m for m ≤ 1 (3)
or
Δy = −1, xk+1 = xk −1/m for m > 1 (4)
DDA- Line with negative Slope
• If m < 1,
• use(1) [provided line is calculated from left to right] and
• use(3) [provided line is calculated from right to left].
• If m ≥ 1
• use (2) or (4).
Example
• Input coordinates are and calculate the long a of pixels.
•
•
9/3/20XX Presentation Title 21
Example
10
9/3/20XX Presentation Title 22
What are the drawback of DDA algorithm?
• Floating point operations are
expensive
• Rounding round (x), round (y)
9/3/20XX Presentation Title 23
Bresenham’s Line Algorithm
• It is an efficient raster line generation algorithm.
• It can be adapted to display circles and other curves.
• The algorithm
• After plotting a pixel position (xk, yk) , what is the next pixel to
plot?
• Consider lines with positive slope.
Presenter name: Dr. Abdulkadir Jeilani
Thank you Email address: [Link]@[Link] /
[Link]@[Link]
Website: [Link]
9/3/20XX Presentation Title 25