Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.
-
Upload
paula-bradley -
Category
Documents
-
view
226 -
download
0
Transcript of Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.
![Page 1: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/1.jpg)
Output Primitives
Dr. S.M. MalaekAssistant: M. Younesi
![Page 2: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/2.jpg)
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.
![Page 3: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/3.jpg)
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.
![Page 4: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/4.jpg)
Output Primitives Each pixel on the display surface has
a finite size depending on the screen
resolution and hence a pixel cannot cannot representrepresent a single mathematical point.
![Page 5: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/5.jpg)
Scan Converting A Point
![Page 6: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/6.jpg)
Scan Converting A Point A mathematical point (x,y) needs to
be scan converted to a pixel at location (x´, y´).
![Page 7: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/7.jpg)
Scan Converting A Point x´=Round(x) and y´=Round(y) All points that satisfy:
are mapped to pixel (x´,y´) 1
1
yyy
xxx
![Page 8: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/8.jpg)
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.05.0
5.05.0
yyy
xxx
![Page 9: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/9.jpg)
Scan Converting A Line
![Page 10: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/10.jpg)
Scan Converting A Line The Cartesian slope- intercept equation
for a straight line is:
12
12
xxyy
m
bxmy
11xmyb
xmy my
x
![Page 11: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/11.jpg)
Scan Converting A Line
These equation form the basic for determining deflection voltage in analog devices.
xmy my
x
|m|<1 |m|>1
![Page 12: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/12.jpg)
Scan Converting A Line On raster system, lines are plotted
with pixels, and step size (horizontal & vertical direction) are constrained by pixel separation.
![Page 13: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/13.jpg)
Scan Converting A Line We must samplesample a line at discrete
positions and determine the nearest pixel to the line at each sampled position.
![Page 14: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/14.jpg)
Digital Differential Analyzer
(DDA Algorithm)
![Page 15: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/15.jpg)
DDA Algorithm Algorithm is an incremental scan
conversion method. Based on calculating either or If |m|<1,
x y)1( x
myy
xmy
kK
1
![Page 16: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/16.jpg)
DDA Algorithm If |m|>1,
)1( x
)1( y
mxx
my
x
kK
11
If
myy
xmy
kK
1
![Page 17: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/17.jpg)
Bresenham’s Line Algorithm
![Page 18: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/18.jpg)
Bresenham’s 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.
![Page 19: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/19.jpg)
Bresenham’s 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.
![Page 20: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/20.jpg)
Bresenham’s Line Algorithm
![Page 21: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/21.jpg)
Bresenham’s Line Algorithm
![Page 22: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/22.jpg)
y
yk
yk+1
xk+1
}
}d2
d1
Bresenham’s Line Algorithm
y
yk
yk+1
xk+1
}
}d2
d1
y
yk
yk+1
xk+1
}
}d2
d1
![Page 23: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/23.jpg)
Bresenham’s Line Algorithmd1 = y - yk = m (xk + 1) + b - yk
d2 = (yk + 1) - y = yk + 1 - m (xk + 1) –b
d1 - d2 = 2 m (xk + 1) - 2 yk + 2b -1
![Page 24: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/24.jpg)
Bresenham’s Line Algorithm
Pk = ΔX ( d1 - d2) = 2 ΔY . xk - 2 ΔX . yk + c
c = constante = 2 ΔY + ΔX (2b -1)
![Page 25: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/25.jpg)
Let's get rid of multiplicationsPk+1 = 2 ΔY . xk+1 - 2 ΔX .y + c
Pk+1 - Pk = 2 ΔY (xk+1 - xk) -2 ΔX (yk+1 - yk) (get rid of the constance)
Pk+1 = Pk + 2 ΔY - 2 ΔX (yk+1 - yk)
Pk+1 = Pk + 2ΔY or = Pk + 2(ΔY – ΔX(
with (yk+1 - yk) = 0 or 1 depending on Pk sign
![Page 26: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/26.jpg)
P0 =ΔX (d1-d2) =ΔX[2m(x0+1)-2y0+2b-1] =ΔX[2(mx0+b-y0)+2m-1]
P0=2ΔY -ΔX0
m=Δy/x
Bresenham’s Line Algorithm
![Page 27: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/27.jpg)
Bresenham’s Line Algorithm Example: Digitize the line with endpoint
(20,10) and (30,18) ΔX=10 ΔY= 8P0=2ΔY –Δx=6 2ΔY =16 2(ΔY – ΔX)=-4
P0=2ΔY –ΔXPk+1 = Pk + 2ΔY or = Pk + 2(ΔY – ΔX(
![Page 28: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/28.jpg)
Circle Generation Algorithms
![Page 29: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/29.jpg)
Circle Generation Algorithms The equation of a circle:
We could solve for y in terms of x
![Page 30: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/30.jpg)
Circle Generation Algorithms Computation can be reduced by
considering the symmetry of circles
8 -Way symmetry
![Page 31: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/31.jpg)
Midpoint Circle Algorithm
![Page 32: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/32.jpg)
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.
![Page 33: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/33.jpg)
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
![Page 34: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/34.jpg)
Circle Generation Algorithms
We define a circle function:
o
ryxyxfcircle
0
0
),( 222
![Page 35: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/35.jpg)
Circle Generation Algorithms Midpoint
Consider the coordinates of the point halfway between pixel T and pixel S
)21
,1( ii
yx
Midpoint
![Page 36: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/36.jpg)
Circle Generation Algorithms
We use it to define a decision parameter
222 )21
()1()21
,1( ryxyxfpiiii
![Page 37: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/37.jpg)
Circle Generation Algorithms If is negative, the midpoint
is inside the pixel, and we choose pixel T.
If we choose pixel S.0i
p
0i
p
![Page 38: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/38.jpg)
Circle Generation Algorithms Parameter for the next step is:
since
2
1
2
11)
21
()1( ryxpiii
11
ii
xx
![Page 39: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/39.jpg)
Circle Generation Algorithms
If T is chosen ( ) we have:
If pixel S is chosen ( ) we have
0i
p
0i
p
![Page 40: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/40.jpg)
Circle Generation Algorithms
In terms of
![Page 41: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/41.jpg)
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
![Page 42: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/42.jpg)
Circle Generation Algorithms Example: A circle radius r=10 x=0 to x=y P0=1-r = -9
![Page 43: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/43.jpg)
ExercisesExercises??
![Page 44: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/44.jpg)
1. Scan Converting Arcs
And Sectors?
![Page 45: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/45.jpg)
Character Generation
![Page 46: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/46.jpg)
Character Generation
Letters, numbers, and other character can be displayed in a variety of size and styles.
![Page 47: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/47.jpg)
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.
![Page 48: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/48.jpg)
Character Generation Two different representation are used
for storing computer fonts:
1. Bitmap font (or bitmapped font)
2. Outline font
![Page 49: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/49.jpg)
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.
![Page 50: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/50.jpg)
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
![Page 51: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/51.jpg)
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.
![Page 52: Output Primitives Dr. S.M. Malaek Assistant: M. Younesi.](https://reader038.fdocuments.in/reader038/viewer/2022102707/56649e405503460f94b32107/html5/thumbnails/52.jpg)
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.