1 / 25

Scan Conversion

Scan Conversion. A. Samal. Scan Conversion. Last step in the graphics pipeline Efficiency is a central issue Common primitives Lines Polygons Circles Hardware implementations preferable. Lines. Compute the coordinate of the pixels that lie on a line on a 2D raster

Download Presentation

Scan Conversion

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 A. Samal

  2. Scan Conversion • Last step in the graphics pipeline • Efficiency is a central issue • Common primitives • Lines • Polygons • Circles • Hardware implementations preferable

  3. Lines • Compute the coordinate of the pixels that lie on a line on a 2D raster • Defined by the coordinates of the end points • Criteria • Thin • As close to ideal as possible • 1 pixel wide • If -1<= slope <= 1 exactly 1 pixel in one column • Else exactly 1 pixel in one row • Constant brightness, independent of the length & orientation • Should be drawn fast

  4. Scan Conversion of Lines

  5. Basic Incremental Algorithm

  6. Problem • for each x plot pixel at closest y • Problems for steep lines

  7. Basic Incremental Algorithm Desired Line

  8. Basic Incremental Algorithm • Brute force algorithm • Inefficient • Each iteration • Floating point multiply • Floating point addition • Rounding

  9. Basic Incremental Algorithm • Eliminate the multiplication • Incremental computation • Digital Differential Analyzer (DDA)

  10. Basic Incremental Algorithm • If the magnitude of the slope is more than 1 change the role of x and y in the algorithm • y increases faster than x • Simple but inefficient • Still there are floating point operations • Bresenham’s algorithm • Uses only integer arithmetic • Avoids round function • Extended to drawing circles

  11. Midpoint Line Algorithm NE M E Previous Pixel Current Pixel Choices Next Pixel Choices

  12. Compute the distance between Q and E Q and NE See which side of the line M lies M lies below the line Choose NE M lies above the line Choose E M lies on the line Choose either NE M E Previous Pixel Current Pixel Choices Next Pixel Choices Midpoint Line Algorithm

  13. Midpoint Line Algorithm

  14. Midpoint Line Algorithm

  15. NE M E Previous Pixel Current Pixel Choices Next Pixel Choices Midpoint Line Algorithm

  16. What happens at the next grid point? Depends on whether we choose N or NE If E is chosen NE M E Previous Pixel Current Pixel Choices Next Pixel Choices Midpoint Line Algorithm

  17. NE M E Previous Pixel Current Pixel Choices Next Pixel Choices Midpoint Line Algorithm • If NE is chosen

  18. Midpoint Line Algorithm • Summary • Choose between the two pixels (E/NE) based on the sign of the decision variable d=F(M) • Update the decision variable by adding the change along that direction • Repeat this process until the end point is reached

  19. Midpoint Line Algorithm

  20. Midpoint Line Algorithm • Fractional arithmetic still problematic • Should be avoided if possible • Redefine F(x,y) by multiplying by 2 • Thus F(x,y) = 2(ax+by+c) • Replace all constants and the decision variable by 2 • Removes all multiplications; only additions left

  21. Midpoint Line Algorithm

  22. Midpoint Line Algorithm MidpointLine(x0,y0,x1,y1,color) { int dx,dy,dE,dNE,d,x,y; dx=x1-x0; dy=y1-y0; d=2*dy-dx; dE=2*dy; dNE=2*(dy-dx); x=x0;y=y0; DrawPixel(x,y,color); for(x=x0;x<x1; x++) { if (d<=0) d+=dE ; else {d+=dNE; y++;} DrawPixel(x,y,color); }

  23. Bresenham’s AlgorithmAn example 12 11 10 9 8 7 4 5 6 7 8 9

  24. Bresenham’s AlgorithmAn example 12 11 10 9 8 7 4 5 6 7 8 9

  25. Bresenham’s AlgorithmAn example 12 11 10 9 8 7 4 5 6 7 8 9

More Related