1 / 22

The Rasterization Problem: Idealized Primitives Map to Discrete Display Space

The Rasterization Problem: Idealized Primitives Map to Discrete Display Space. Solution Involves Selection of Discrete Representation Values. Scan Converting Lines: Characterizing the Problem. ideal line. i.e. for each x, choose y. i.e. for each y, choose x.

jenn
Download Presentation

The Rasterization Problem: Idealized Primitives Map to Discrete Display Space

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The Rasterization Problem: Idealized PrimitivesMap to Discrete Display Space

  2. Solution Involves Selection of DiscreteRepresentation Values

  3. Scan Converting Lines:Characterizing the Problem ideal line i.e. for each x, choose y i.e. for each y, choose x

  4. Scan Converting Lines:The Strategy • Pick pixels closest to endpoints • Select in between pixels “closest” to ideal line • Minimize calculation required!

  5. Calculate ideal line equation Pick endpoints: two dimensional round. Starting at leftmost point: for each xi Calculate Select pixel at Scan Converting Lines:A Basic Algorithm Selected Not Selected

  6. Scan Converting Lines:DDA Algorithm, Incremental Form Therefore, rather than recomputing y each step, simply add m. The Algorithm: void Line(int x0, int y0, int x1, int y1) { int x; float dy, dx, y, m; dy = y1 - y0; dx = x1 - x0; m = dy/dx; y = y0; for (x = x0; x<=x1,x++){ WritePixel(x, round(y)); y += m; } }

  7. Midpoint Algorithm:Allowable Pixel Selections Not Allowed Option NE 0 < Slope < 1 Option E Last Selection

  8. Midpoint Algorithm:Iterating 0 < Slope < 1 Select E Select NE

  9. Midpoint AlgorithmDecision Function: (implicit equation of the line)

  10. Midpoint Algorithm:Calculating the Decision Function

  11. Option NE Option E Midpoint Algorithm:Incremental Calculation of di

  12. Midpoint Algorithm:The Code void MidpointLine(int x0, int y0, int xn, int yn) { int dx,dy,incrE,incrNE,d,x,y; dx=xn-x0; dy=yn-y0; d=2*dy-dx; /* initial value of d */ incrE=2*dy; /* decision funct incr for E */ incrNE=2*dy-2*dx; /* decision funct incr for NE */ x=x0; y=y0; DrawPixel(x,y) /* draw the first pixel */ while (x<xn){ if (d<=0){ /* choose E */ d+=incrE; x++; /* move E */ }else{ /* choose NE */ d+=incrNE; x++; y++; /* move NE */ } DrawPixel (x,y); } }

  13. Midpoint AlgorithmAn example 12 11 10 9 8 7 4 5 6 7 8 9

  14. Midpoint AlgorithmAn example 12 11 10 9 8 7 4 5 6 7 8 9

  15. Midpoint AlgorithmAn example 12 11 10 9 8 7 4 5 6 7 8 9

  16. Other Incremental Algorithms(Wu 1987)

  17. Midpoint Circle Algorithm(Bresenham 1977)

  18. Filling Polygons:Scan Line Algorithm 14 12 10 8 6 4 2 0 0 2 4 6 8 10 12 14

  19. Filling Polygons:Scan Line Algorithm 1. Find the intersections of current scan line with all edges of the polygon. 2. Sort the intersections by increasing x coordinate. 3. Fill in pixels that lie between pairs of intersections that lie interior to the polygon using the odd/even parity rule. Special Cases: 1. Intersections at integer coordinates 2. Shared vertices 3. Horizontal edges

  20. Filling Polygons:Special Cases Only count ymin, not ymax. Leftmost integer pixel is interior; rightmost exterior. 14 12 10 8 6 4 2 0 0 2 4 6 8 10 12 14

  21. 11 10 9 8 7 6 5 4 3 2 1 0 Scan Line Polygon Fill Algorithm:Exploiting Coherence l l 14 l D 12 l EF DE F 10 -5/2 6/4 l 9 7 7 12 CD l 8 l 12 13 0 E 6 C FA l 4 l 9 2 0 A 2 l AB BC B 0 6/4 l -5/2 7 3 7 5 0 2 4 6 8 10 12 14 l Scan Line

  22. Scan Line Polygon Fill:The Algorithm • Set y to smallest y coordinate that has an entry in ET • Initialize the active edge table (AET) to empty • Repeat until the ET and AET are both empty: • Move from ET bucket at y to AET those edges whose ymin = y. (entering edges) • Remove from AET those edges for which y = ymax. • Sort AET on x • Fill in desired pixels on scan line using even-odd parity from AET • Increment y by one (next scan line) • For each edge in the AET, update x by adding Dx/Dy

More Related