1 / 70

Scan Conversion of Polygons

Scan Conversion of Polygons. Dr. Scott Schaefer. Drawing Rectangles. Which pixels should be filled?. Drawing Rectangles. Is this correct?. Drawing Rectangles. What if two rectangles overlap?. Drawing Rectangles. Is this correct?. Drawing Rectangles. Overlap!!!. Is this correct?.

noma
Download Presentation

Scan Conversion of Polygons

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. Scan Conversion of Polygons Dr. Scott Schaefer

  2. Drawing Rectangles Which pixels should be filled?

  3. Drawing Rectangles Is this correct?

  4. Drawing Rectangles What if two rectangles overlap?

  5. Drawing Rectangles Is this correct?

  6. Drawing Rectangles Overlap!!! Is this correct?

  7. Drawing Rectangles Solution: Exclude pixels on top and right

  8. Drawing Rectangles Artifacts are possible

  9. General Polygons – Basic Idea • Intersect scan lines with edges • Find ranges along x • Fill interior of those ranges Don’t fill top/right Edges may NOT match with line drawing algo

  10. General Polygons – Basic Idea Use coherence to speed up • Intersect scan lines with edges • Find ranges along x • Fill interior of those ranges Don’t fill top/right Edges may NOT match with line drawing algo

  11. General Polygons – Basic Idea Use coherence to speed up • Intersect scan lines with edges • Find ranges along x • Fill interior of those ranges Edges intersection one scan line are mostly same as those intersecting previous scan line

  12. General Polygons – Basic Idea Use coherence to speed up • Intersect scan lines with edges • Find ranges along x • Fill interior of those ranges The x-value of an intersection with one scan line is close to the intersection with the previous one

  13. General Polygons – Data Structures • Edge: maxY: currentX: xIncr: Edge maxY currentX xIncr

  14. General Polygons – Data Structures • Edge: maxY: currentX: xIncr: Edge maxY currentX xIncr Horizontal edges will not be used!!!

  15. General Polygons – Data Structures • Active Edge Table: Store a linked-list per scan-line. Insert edges into table at scan-line associated with lowest end-point. Scan Lines Edges

  16. General Polygons – Data Structures • Active Edge List: List of all edges intersecting current scan-line sorted by their x-values Edges

  17. General Polygons – Algorithm line = 0 While (line < height ) Add edges to Active Edge List from Active Edge Table starting at line Remove edges that end at line Fill pixels Increment x-values on edges in Active Edge List Increment line

  18. General Polygons – Example C Active Edge Table B D G Active Edge List F E A

  19. General Polygons – Example C Active Edge Table B D G AB Active Edge List F E A

  20. General Polygons – Example C Active Edge Table B BC D G AB Active Edge List F E A

  21. General Polygons – Example C Active Edge Table B BC D CD G AB Active Edge List F E A

  22. General Polygons – Example C Active Edge Table B BC D CD G ED AB Active Edge List F E A

  23. General Polygons – Example C Active Edge Table B BC D CD G ED AB Active Edge List F E A

  24. General Polygons – Example C Active Edge Table B BC D CD G FG ED AB Active Edge List F E A

  25. General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E A

  26. General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB AG A maxY currentX xIncr

  27. General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB AG FG ED A maxY currentX xIncr

  28. General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB AG FG ED A maxY currentX xIncr

  29. General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB AG FG ED A maxY currentX xIncr

  30. General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB AG FG ED A maxY currentX xIncr

  31. General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB AG FG ED A maxY currentX xIncr

  32. General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB ED A maxY currentX xIncr

  33. General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB ED A maxY currentX xIncr

  34. General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB ED A maxY currentX xIncr

  35. General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB ED A maxY currentX xIncr

  36. General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB ED CD A maxY currentX xIncr

  37. General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB ED CD A maxY currentX xIncr

  38. General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB CD A maxY currentX xIncr

  39. General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB CD A maxY currentX xIncr

  40. General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB BC CD A maxY currentX xIncr

  41. General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB BC CD A maxY currentX xIncr

  42. General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E BC CD A maxY currentX xIncr

  43. General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E BC CD A maxY currentX xIncr

  44. General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E BC CD A maxY currentX xIncr

  45. General Polygons – Example C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E BC CD A maxY currentX xIncr

  46. General Polygons – Problems • Sliver polygons may not be drawn correctly • No simple solution • Long, thin triangles cause problems • Want triangles with good aspect ratio (close to equilateral)

  47. Boundary Fill • Start with drawn outline of a polygon and an interior point • Recursively recolor outward from that point • If neighbor different, then recolor and recur • Everything within the boundary is changed to that color

  48. Boundary Fill • How to define a neighbor? 8-connected 4-connected

  49. Boundary Fill – Example

  50. Boundary Fill – Example

More Related