SlideShare une entreprise Scribd logo
1  sur  121
Télécharger pour lire hors ligne
COMPUTER GRAPHICS AND
IMAGE PROCESSING
MODULE I
Module – 1(Basics of Computer graphics and
Algorithms)
• Basics of Computer Graphics and its applications.
Video Display devices- Refresh Cathode Ray Tubes,
Random Scan Displays and systems, Raster scan
displays and systems.
• Line drawing algorithms- DDA, Bresenham’s algorithm.
Circle drawing algorithms- Midpoint Circle generation
algorithm, Bresenham’s algorithm.
• Business visualization- Data sets related to
commerce, industry etc
VIDEO DISPLAY DEVICES
Electron Gun
RASTER AND RANDOM SCAN DEVICES
RASTER SCAN SYSTEMS
• 1. Beam Penetration Method :
Beam Penetration Method is quite similar to the normal CRT and it uses only one electron
gun. In this, different colors of multi-layered are coated on inner surface of screen,
normally the two layers of phosphorus i.e., red and green are coated. It is a method used
for displaying color pictures that has been used with random scan monitors.
• 2. Shadow Mask Method :
Shadow Mask Method is the method which is used in raster scan system which includes
color TVs. In this the pixel is made up of three -colors. So due to three colors it uses three
electron guns one for producing each color. The colors are red, green and blue. In this the
important consideration for a color monitor is the setting of electron guns and the
phosphor dots forming a pixel.
Line drawing algorithms
• The Line drawing algorithm is a graphical algorithm which is used to
represent the line segment on discrete graphical media, i.e., printer and
pixel-based media.
• A line contains two points. The point is an important element of a line
Equation of the straight line
We can define a straight line with the help of the following equation.
y= mx + a
• Where,
3 cases
m=1, m< 1, m>1
DDA (Digital Differential Analyzer)
• Simplest line drawing algorithm.
• Digital Differential Analyzer algorithm is also known as an incremental
method of scan conversion. Previous step results are used in the next
step.
• Digital Differential Analyzer algorithm is used to perform rasterization
on polygons, lines, and triangles etc
Algorithm of Digital Differential Analyzer (DDA) Line Drawing
Step 1: Start.
Step 2: We consider Starting point as (x1, y1), and ending point (x2, y2).
Step 3: Now, we have to calculate Δx and Δy.
Δx = x2-x1
Δy = y2-y1
m = Δy/Δx
Step 4: Now, we calculate three cases.
If m < 1
Then x change in Unit Interval
y moves with deviation
(xk+1, yk+1) = (xk+1, yk+m)
If m > 1
Then x moves with deviation
y change in Unit Interval
(xk+1, yk+1) = (xk+1/m, yk+1)
If m = 1
Then x moves in Unit Interval
y moves in Unit Interval
(xk+1, yk+1) = (xk+1, yk+1)
Step 5: We will repeat step 4 until we find the ending point of the line.
Step 6: Stop.
Problems
• There is a system with resolution 640 X 480. Calculate the size of
the frame buffer to store 12 bits per pixel?
Solution
Resolution = 640 X 480
Number of bits/pixel = N = 12
Required Frame Buffer Memory = N X Resolution
= 12 X 640 X 480
Memory in bytes = (12 x 640 X 480) / 8
= 460800 Bytes
Memory in KB = 460800/1024
= 450 KB
There is a system with resolution 1280 X 1024. Find out the size of frame buffer in
bytes and kilobytes, if 9 bits per pixel are stored. Also find out how many colors can
be displayed?
Solution
Resolution = 1280 X 1024
Number of bits/pixel = N = 9
Required Frame Buffer Memory = N X Resolution
= 9 X 1280 X 1024
Memory in bytes = (9 X 1280 X 1024) / 8
= 1474560 Bytes
Memory in KB = 1474560/1024 = 1440 KB
• If there are n bits per pixel then we can have a total of 2n colors.
Here we have 9 bits per pixel, so,
Total number of colors = 2n = 29= 512 colors
There are two raster systems with resolutions of 1280×1024, and 2560×2048.
a) Tell the size of the frame buffer (in bytes) for each of these systems to store 12
bits/pixel? b) How much storage is required for each system if we store 24 bits per
pixel?
1280 x 1024 x 12 bits / 8 = 1920KB
2560 x 2048 x 12 bits / 8 = 7680KB
Consider two raster systems with the resolutions of 640 x 480 and 1280 x 1024.
a) How many pixels could be accessed per second in each of these systems by a
display controller that refreshes the screen at a rate of 60 frames per second?
Solution
Since 60 frames are refreshed per second and each frame consists of 640 x 480 pixels,
the access rate of such a system is (640 x 480) * 60 = 1.8432 x 107 pixels/second.
Likewise, for the 1280 x 1024 system, the access rate is (1280 x 1024) * 60 = 7.86432 x 107 pixels/second.
Bresenham's Line Algorithm
Line equation
The slope-intercept form of a line is written as
• To illustrate Bresenham’s approach, we first consider the scan conversion
process for lines with positive slope less than 1
• Pixel positions along a line path are the determined by sampling at unit x
intervals.
• Starting from the left end point( x0,y0) of a given line, we step to each
successive column(x position) and plot the pixel whose scan line y value is
closest to the line path
(xk+1,yk) or (xk+1,yk +1)
If
dlower - dupper <0
dlower - dupper >0
yk
yk+1
xk
ie ynext =yk
To find the initial value of Pk
Calculate the points between the starting coordinates (9, 18) and
ending coordinates (14, 22).
Calculate ΔX and ΔY from the given input.
ΔX = Xn – X0 = 14 – 9 = 5
ΔY =Yn – Y0 = 22 – 18 = 4
Calculate the decision parameter.
Pk= 2ΔY – ΔX = 2 x 4 – 5 = 3
So, decision parameter Pk = 3
As Pk >= 0, so case-02 is satisfied.
Thus,
k+1 k
• P = P + 2ΔY – 2ΔX = 3 + (2 x 4) – (2 x 5) = 1
• Xk+1 = Xk + 1 = 9 + 1 = 10
• Yk+1 = Yk + 1 = 18 + 1 = 19
Similarly, Step-03 is executed until the end point is reached or number of iterations
equals to 5 times.
(Number of iterations = ΔX =5 times)
x y p
9 18 3
10 19 1
11 20 -1
12 20 7
13 21 5
14 22 3
Calculate the points between the starting coordinates (20, 10) and ending coordinates (30, 18).
dx=10 dy=8 2dy=16
Pk=2dy-dx= 16-10=6
2dy-2dx= 16-20 = -4
x y p
20 10 6
21 11 2
22 12 -2
23 12 14
24 13 10
25 14 6
26 15 2
27 16 -2
28 16 14
29 17 10
30 18 6
(Advantages)
If pk<0
Píoblem-
02:
Given the centre point coordinates (4, 4) and radius as 10, generate all
the points to form a circle.
Given-
Centre Coordinates of Circle (X0, Y0) = (4, 4)
Radius of Circle = 10
The following table shows the generation of points
for Quadrant-1-
Xplot = Xc + X0 = 4 + X0
Yplot = Yc + Y0 = 4 + Y0
Bresenham’s Circle Drawing Algorithm
Bresenham’s algorithm is also used for circle drawing.
It is known as Bresenhams’s circle drawing algorithm.
Let us assume we have a point p (x, y) on the boundary of the circle and with r radius
satisfying the equation fc (x, y) = 0
We assume,
The distance between point P3 and circle boundary = d1
The distance between point P2 and circle boundary = d2
Now, if we select point P3 then circle equation will be-
d1 = (xk +1)2 + (yk)2 – r2 {Value is +ve, because the point is
outside the circle}
if we select point P2 then circle equation will be-
d2 = (xk +1)2 + (yk –1)2 – r2 {Value is -ve, because the point is
inside the circle}
Now, we will calculate the decision parameter
(dk) = d1 + d2
dk =(xk +1)2 + (yk)2 – r2 + (xk +1)2 + (yk –1)2 – r2
= 2(xk +1)2 + (yk)2+ (yk -1)2 – 2r2 ……… (1)
If
dk < 0
then
Point P3 is closer to circle boundary, and the final coordinates are-
(xk +1, yk) = (xk +1, yk)
If
dk >= 0
then
Point P2 is closer to circle boundary, and the final coordinates are-
(xk +1, yk) = (xk +1, yk -1)
Now, we will find the next decision parameter (dk+1)
(dk+1) = 2(xk+1 +1)2 + (yk+1)2+ (yk+1 -1)2 – 2r2 …………… (2)
Now, we find the difference between decision parameter equation (2) – equation
(1)
(dk+1) – (dk) = 2(xk+1+1)2 + (yk+1)2+ (yk+1 –1)2 – 2r2 – 2(xk +1)2 + (yk)2+ (yk– 1)2 –
2r2
(dk+1) = dk + 4xk + 2(yk+1
2– yk
2) –2 (yk+1 – yk) + 6
Now, we calculate initial decision parameter (d0)
Algorithm of Bresenham’s Circle Drawing
Step 1: Start.
Step 2: First, we allot the starting coordinates (x1, y1) as follows-
x1 = 0
y1 =r
Step 3: Now, we calculate the initial decision parameter d0 –
d0 = 3 – 2 x r
Step 4: Assume,the initial coordinates are (xk, yk)
The next coordinates will be (xk+1, yk+1)
Now, we will find the next point of the first octant according to the value of the decision parameter
(dk).
Step 5: Now, we follow two cases-
Case 1: If
dk < 0
then
xk+1 =xk + 1
yk+1 =yk
dk+1 = dk + 4xk+1 + 6
Case 2: If
dk >= 0
then
xk+1 =xk + 1
yk+1 =yk –1
dk+1 = dk + 4(xk+1 – yk+1)+ 10
Step 6: If the center coordinates (x1, y1) is not at the origin (0, 0), then we will draw the points as follow-
X coordinate = xc + x1
y coordinate = yc + y1 {xc andyc representsthe current value of x and y coordinate}
Step 7: We repeat step 5 and 6 until we get x>=y.
Step 8: Stop.
Example
The radius of a circle is 8, and center point coordinates are (0, 0). Apply
bresenham’s circle drawing algorithm to plot all points of the circle.
Solution:
Step 1: The given stating points of the circle (x1, y1) = (0, 0)
Radius of the circle (r) = 8
Step 2: Now, we will assign the starting point (x1, y1) as follows-
x1 = 0
y1 = r (radius) = 8
Step 3: Now, we will calculate the initial decision parameter (d0)
d0 = 3 – 2 x r
d0 = 3 – 2 x 8
d0 = -13
Step 4: The value of initial parameter d0 < 0. So, case 1 is satisfied.
Thus,
xk+1 =xk + 1 = 0 + 1 = 1
yk+1 =yk = 8
dk+1 = dk + 4xk+1 + 6 = –13 + (4 x 1) + 6 = –3
Step 5: The center coordinates are already (0, 0) so we will move to next step.
Step 6: Follow step 4 until we get x >= y.
module 1.pdf
module 1.pdf
module 1.pdf

