0% found this document useful (0 votes)
195 views52 pages

Understanding Output Primitives

The document discusses various output primitives and algorithms for rendering geometric objects and text on raster displays. It describes point, line, and circle generation algorithms like Bresenham's line algorithm and the midpoint circle algorithm. These algorithms incrementally scan convert mathematical representations of shapes to pixels on the display. The document also covers bitmap and outline fonts for representing character shapes in different typefaces and sizes more efficiently.

Uploaded by

Peta Suresh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
195 views52 pages

Understanding Output Primitives

The document discusses various output primitives and algorithms for rendering geometric objects and text on raster displays. It describes point, line, and circle generation algorithms like Bresenham's line algorithm and the midpoint circle algorithm. These algorithms incrementally scan convert mathematical representations of shapes to pixels on the display. The document also covers bitmap and outline fonts for representing character shapes in different typefaces and sizes more efficiently.

Uploaded by

Peta Suresh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd

Output Primitives

Dr. S.M. Malaek


Assistant: M. Younesi
Output Primitives
Output Primitives: Basic geometric
structures (points, straight line segment,
circles and other conic sections, quadric
surfaces, spline curve and surfaces,
polygon color areas, and character
strings)
These picture components are often
defined in a continuous space.
Output Primitives
In order to draw the primitive objects,
one has to first scan convert the object.

Scan convert: Refers to he operation of
finding out the location of pixels to the
intensified and then setting the values of
corresponding bits, in the graphic
memory, to the desired intensity code.
Output Primitives
Each pixel on the display surface has
a finite size depending on the screen
resolution and hence a pixel cannot
represent a single mathematical
point.

Scan Converting A Point
Scan Converting A Point
A mathematical point (x,y) needs to
be scan converted to a pixel at
location (x, y).


Scan Converting A Point
x=Round(x) and y=Round(y)
All points that satisfy:

are mapped to pixel (x,y)

1
1
+
'
< s
'
+
'
< s
'
y y y
x x x
Scan Converting A Point
x=Round(x+0.5) and y=Round(y+o.5)
All points that satisfy:

are mapped to pixel (x,y)

5 . 0 5 . 0
5 . 0 5 . 0
+
'
< s
'
+
'
< s
'
y y y
x x x

Scan Converting A Line
Scan Converting A Line
The Cartesian slope- intercept equation
for a straight line is:
1 2
1 2
x x
y y
m

=
b x m y + =
1 1
x m y b =
x m y A = A
m
y
x
A
= A
Scan Converting A Line
These equation form the basic for
determining deflection voltage in
analog devices.
x m y A = A
m
y
x
A
= A
|m|<1 |m|>1
Scan Converting A Line
On raster system, lines are plotted
with pixels, and step size (horizontal
& vertical direction) are constrained
by pixel separation.

Scan Converting A Line
We must sample a line at discrete
positions and determine the
nearest pixel to the line at each
sampled position.
X2

Digital Differential
Analyzer
(DDA Algorithm)
DDA Algorithm
Algorithm is an incremental scan
conversion method.
Based on calculating either or
If |m|<1,
x A
y A
) 1 ( = Ax
m y y
x m y
k K
+ =
A = A
+1
DDA Algorithm
If |m|>1,
) 1 ( = Ax
) 1 ( = Ay
m
x x
m
y
x
k K
1
1
+ =
A
= A
+
If
m y y
x m y
k K
=
A = A
+1

Bresenhams Line
Algorithm
Bresenhams Line Algorithm
A highly efficient incremental
method for scan converting lines.
Using only incremental integer
calculation.
By testing the sign of an
integer parameter, whose
value is proportional to the
difference between the
separation of two pixel
positions from the actual
line path.
Bresenhams Line Algorithm
A highly efficient incremental
method for scan converting lines.
Using only incremental integer
calculation.
By testing the sign of an
integer parameter, whose
value is proportional to the
difference between the
separation of two pixel
positions from the actual
line path.
Bresenhams Line Algorithm
Bresenhams Line Algorithm

y

y
k
y
k+1
x
k+1
}
}
d
2
d
1
Bresenhams Line Algorithm
y

