0% found this document useful (0 votes)
103 views51 pages

Computer Graphics and Multimedia Systems SCS1302: Unit 1

This document provides information about computer graphics and multimedia systems. It outlines the course objectives, which include constructing lines, circles, and shapes, applying 2D and 3D transformations, and developing photo shop applications. It then describes two common line drawing algorithms - DDA and Bresenham's line drawing algorithm. For each algorithm, it provides the steps to draw a line between two points, includes examples to illustrate the process, and notes advantages of Bresenham's algorithm over DDA.

Uploaded by

ss sri
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)
103 views51 pages

Computer Graphics and Multimedia Systems SCS1302: Unit 1

This document provides information about computer graphics and multimedia systems. It outlines the course objectives, which include constructing lines, circles, and shapes, applying 2D and 3D transformations, and developing photo shop applications. It then describes two common line drawing algorithms - DDA and Bresenham's line drawing algorithm. For each algorithm, it provides the steps to draw a line between two points, includes examples to illustrate the process, and notes advantages of Bresenham's algorithm over DDA.

Uploaded by

ss sri
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/ 51

Computer Graphics and

Multimedia Systems
SCS1302
Unit 1
Syllabus

08/02/2021 2018 - 2022 2


Syllabus

08/02/2021 2018 - 2022 3


Course Objective(CO)
CO1: Construct lines and circles for the given input.
CO2: Apply 2D transformation techniques to transform the
shapes to fit them as per the picture definition.
CO3: Construct splines, curves and perform 3D
transformations
CO4: Apply colour and transformation techniques for
various applications.
CO5: Analyse the fundamentals of animation, virtual
reality, and underlying technologies.
CO6: Develop photo shop applications
08/02/2021 2018 - 2022 4
Line Drawing Algorithms
• A line connects two points. It is a basic element in
graphics.
• Line drawing algorithms:
– DDA Algorithm(Digital Differential Analyzer)
– Bresenham’s Line drawing Algorithm

• To draw a line, you need two points between which you


can draw a line
y=mx+c
Where, m is the slope , c is the y intercept
08/02/2021 2018 - 2022 5
Digital Differential Analyzer (DDA) line
drawing algorithm
• The DDA is a scan conversion line algorithm
based on calculating either dy or dx.
• A line is sampled at unit intervals in one
coordinate and corresponding integer values
nearest the line path are determined for other
coordinates.

08/02/2021 2018 - 2022 6


Steps in DDA algorithm
• Get the input of two end points
• Calculate the difference between two end points.
• Based on the calculated difference, If dx >dy, then
number of steps = dx else number of steps =dy
• Calculate the increment in x coordinate and y
coordinate.
• Put the pixel by successfully incrementing x and y
coordinates the drawing of the line.

08/02/2021 2018 - 2022 7


DDA
• DDA Algorithm is the simplest line drawing
algorithm.
• Given the starting and ending coordinates of a
line, DDA Algorithm attempts to generate the
points between the starting and ending
coordinates.

08/02/2021 2018 - 2022 8


Procedure
Given
Starting coordinates = (Xa, Ya)
Ending coordinates = (Xb, Yb)
The points generation using DDA Algorithm involves the following
steps-
Step-01:
 Calculate dx,dy and m from the given input.
These parameters are calculated as-
dx= Xb – Xa
dy=Yb – Ya
m=dy/dx
and
X= Xa
08/02/2021 2018 - 2022 9
Step-02:
 Find the number of steps or points in between
the starting and ending coordinates. 
if (ab (dx) > abs (dy))
Steps = abs (dx);
else
Steps = abs (dy);

08/02/2021 2018 - 2022 10


Step-03:
 Find x increment and y increment, 
Xincrement = dx/steps
Yincrement = dy/steps

08/02/2021 2018 - 2022 11


• Step-04:
• Suppose the current point is (Xk, Yk) and the
next point is (Xk+1, Yk+1).
• Find the next point by following the below
three cases-
• Case 1 : m < 1
• Case 2: m > 1
• Case 3: m = 1
08/02/2021 2018 - 2022 12
08/02/2021 2018 - 2022 13
Step-05:
• Keep repeating Step-04 until the end point is
reached or the number of generated new points
(including the starting and ending points)
equals to the steps count.

08/02/2021 2018 - 2022 14


DDA algorithm

08/02/2021 2018 - 2022 15


08/02/2021 2018 - 2022 16
08/02/2021 2018 - 2022 17
Example 2
Calculate the points between the starting point (5, 6) and ending
point (8, 12).
Given-
• Starting coordinates = (X0, Y0) = (5, 6)
• Ending coordinates = (Xn, Yn) = (8, 12)
Step-01:
 
• Calculate ΔX, ΔY and M from the given input.
• ΔX = Xn – X0 = 8 – 5 = 3
• ΔY =Yn – Y0 = 12 – 6 = 6
• M = ΔY / ΔX = 6 / 3 = 2

08/02/2021 2018 - 2022 18


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.

 
08/02/2021 2018 - 2022 19
08/02/2021 2018 - 2022 20
08/02/2021 2018 - 2022 21
Example 3
Calculate the points between the starting point (5, 6) and
ending point (13, 10).
Given-
• Starting coordinates = (X0, Y0) = (5, 6)
• Ending coordinates = (Xn, Yn) = (13, 10)
Step-01: 
• Calculate ΔX, ΔY and M from the given input.
• ΔX = Xn – X0 = 13 – 5 = 8
• ΔY =Yn – Y0 = 10 – 6 = 4
• M = ΔY / ΔX = 4 / 8 = 0.50