Contenu connexe

Similaire à module 1.pdf

Lines and curves algorithms
Lines and curves algorithmsLines and curves algorithms
Lines and curves algorithms
Mohammad Sadiq
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
Thirunavukarasu Mani
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
Ketan Jani
 
Output Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and MultimediaOutput Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and Multimedia
saranyan75
 
Computer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitivesComputer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitives
saranyan75
 
Bresenham circlesandpolygons
Bresenham circlesandpolygonsBresenham circlesandpolygons
Bresenham circlesandpolygons
aa11bb11
 
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdfCD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
RajJain516913
 

Similaire à module 1.pdf (20)

Lines and curves algorithms
Lines and curves algorithmsLines and curves algorithms
Lines and curves algorithms
 
Computer Graphics Unit 2
Computer Graphics Unit 2Computer Graphics Unit 2
Computer Graphics Unit 2
 
Cgm Lab Manual
Cgm Lab ManualCgm Lab Manual
Cgm Lab Manual
 
Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output Primitives
 
Unit 3
Unit 3Unit 3
Unit 3
 
Computer_Graphics_circle_drawing_techniq.ppt
Computer_Graphics_circle_drawing_techniq.pptComputer_Graphics_circle_drawing_techniq.ppt
Computer_Graphics_circle_drawing_techniq.ppt
 
