class 2
class 2
Class 2
Online class for
PSC and NEA
BLA, circle, ellipse
Associate Professor
9801104103
[email protected]
Bresenham’s Line
Drawing
algorithms
Associate Professor
9801104103
[email protected]
Scan Conversion
continued…
Associate Professor
9801104103
[email protected]
Center
(𝑥𝑐 , 𝑦𝑐 )
r
Radius
Properties of Circle- Cartesion Coordinate
• Cartesian coordinates equation :
• (𝑥 − 𝑥𝑐 )2 +(𝑦 − 𝑦𝑐 )2 = 𝑟 2
yk Midpoint
Candidate Pixel
yk+1
xk xk+1 xk+2
• 𝑝3 = −1 + 6 + 1 = 6 6 5 (7, 7)
• We can start from (0, 𝑟𝑦 ) and step clockwise along the elliptical path
in the first quadrant
• Alternatively, we could start at (𝑟𝑥 , 0 ) and select points in a
counterclockwise order.
• With parallel processors, we could calculate pixel positions in the two
regions simultaneously.
• Here we consider sequential implementation of midpoint algorithm.
• We take the start position at (0, 𝑟𝑦 ) and steps along the elliptical path
in clockwise order through the first quadrant.
Decision Parameter Midpoint Ellipse Algorithm
• We define ellipse function for center of ellipse at (0, 0) as follows.
• 𝑓𝑒𝑙𝑙𝑖𝑝𝑠𝑒 𝑥, 𝑦 = 𝑟𝑦 2 𝑥 2 + 𝑟𝑥 2 𝑦 2 − 𝑟𝑦 2 𝑟𝑥 2
• Which has the following properties:
<0 𝑖𝑓 𝑥, 𝑦 𝑖𝑠 𝑖𝑛𝑠𝑖𝑑𝑒 𝑡ℎ𝑒 𝑒𝑙𝑙𝑖𝑝𝑠𝑒 𝑏𝑜𝑢𝑛𝑑𝑎𝑟𝑦
𝑓𝑒𝑙𝑙𝑖𝑝𝑠𝑒 𝑥, 𝑦 = 0 𝑖𝑓 𝑥, 𝑦 𝑖𝑠 𝑜𝑛 𝑡ℎ𝑒 𝑒𝑙𝑙𝑖𝑝𝑠𝑒 𝑏𝑜𝑢𝑛𝑑𝑎𝑟𝑦
> 0 𝑖𝑓 𝑥, 𝑦 𝑖𝑠 𝑜𝑢𝑡𝑠𝑖𝑑𝑒 𝑡ℎ𝑒 𝑒𝑙𝑙𝑖𝑝𝑠𝑒 𝑏𝑜𝑢𝑛𝑑𝑎𝑟𝑦
• Thus the ellipse function serves as the decision parameter in the
midpoint ellipse algorithm.
• At each sampling position we select the next pixel from two
candidate pixel.
Processing Steps of Midpoint Ellipse Algorithm
yk Midpoint
yk-1 Candidate
Pixel
xk xk+1 xk+2
• Assume we are at (𝑥𝑘 , 𝑦𝑘 ) position and we determine the next position along the
ellipse path, by evaluating decision parameter at midpoint between two candidate
pixels.
1
• 𝑝1𝑘 = 𝑓𝑒𝑙𝑙𝑖𝑝𝑠𝑒 𝑥𝑘 + 1, 𝑦𝑘 −
2
Derivation for Region 1
1
• 𝑝1𝑘 = 𝑓𝑒𝑙𝑙𝑖𝑝𝑠𝑒 𝑥𝑘 + 1, 𝑦𝑘 −
2
1 2
• 𝑝1𝑘 = 𝑟𝑦 2 (𝑥𝑘 + 1)2 +𝑟𝑥 2 𝑦𝑘 − − 𝑟𝑥 2 𝑟𝑦 2
2
• If 𝑝1𝑘 < 0, the midpoint is inside the ellipse and
the pixel on scan line 𝑦𝑘 is closer to ellipse
boundary
• Otherwise the midpoint is outside or on the ellipse
boundary and we select the pixel 𝑦𝑘 − 1.
Contd.
• At the next sampling position decision parameter for region 1 is evaluated as.
1
• 𝑝1𝑘+1 = 𝑓𝑒𝑙𝑙𝑖𝑝𝑠𝑒 𝑥𝑘+1 + 1, 𝑦𝑘+1 −
2
2 2 2 1 2
• 𝑝1𝑘+1 = 𝑟𝑦 𝑥𝑘 + 1 + 1 + 𝑟𝑥 𝑦𝑘+1 − − 𝑟𝑥 2 𝑟𝑦 2
2
• Now subtract 𝑝1𝑘 from 𝑝1𝑘+1
1 2 1 2
• 𝑝1𝑘+1 − 𝑝1𝑘 = 𝑟𝑦 2 𝑥𝑘 + 1 + 1 2
+ 𝑟𝑥 2 𝑦𝑘+1 − − 𝑟𝑥 2 𝑟𝑦 2 − 𝑟𝑦 2 (𝑥𝑘 + 1)2 −𝑟𝑥 2 𝑦𝑘 − + 𝑟𝑥 2 𝑟𝑦 2
2 2
Contd.
2 2 2 1 2 2 2 2 1 2
• 𝑝1𝑘+1 − 𝑝1𝑘 = 𝑟𝑦 𝑥𝑘 + 1 + 1 + 𝑟𝑥 𝑦𝑘+1 − − 𝑟𝑦 (𝑥𝑘 + 1) −𝑟𝑥 𝑦𝑘 −
2 2
2 2 2 2 2 1 2 2 2 2 1 2
• 𝑝1𝑘+1 − 𝑝1𝑘 = 𝑟𝑦 𝑥𝑘 + 1 + 2𝑟𝑦 𝑥𝑘 + 1 + 𝑟𝑦 + 𝑟𝑥 𝑦𝑘+1 − − 𝑟𝑦 (𝑥𝑘 + 1) −𝑟𝑥 𝑦𝑘 −
2 2
1 2 1 2
• 𝑝1𝑘+1 − 𝑝1𝑘 = 2𝑟𝑦 2 𝑥𝑘 + 1 + 𝑟𝑦 2 + 𝑟𝑥 2 𝑦𝑘+1 − − 𝑦𝑘 −
2 2
yk Midpoint
yk-1 Candidate
Pixel
xk xk+1 xk+2
2 1 2
• 𝑝2𝑘+1 = 𝑟𝑦 𝑥𝑘+1 + + 𝑟𝑥 2 𝑦𝑘 − 1 − 1 2
− 𝑟𝑥 2 𝑟𝑦 2
2
• Now subtract 𝑝2𝑘 from 𝑝2𝑘+1
2 1 2 2 2 1 2
• 𝑝2𝑘+1 − 𝑝2𝑘 = 𝑟𝑦 𝑥𝑘+1 + + 𝑟𝑥 𝑦𝑘 − 1 − 1 − 𝑟𝑥 2 𝑟𝑦 2 − 𝑟𝑦 2 𝑥𝑘 + − 𝑟𝑥 2 𝑦𝑘 − 1 2 + 𝑟𝑥 2 𝑟𝑦 2
2 2
Contd.
2 1 2 2 2 2 2 2 1 2
• 𝑝2𝑘+1 − 𝑝2𝑘 = 𝑟𝑦 𝑥𝑘+1 + + 𝑟𝑥 𝑦𝑘 − 1 − 1 − 𝑟𝑥 𝑟𝑦 − 𝑟𝑦 𝑥𝑘 + − 𝑟𝑥 2 𝑦𝑘 − 1 2
+ 𝑟𝑥 2 𝑟𝑦 2
2 2
2 1 2 2 2 2 2 2 1 2
• 𝑝2𝑘+1 − 𝑝2𝑘 = 𝑟𝑦 𝑥𝑘+1 + + 𝑟𝑥 𝑦𝑘 − 1 − 2𝑟𝑥 𝑦𝑘 − 1 + 𝑟𝑥 − 𝑟𝑦 𝑥𝑘 + − 𝑟𝑥 2 𝑦𝑘 − 1 2
2 2
1 2 1 2
• 𝑝2𝑘+1 − 𝑝2𝑘 = 𝑟𝑦 2 𝑥𝑘+1 + − 2𝑟𝑥 2 𝑦𝑘 − 1 + 𝑟𝑥 2 − 𝑟𝑦 2 𝑥𝑘 +
2 2
1 2 1 2
• 𝑝2𝑘+1 − 𝑝2𝑘 = −2𝑟𝑥 2 𝑦𝑘 − 1 + 𝑟𝑥 2 + 𝑟𝑦 2 𝑥𝑘+1 + − 𝑥𝑘 +
2 2
Contd.
1 2 1 2
• 𝑝2𝑘+1 − 𝑝2𝑘 = −2𝑟𝑥 2 𝑦𝑘 − 1 + 𝑟𝑥 2 + 𝑟𝑦 2 𝑥𝑘+1 + − 𝑥𝑘 +
2 2
• Now making 𝑝2𝑘+1 as subject.
1 2 1 2
• 𝑝2𝑘+1 = 𝑝2𝑘 − 2𝑟𝑥 2 𝑦𝑘 − 1 + 𝑟𝑥 2 + 𝑟𝑦 2 𝑥𝑘+1 + − 𝑥𝑘 +
2 2
• Here 𝑥𝑘+1 is either 𝑥𝑘 or 𝑥𝑘 + 1, depends on the sign of 𝑝2𝑘 .
IDP for Region 2
• In region-2 initial position is selected which is last
position of region one and the initial decision
parameter is calculated as follows.
1
• 𝑝20 = 𝑓𝑒𝑙𝑙𝑖𝑝𝑠𝑒 𝑥0 + , 𝑦0 −1
2
2 1 2
• 𝑝20 = 𝑟𝑦 𝑥0 + + 𝑟𝑥 2 𝑦0 − 1 2 − 𝑟𝑥 2 𝑟𝑦 2
2
• For simplify calculation of 𝑝20 we could also select
pixel position in counterclockwise order starting at
(𝑟𝑥 , 0).
Algorithm for Midpoint Ellipse Generation
1. Input 𝑟𝑥 , 𝑟𝑦 and ellipse center (𝑥𝑐 , 𝑦𝑐 ), and obtain the first point on an ellipse
centered on the origin as
𝑥0 , 𝑦0 = (0, 𝑟𝑦 )
7. Move each calculated pixel position (𝑥, 𝑦) onto the elliptical path centered on
(𝑥𝑐 , 𝑦𝑐 ) and plot the coordinate values:
𝑥 = 𝑥 + 𝑥𝑐 , 𝑦 = 𝑦 + 𝑦𝑐
2
𝑝1𝑘+1 = 𝑝1𝑘 + 2𝑟𝑦 𝑥𝑘 + 1 + 𝑟𝑦 + 𝑟𝑥 2 2
𝑦𝑘+1 −
1 2
− 𝑦𝑘 −
1 2 K p1k (xk+1, yk+1)
2 2
0 -332 (1, 6)
𝑝14 = 208 + 2 ∗ 62 3+1 + 62 + 82 5−
1 2
− 6−
1 2
= −108 1 -224 (2, 6)
2 2
2 -44 (3, 6)
3 208 (4, 5)
4 -108 (5, 5)
5 288 (6, 4)
6 244 (7, 3)
4 -108 (5, 5)
5 288 (6, 4)
6 244 (7, 3)
4 -108 (5, 5)
5 288 (6, 4)
6 244 (7, 3)
(7, 3)
Center
(0, 0) 0 1 2 3 4 5 6 7 8 9 10 11
1. What is scan conversion in computer graphics?
a) Converting a vector image into raster format
b) Converting an image from grayscale to color
c) Converting raster graphics into vector graphics
d) Converting an image into a 3D model
6. The Digital Differential Analyzer (DDA) algorithm calculates points on a line using:
a) Integer arithmetic
b) Floating-point arithmetic
c) Polar coordinates
d) Binary arithmetic
Answer: b) Floating-point arithmetic
8. What is the purpose of anti-aliasing in scan conversion?
a) To fill polygons with a solid color
b) To make lines look smoother by reducing the jagged edges
c) To draw a line between two points using a straight-line equation
d) To calculate intersections between line segments
Answer: b) To make lines look smoother by reducing the jagged edges
3.Frame Buffer:
1. A portion of memory containing the complete image to be displayed.
2. Includes color, depth (Z-buffer)
4.Display Devices:
1. Hardware like monitors, projectors, and VR headsets.
2. Technologies include CRT, LCD, LED, OLED, and MicroLED.
5.Input/Output Interfaces:
1. Interfaces like HDMI, DisplayPort, and USB-C connect GPUs to display devices.
2. Types of Graphics Hardware
1.Integrated Graphics:
1. Built into the CPU or motherboard.
2. Cost-effective but limited in performance.
3. Examples: Intel UHD Graphics, AMD Radeon Vega.
3.Workstation GPUs:
1. Designed for professional use in CAD, simulation, and AI.
2. Examples: NVIDIA Quadro, AMD Radeon Pro.
4.Mobile GPUs:
1. Integrated or discrete GPUs optimized for laptops and handheld devices.
2. Examples: NVIDIA GeForce RTX Mobile, Apple M-series GPUs.
1.Which component in a computer system is primarily responsible for rendering graphics?
a) CPU
b) GPU
c) RAM
Answer: b) GPU
d) SSD