08/02/2021 2018 - 2022 22


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.
08/02/2021 2018 - 2022 23
08/02/2021 2018 - 2022 24
08/02/2021 2018 - 2022 25
Example 4
Calculate the points between the starting point (1, 7) and ending
point (11, 17).
Solution-
Given-
• Starting coordinates = (X0, Y0) = (1, 7)
• Ending coordinates = (Xn, Yn) = (11, 17)
Step-01: 
• Calculate ΔX, ΔY and M from the given input.
• ΔX = Xn – X0 = 11 – 1 = 10
• ΔY =Yn – Y0 = 17 – 7 = 10
• M = ΔY / ΔX = 10 / 10 = 1

08/02/2021 2018 - 2022 26


Step-02: 
• Calculate the number of steps.
• As |ΔX| = |ΔY| = 10 = 10, so number of steps
= ΔX = ΔY = 10
Step-03: 
• As M = 1, so case-02 is satisfied.
• Now, Step-03 is executed until Step-04 is
satisfied.
08/02/2021 2018 - 2022 27
08/02/2021 2018 - 2022 28
08/02/2021 2018 - 2022 29
Bresenham’s Line Drawing
Algorithm
Bresenhams Line Drawing Algorithm
• This algorithm is used for scan converting a line.
• It was developed by Bresenham.
• It is an efficient method because it involves only
integer addition, subtractions, and multiplication
operations.
• These operations can be performed very rapidly
so lines can be generated quickly.

08/02/2021 2018 - 2022 31


Bresenhams Line Drawing Algorithm

08/02/2021 2018 - 2022 32


Bresenhams Line Drawing Algorithm

08/02/2021 2018 - 2022 33


Bresenhams Line Drawing Algorithm

08/02/2021 2018 - 2022 34


Bresenhams Line Drawing Algorithm

08/02/2021 2018 - 2022 35


Bresenhams Line Drawing Algorithm

08/02/2021 2018 - 2022 36


Bresenhams Line Drawing Algorithm

08/02/2021 2018 - 2022 37


Bresenhams Line Drawing Algorithm

08/02/2021 2018 - 2022 38


Bresenhams Line Drawing Algorithm

08/02/2021 2018 - 2022 39


Bresenhams Line Drawing Algorithm

08/02/2021 2018 - 2022 40


Bresenhams Line Drawing Algorithm

08/02/2021 2018 - 2022 41


Bresenhams Line Drawing Algorithm

08/02/2021 2018 - 2022 42


Example- Bresenhams Line drawing

• Given (xa,ya)=(20,10) and


(xb,yb)=(30,18)
Solution:
dx= 30-20 =10
dy= 18-10 = 8
P= 2*dy-dx
= 2*8-10
=6
twody= 2*dy = 2*8 = 16
twodydx= 2*(dy-dx)
= 2*(8-10)
08/02/2021 2018 - 2022
= -4 43
Example- Bresenhams Line drawing

If(20>30)
{ x=20; y=10; xend=30; }
setpixel(20,10);
while(20<30)
{ x=21;
If(6<0)
y=11;
p=6-4 = 2;
}
setpixel(21,11);

08/02/2021 2018 - 2022 44


Example 1- Bresenhams Line drawing

0 6 (21,11)
1 2 (22,12)
2 -2 (23,12)
3 14 (24,13)
4 10 (25,14)
5 6 (26,15)
6 2 (27,16)
7 -2 (28,16)
8 14 (29,17)
9 08/02/2021
10 (30,18)
2018 - 2022 45
Example 1- Bresenhams Line drawing

08/02/2021 2018 - 2022 46


Advantages of Bresenhams Line drawing algorithm
Disadvantage of DDA:
• The accumulation of round of error is successive addition of the floating point increments is used to
find the pixel position but it take lot of time to compute the pixel position.

Advantages of bresenham's line drawing algorithm.

The Bresenham line algorithm has the following advantages:


– An fast incremental algorithm
– Uses only integer calculations

The Bresenham algorithm is another incremental scan conversion algorithm


The big advantage of this algorithm is that it uses only integer calculations such as
addition/subtraction and bit shifting.
The main advantage of Bresenham's algorithm is speed.

The disadvantage of such a simple algorithm is that it is meant for basic line drawing. The "advanced"
topic of antialiasing isn't part of Bresenham's algorithm, so to draw smooth lines, you'd want to look
into a different algorithm.

08/02/2021 2018 - 2022 47


Advantages of bresenham's line drawing algorithm.

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
DDA Algorithm.
•It uses fixed points only.
 
Disadvantages of Bresenham Line Drawing
Algorithm-
 
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.

08/02/2021 2018 - 2022 48


Example 2
• Calculate the points between the starting
coordinates (9, 18) and ending coordinates
(14, 22).

08/02/2021 2018 - 2022 49


Example 2-cont…

08/02/2021 2018 - 2022 50


• https://developerinsider.co/download-turbo-c
-for-windows-7-8-8-1-and-windows-10-32-64-
bit-full-screen
/
• developerinsider.in/turbocpp

08/02/2021 2018 - 2022 51

You might also like