4 CG_U1_M3_PPT_4 DDA.pptx
4 CG_U1_M3_PPT_4 DDA.pptx4 CG_U1_M3_PPT_4 DDA.pptx
4 CG_U1_M3_PPT_4 DDA.pptx
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
 
Output Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and MultimediaOutput Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and Multimedia
 
Computer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitivesComputer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitives
 
10994479.ppt
10994479.ppt10994479.ppt
10994479.ppt
 
Bresenham circlesandpolygons
Bresenham circlesandpolygonsBresenham circlesandpolygons
Bresenham circlesandpolygons
 
Bresenham circles and polygons derication
Bresenham circles and polygons dericationBresenham circles and polygons derication
Bresenham circles and polygons derication
 
2.circle
2.circle2.circle
2.circle
 
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdfCD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
 
Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1
 
CG-Lecture3.pptx
CG-Lecture3.pptxCG-Lecture3.pptx
CG-Lecture3.pptx
 
cgrchapter2version-1-200729063505 (1).pdf
cgrchapter2version-1-200729063505 (1).pdfcgrchapter2version-1-200729063505 (1).pdf
cgrchapter2version-1-200729063505 (1).pdf
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - Notes
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 

module 1.pdf

  • 1. COMPUTER GRAPHICS AND IMAGE PROCESSING MODULE I
  • 2. Module – 1(Basics of Computer graphics and Algorithms) • Basics of Computer Graphics and its applications. Video Display devices- Refresh Cathode Ray Tubes, Random Scan Displays and systems, Raster scan displays and systems. • Line drawing algorithms- DDA, Bresenham’s algorithm. Circle drawing algorithms- Midpoint Circle generation algorithm, Bresenham’s algorithm.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21. • Business visualization- Data sets related to commerce, industry etc
  • 22.
  • 23.
  • 24.
  • 25.
  • 27.
  • 28.
  • 29.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39. RASTER AND RANDOM SCAN DEVICES
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60. • 1. Beam Penetration Method : Beam Penetration Method is quite similar to the normal CRT and it uses only one electron gun. In this, different colors of multi-layered are coated on inner surface of screen, normally the two layers of phosphorus i.e., red and green are coated. It is a method used for displaying color pictures that has been used with random scan monitors. • 2. Shadow Mask Method : Shadow Mask Method is the method which is used in raster scan system which includes color TVs. In this the pixel is made up of three -colors. So due to three colors it uses three electron guns one for producing each color. The colors are red, green and blue. In this the important consideration for a color monitor is the setting of electron guns and the phosphor dots forming a pixel.
  • 61.
  • 62. Line drawing algorithms • The Line drawing algorithm is a graphical algorithm which is used to represent the line segment on discrete graphical media, i.e., printer and pixel-based media. • A line contains two points. The point is an important element of a line Equation of the straight line We can define a straight line with the help of the following equation. y= mx + a • Where,
  • 63. 3 cases m=1, m< 1, m>1
  • 64. DDA (Digital Differential Analyzer) • Simplest line drawing algorithm. • Digital Differential Analyzer algorithm is also known as an incremental method of scan conversion. Previous step results are used in the next step. • Digital Differential Analyzer algorithm is used to perform rasterization on polygons, lines, and triangles etc
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71. Algorithm of Digital Differential Analyzer (DDA) Line Drawing Step 1: Start. Step 2: We consider Starting point as (x1, y1), and ending point (x2, y2). Step 3: Now, we have to calculate Δx and Δy. Δx = x2-x1 Δy = y2-y1 m = Δy/Δx
  • 72. Step 4: Now, we calculate three cases. If m < 1 Then x change in Unit Interval y moves with deviation (xk+1, yk+1) = (xk+1, yk+m) If m > 1 Then x moves with deviation y change in Unit Interval (xk+1, yk+1) = (xk+1/m, yk+1) If m = 1 Then x moves in Unit Interval y moves in Unit Interval (xk+1, yk+1) = (xk+1, yk+1) Step 5: We will repeat step 4 until we find the ending point of the line. Step 6: Stop.
  • 73.
  • 74. Problems • There is a system with resolution 640 X 480. Calculate the size of the frame buffer to store 12 bits per pixel? Solution Resolution = 640 X 480 Number of bits/pixel = N = 12 Required Frame Buffer Memory = N X Resolution = 12 X 640 X 480 Memory in bytes = (12 x 640 X 480) / 8 = 460800 Bytes Memory in KB = 460800/1024 = 450 KB
  • 75. There is a system with resolution 1280 X 1024. Find out the size of frame buffer in bytes and kilobytes, if 9 bits per pixel are stored. Also find out how many colors can be displayed? Solution Resolution = 1280 X 1024 Number of bits/pixel = N = 9 Required Frame Buffer Memory = N X Resolution = 9 X 1280 X 1024 Memory in bytes = (9 X 1280 X 1024) / 8 = 1474560 Bytes Memory in KB = 1474560/1024 = 1440 KB • If there are n bits per pixel then we can have a total of 2n colors. Here we have 9 bits per pixel, so, Total number of colors = 2n = 29= 512 colors
  • 76. There are two raster systems with resolutions of 1280×1024, and 2560×2048. a) Tell the size of the frame buffer (in bytes) for each of these systems to store 12 bits/pixel? b) How much storage is required for each system if we store 24 bits per pixel? 1280 x 1024 x 12 bits / 8 = 1920KB 2560 x 2048 x 12 bits / 8 = 7680KB
  • 77. Consider two raster systems with the resolutions of 640 x 480 and 1280 x 1024. a) How many pixels could be accessed per second in each of these systems by a display controller that refreshes the screen at a rate of 60 frames per second? Solution Since 60 frames are refreshed per second and each frame consists of 640 x 480 pixels, the access rate of such a system is (640 x 480) * 60 = 1.8432 x 107 pixels/second. Likewise, for the 1280 x 1024 system, the access rate is (1280 x 1024) * 60 = 7.86432 x 107 pixels/second.
  • 79. Line equation The slope-intercept form of a line is written as • To illustrate Bresenham’s approach, we first consider the scan conversion process for lines with positive slope less than 1 • Pixel positions along a line path are the determined by sampling at unit x intervals. • Starting from the left end point( x0,y0) of a given line, we step to each successive column(x position) and plot the pixel whose scan line y value is closest to the line path
  • 80.
  • 82. If dlower - dupper <0 dlower - dupper >0 yk yk+1 xk
  • 83.
  • 85.
  • 86. To find the initial value of Pk
  • 87.
  • 88.
  • 89. Calculate the points between the starting coordinates (9, 18) and ending coordinates (14, 22). Calculate ΔX and ΔY from the given input. ΔX = Xn – X0 = 14 – 9 = 5 ΔY =Yn – Y0 = 22 – 18 = 4 Calculate the decision parameter. Pk= 2ΔY – ΔX = 2 x 4 – 5 = 3 So, decision parameter Pk = 3
  • 90. As Pk >= 0, so case-02 is satisfied. Thus, k+1 k • P = P + 2ΔY – 2ΔX = 3 + (2 x 4) – (2 x 5) = 1 • Xk+1 = Xk + 1 = 9 + 1 = 10 • Yk+1 = Yk + 1 = 18 + 1 = 19 Similarly, Step-03 is executed until the end point is reached or number of iterations equals to 5 times. (Number of iterations = ΔX =5 times) x y p 9 18 3 10 19 1 11 20 -1 12 20 7 13 21 5 14 22 3
  • 91. Calculate the points between the starting coordinates (20, 10) and ending coordinates (30, 18). dx=10 dy=8 2dy=16 Pk=2dy-dx= 16-10=6 2dy-2dx= 16-20 = -4 x y p 20 10 6 21 11 2 22 12 -2 23 12 14 24 13 10 25 14 6 26 15 2 27 16 -2 28 16 14 29 17 10 30 18 6
  • 93.
  • 94.
  • 95.
  • 96.
  • 97.
  • 98.
  • 99.
  • 100.
  • 101.
  • 102.
  • 103.
  • 104.
  • 105.
  • 107.
  • 108.
  • 109. Píoblem- 02: Given the centre point coordinates (4, 4) and radius as 10, generate all the points to form a circle. Given- Centre Coordinates of Circle (X0, Y0) = (4, 4) Radius of Circle = 10 The following table shows the generation of points for Quadrant-1- Xplot = Xc + X0 = 4 + X0 Yplot = Yc + Y0 = 4 + Y0
  • 110.
  • 111.
  • 112. Bresenham’s Circle Drawing Algorithm Bresenham’s algorithm is also used for circle drawing. It is known as Bresenhams’s circle drawing algorithm. Let us assume we have a point p (x, y) on the boundary of the circle and with r radius satisfying the equation fc (x, y) = 0
  • 113. We assume, The distance between point P3 and circle boundary = d1 The distance between point P2 and circle boundary = d2 Now, if we select point P3 then circle equation will be- d1 = (xk +1)2 + (yk)2 – r2 {Value is +ve, because the point is outside the circle} if we select point P2 then circle equation will be- d2 = (xk +1)2 + (yk –1)2 – r2 {Value is -ve, because the point is inside the circle} Now, we will calculate the decision parameter (dk) = d1 + d2 dk =(xk +1)2 + (yk)2 – r2 + (xk +1)2 + (yk –1)2 – r2 = 2(xk +1)2 + (yk)2+ (yk -1)2 – 2r2 ……… (1)
  • 114. If dk < 0 then Point P3 is closer to circle boundary, and the final coordinates are- (xk +1, yk) = (xk +1, yk) If dk >= 0 then Point P2 is closer to circle boundary, and the final coordinates are- (xk +1, yk) = (xk +1, yk -1) Now, we will find the next decision parameter (dk+1) (dk+1) = 2(xk+1 +1)2 + (yk+1)2+ (yk+1 -1)2 – 2r2 …………… (2) Now, we find the difference between decision parameter equation (2) – equation (1) (dk+1) – (dk) = 2(xk+1+1)2 + (yk+1)2+ (yk+1 –1)2 – 2r2 – 2(xk +1)2 + (yk)2+ (yk– 1)2 – 2r2 (dk+1) = dk + 4xk + 2(yk+1 2– yk 2) –2 (yk+1 – yk) + 6
  • 115.
  • 116. Now, we calculate initial decision parameter (d0)
  • 117. Algorithm of Bresenham’s Circle Drawing Step 1: Start. Step 2: First, we allot the starting coordinates (x1, y1) as follows- x1 = 0 y1 =r Step 3: Now, we calculate the initial decision parameter d0 – d0 = 3 – 2 x r Step 4: Assume,the initial coordinates are (xk, yk) The next coordinates will be (xk+1, yk+1) Now, we will find the next point of the first octant according to the value of the decision parameter (dk). Step 5: Now, we follow two cases- Case 1: If dk < 0 then xk+1 =xk + 1 yk+1 =yk dk+1 = dk + 4xk+1 + 6 Case 2: If dk >= 0 then xk+1 =xk + 1 yk+1 =yk –1 dk+1 = dk + 4(xk+1 – yk+1)+ 10 Step 6: If the center coordinates (x1, y1) is not at the origin (0, 0), then we will draw the points as follow- X coordinate = xc + x1 y coordinate = yc + y1 {xc andyc representsthe current value of x and y coordinate} Step 7: We repeat step 5 and 6 until we get x>=y. Step 8: Stop.
  • 118. Example The radius of a circle is 8, and center point coordinates are (0, 0). Apply bresenham’s circle drawing algorithm to plot all points of the circle. Solution: Step 1: The given stating points of the circle (x1, y1) = (0, 0) Radius of the circle (r) = 8 Step 2: Now, we will assign the starting point (x1, y1) as follows- x1 = 0 y1 = r (radius) = 8 Step 3: Now, we will calculate the initial decision parameter (d0) d0 = 3 – 2 x r d0 = 3 – 2 x 8 d0 = -13 Step 4: The value of initial parameter d0 < 0. So, case 1 is satisfied. Thus, xk+1 =xk + 1 = 0 + 1 = 1 yk+1 =yk = 8 dk+1 = dk + 4xk+1 + 6 = –13 + (4 x 1) + 6 = –3 Step 5: The center coordinates are already (0, 0) so we will move to next step. Step 6: Follow step 4 until we get x >= y.