Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 15: Raster Graphics and Scan Conversion

Similar presentations


Presentation on theme: "Lecture 15: Raster Graphics and Scan Conversion"— Presentation transcript:

1 Lecture 15: Raster Graphics and Scan Conversion
CS552: Computer Graphics Lecture 15: Raster Graphics and Scan Conversion

2 Recap Issues related to scan converting a line
Generalized line drawing algorithm Mid point circle drawing algorithm

3 Objective After completing this lecture students will be able to
Derive mathematical expression for drawing am ellipse Write programs to implement ellipse drawing algorithm Explain polygon filling algorithms

4 Ellipse 𝑥 2 𝑎 2 + 𝑦 2 𝑏 2 =1 𝐹 𝑥,𝑦 = 𝑏 2 𝑥 2 + 𝑎 2 𝑦 2 − 𝑎 2 𝑏 2 =0
𝑥 2 𝑎 𝑦 2 𝑏 2 =1 𝐹 𝑥,𝑦 = 𝑏 2 𝑥 2 + 𝑎 2 𝑦 2 − 𝑎 2 𝑏 2 =0 Minor axis (0,0) Major axis

5 Four way symmetry in ellipse

6 Filling rectangles The task of filling primitives can be broken into two parts: the decision of which pixels to fill shape of the primitive with what value to fill them.

7 Filling rectangles for (y=YMIN; y<YMAX; y++) // by scan line {
for (x=XMIN; x<XMAX; x++) // by pixel in span WritePixel(x,y,color); }

8 Polygons A polygon is a many-sided planar figure composed of vertices and edges. A polygon is bounded (finite area) and closed (includes boundary). Vertices are represented by points (x,y). Edges are represented as line segments which connect two points, (x1,y1) and (x2,y2). P = { (xi , yi ) } i=1,n E3 (x3,y3) E2 (x2,y2) E1 (x1,y1)

9 Polygons: Complex vs Simple
A simple polygon – edges only intersect a vertices, no coincident vertices A complex polygon – edges intersect and/or coincident vertices A B C E F G H C E D A B B A C A B,E C D F

10 Simple Polygons: Convex and Concave
Convex Polygon - For any two points P1, P2 inside the polygon, all points on the line segment which connects P1 and P2 are inside the polygon. All points P = uP1 + (1-u)P2, u in [0,1] are inside the polygon provided that P1 and P2 are inside the polygon. Concave Polygon - A polygon which is not convex.

11 Inside-Outside Tests Identifying the interior of a simple object
Non-zero winding number Rule Odd-Even Rule

12 Filled- Area Primitives
A standard output primitive in general graphics packages is a solid-color or patterned polygon area. The scan-line approach Determine the overlap intervals for scan lines that cross the area. Typically used in general graphics packages to fill polygons, circles, ellipses Filling approaches Start from a given interior position and paint outward from this point until we encounter the specified boundary conditions. Useful with more complex boundaries and in interactive painting systems.

13 Scan-Line Polygon-Fill
For each scan line crossing a polygon Locate the intersection points of the scan line with the polygon edges. These intersection points are then sorted from left to right, the corresponding frame-buffer positions between each intersection pair are set to the specified fill color.

14 Example

15 Issues

16 Issues

17 Adjust end point calculation

18 Filled- Area Primitives (cont.)
Scan-conversion algorithms typically take advantage of various coherence properties of a scene Coherence is simply that the properties of one part of a scene are related in some way to other parts of the scene so that the relationship can be used to reduce processing. Coherence methods often involve incremental calculations applied along a single scan line between successive scan lines.

19 Coherence Example Slope of the edge
Change in y coordinates between the two scan lines is ? Given the current x-intercept, the next x-intercept coordinate =

20 Different situations while scanning
Intersection point change by the amount of the slope of the line Edges may start / end Tracking of intersection points is the key Vertices Edges Active Edge Table (AET)

21 Thank you Next Lecture: Scan Line Filling Algorithm


Download ppt "Lecture 15: Raster Graphics and Scan Conversion"

Similar presentations


Ads by Google