y
k
y
k+1
x
k+1
}
}
d
2
d
1
y

y
k
y
k+1
x
k+1
}
}
d
2
d
1
Bresenhams Line Algorithm
d
1
= y - y
k
= m (x
k
+ 1) + b - y
k

d
2
= (y
k
+ 1) - y = y
k
+ 1 - m (x
k
+ 1) b

d
1
- d
2
= 2 m (x
k
+ 1) - 2 y
k
+ 2b -1

Bresenhams Line Algorithm
P
k
= X ( d
1
- d
2
) =
2 Y . x
k
- 2 X . y
k
+ c

c = constante = 2 Y + X (2b -1)

Let's get rid of multiplications
P
k+1
= 2 Y . x
k+1
- 2 X .y + c
P
k+1
- P
k
= 2 Y (x
k+1
- x
k
) -2 X (y
k+1
- y
k
)
(get rid of the constance)
P
k+1
= P
k
+ 2 Y - 2 X (y
k+1
- y
k
)

P
k+1
= P
k
+ 2Y
or
= P
k
+ 2(Y X(

with (y
k+1
- y
k
) = 0 or 1 depending on P
k
sign

P
0
=X (d
1
-d
2
)
=X[2m(x
0
+1)-2y
0
+2b-1]
=X[2(mx
0
+b-y
0
)+2m-1]


P
0
=2Y -X

0
m=y/x
Bresenhams Line Algorithm
Bresenhams Line Algorithm
Example: Digitize the line with endpoint
(20,10) and (30,18)
X=10 Y= 8
P0=2Y x=6
2Y =16
2(Y X)=-4





P0=2Y X
Pk+1 = Pk + 2Y
or
= Pk + 2(Y X(


Circle Generation
Algorithms
Circle Generation Algorithms

The equation of a circle:
We could solve for y in terms of x

Circle Generation Algorithms

Computation can be reduced by
considering the symmetry of circles
8 -Way symmetry

Midpoint Circle
Algorithm
Circle Generation Algorithms

As in the line algorithm, we sample at
unit intervals and determine the closet
pixel position to the circle path at each
step.

Circle Generation Algorithms

Points are generated from 90 to 45, moves
will be made only in the +x and y
direction.
positive x direction over this octant and use
a decision parameter
Circle Generation Algorithms

We define a circle function:



>
=
<
+ =
o
r y x y x f
circle
0
0
) , (
2 2 2
Circle Generation Algorithms

Midpoint

Consider the coordinates of the point
halfway between pixel T and pixel S
)
2
1
, 1 ( +
i i
y x
Midpoint
Circle Generation Algorithms

We use it to define a decision
parameter

2 2 2
)
2
1
( ) 1 ( )
2
1
, 1 ( r y x y x f p
i i i i
+ + = + =
Circle Generation Algorithms

If is negative, the midpoint
is inside the pixel, and we choose
pixel T.
If we choose pixel S.

0 >
i
p
0 <
i
p
Circle Generation Algorithms

Parameter for the next step is:


since
2
1
2
1 1
)
2
1
( ) 1 ( r y x p
i i i
+ + =
+ + +
1
1
+ =
+ i i
x x
Circle Generation Algorithms

If T is chosen ( ) we have:

If pixel S is chosen ( ) we
have


0 <
i
p
0 >
i
p
Circle Generation Algorithms


In terms of
Circle Generation Algorithms

Initial value for the decision parameter using the
original function of (0,r(
When r is an integer we can simply set
Circle Generation Algorithms
Example: A circle radius r=10
x=0 to x=y
P
0
=1-r = -9




Exercises

1. Scan Converting Arcs
And Sectors?

Character Generation
Character Generation

Letters, numbers, and other character can
be displayed in a variety of size and
styles.

Character Generation
Typeface: The overall design style
for a set of characters is call
typeface: Zar, nazanin, Titr.

Font: Referred to a set of cast metal
character forms in a particular size
and forma: 10 point Zar.
Character Generation
Two different representation are used
for storing computer fonts:

1. Bitmap font (or bitmapped font)

2. Outline font
Bitmap font
Bitmap font (or bitmapped font): A
simple method for representing the
character shapes in a particular typeface
is to use rectangular grid pattern.

Bitmap font
The character grid only need to be
mapped to a frame buffer position.
Bitmap fonts required more space,
because each variation (size and format)
must be stored in a font cash.

Bold
Italic
Outline Font
Graphic primitives such as lines and arcs
are used to define the outline of each
character.
Require less storage since variation does
not require a distinct font cash.
Outline Font
We can produce boldface, italic, or
different size by manipulating the curve
definition for the character outlines.

It does take more time to process the
outline fonts, because they must be scan
converted into frame buffer.

Common questions

Powered by AI

Circle generation algorithms use the symmetry of circles, specifically their 8-way symmetry, to reduce computational demands. By calculating points for one-eighth of the circle (from 90º to 45º, moving in the +x and –y directions), the algorithm reuses these calculations across other sections, significantly minimizing the required calculations for complete circle generation .

Bresenham’s Line Algorithm is an efficient method for raster line drawing, relying on incremental integer calculations. It determines pixel positions by evaluating the sign of a parameter representing the distance between potential pixel positions and the actual line path . This approach minimizes errors and reduces computational demands, as it only requires integer operations, making it highly suitable for raster systems where precision and performance are crucial .

Output primitives such as points, straight line segments, circles, conic sections, and quadric surfaces represent basic geometric structures essential in computer graphics for image representation . They form the building blocks for complex images and enable precise control over graphic design, allowing continuous space definition and scan conversion for display on raster systems .

The midpoint circle algorithm uses a decision parameter initialized based on the circle’s radius (P0 = 1 - r when r is an integer). This parameter helps determine the closest pixel to the circle path at unit intervals. Depending on the sign of the decision parameter, the algorithm chooses between the potential pixel positions, ensuring accurate circle rendering with minimal computation .

To map a mathematical point (x, y) to a pixel location on the grid, rounding methods are employed where x' = Round(x + 0.5) and y' = Round(y + 0.5). This rounding process ensures that the closest pixel is selected, accommodating the finite size of pixels in relation to mathematical points, which aids in accurately representing continuous geometric entities on discrete screens .

The DDA algorithm is an incremental method for line scan conversion that calculates successive points incrementally using either Δx or Δy, depending on the slope |m|. For |m|<1, it increments x while adjusting y proportionally, and vice versa for |m|>1 . Its primary benefit is simplification, avoiding multiplicative operations by incrementally calculating pixel positions, thus efficiently generating lines on raster displays .

The midpoint circle algorithm updates the decision parameter by considering whether the midpoint is inside the pixel. If P_i is negative, the midpoint is inside, and pixel T is chosen; if positive or zero, pixel S is chosen. For subsequent steps, the decision parameter is recalculated to guide the selection of the nearest pixel until the circle is complete . This iterative approach optimizes circle drawing by maximizing accuracy and minimizing error propagation .

Bitmap fonts use a rectangular grid pattern to represent character shapes, requiring more storage as each size and form must be stored separately. Outline fonts, defined using graphic primitives like lines and arcs, require less storage because variations in style and size do not demand additional font caches. However, outline fonts incur greater processing time since they need to be scan converted to a frame buffer .

Understanding scan conversion operations is essential because it dictates how continuous geometric primitives translate to the discrete pixel grid of digital displays. This process ensures proper pixel placement for accurate visual representation, reduces aliasing, and maximizes graphical fidelity by matching geometric definitions with pixel constraints, critical in rendering accurate and visually pleasing images .

Pixel resolution directly impacts the representation of continuous geometric shapes, as each pixel on a display has a finite size. This means that continuous shapes, defined in infinite mathematical precision, must be approximated to fit the grid of discrete pixels. As resolution increases, the approximation improves, allowing for finer detail and more accurate representation of complex shapes, but limitations in resolution can lead to aliasing and less precise depictions .

You might also like