1 / 78

Scan Conversion of Lines

Scan Conversion of Lines. Dr. Scott Schaefer. Displays – Cathode Ray Tube. Displays – Liquid Crystal Displays. Displays – Light-Emitting Diode. Displays – Pixels. Pixel: the smallest element of picture - Integer position (i,j) - Color information (r,g,b). y. x. (0,0). Problem.

saville
Télécharger la présentation

Scan Conversion of Lines

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 Lines Dr. Scott Schaefer

  2. Displays – Cathode Ray Tube

  3. Displays – Liquid Crystal Displays

  4. Displays – Light-Emitting Diode

  5. Displays – Pixels • Pixel: the smallest element of picture - Integer position (i,j) - Color information (r,g,b) y x (0,0)

  6. Problem • Given two points (P, Q) on the screen (with integer coordinates) determine which pixels should be drawn to display a unit width line

  7. Problem • Given two points (P, Q) on the screen (with integer coordinates) determine which pixels should be drawn to display a unit width line

  8. Problem • Given two points (P, Q) on the screen (with integer coordinates) determine which pixels should be drawn to display a unit width line

  9. Special Lines - Horizontal

  10. Special Lines - Horizontal Increment x by 1, keep y constant

  11. Special Lines - Vertical

  12. Special Lines - Vertical Keep x constant, increment y by 1

  13. Special Lines - Diagonal

  14. Special Lines - Diagonal Increment x by 1, increment y by 1

  15. How about Arbitrary Lines?

  16. Arbitrary Lines Slope-intercept equation for a line: m: slope b: y-intercept

  17. Arbitrary Lines Slope-intercept equation for a line: How can we compute the equation from (xL,yL), (xH,yH)? m: slope b: y-intercept

  18. Arbitrary Lines Slope-intercept equation for a line: How can we compute the equation from (xL,yL), (xH,yH)? m: slope b: y-intercept

  19. Arbitrary Lines • Assume • Other lines by swapping x, y or negating • Take steps in x and determine where to fill y

  20. Simple Algorithm • Start from (xL, yL) and draw to (xH, yH) where xL< xH ( x0, y0 ) = ( xL, yL ) For ( i = 0; i <= xH-xL; i++ ) DrawPixel ( xi, Round ( yi) ) xi+1 = xi+ 1 yi+1 = mxi+1 + b

  21. Simple Algorithm • Start from (xL, yL) and draw to (xH, yH) where xL< xH ( x0, y0 ) = ( xL, yL ) For ( i = 0; i <= xH-xL; i++ ) DrawPixel ( xi, Round ( yi) ) xi+1 = xi+ 1 yi+1 = m ( xi + 1 ) + b

  22. Simple Algorithm • Start from (xL, yL) and draw to (xH, yH) where xL< xH ( x0, y0 ) = ( xL, yL ) For ( i = 0; i <= xH-xL; i++ ) DrawPixel ( xi, Round ( yi) ) xi+1 = xi+ 1 yi+1 = mxi + m + b

  23. Simple Algorithm • Start from (xL, yL) and draw to (xH, yH) where xL< xH ( x0, y0 ) = ( xL, yL ) For ( i = 0; i <= xH-xL; i++ ) DrawPixel ( xi, Round ( yi) ) xi+1 = xi+ 1 yi+1 = mxi + b + m

  24. Simple Algorithm • Start from (xL, yL) and draw to (xH, yH) where xL< xH ( x0, y0 ) = ( xL, yL ) For ( i = 0; i <= xH-xL; i++ ) DrawPixel ( xi, Round ( yi) ) xi+1 = xi+ 1 yi+1 = mxi + b + m

  25. Simple Algorithm • Start from (xL, yL) and draw to (xH, yH) where xL< xH ( x0, y0 ) = ( xL, yL ) For ( i = 0; i <= xH-xL; i++ ) DrawPixel ( xi, Round ( yi) ) xi+1 = xi+ 1 yi+1 = yi + m

  26. Simple Algorithm - Example

  27. Simple Algorithm - Example

  28. Simple Algorithm - Example

  29. Simple Algorithm - Example

  30. Simple Algorithm - Example

  31. Simple Algorithm - Example

  32. Simple Algorithm - Example

  33. Simple Algorithm - Example

  34. Simple Algorithm - Example

  35. Simple Algorithm - Problems • Floating point operations • Rounding • Can we do better? ( x0, y0 ) = ( xL, yL ) For ( i = 0; i <= xH-xL; i++ ) DrawPixel ( xi, Round ( yi) ) xi+1 = xi+ 1 yi+1 = yi + m

  36. Midpoint Algorithm • Given a point just drawn, determine whether we move E or NE on next step

  37. Midpoint Algorithm • Given a point just drawn, determine whether we move E or NE on next step • Is the line above or below ? Below: move E Above: move NE

  38. Midpoint Algorithm

  39. Midpoint Algorithm – Implicit Forms • How do we tell if a point is above or below the line?

  40. Midpoint Algorithm – Implicit Forms • How do we tell if a point is above or below the line?

  41. Midpoint Algorithm – Implicit Forms • How do we tell if a point is above or below the line?

  42. Midpoint Algorithm – Implicit Forms • How do we tell if a point is above or below the line?

  43. Midpoint Algorithm – Implicit Forms • How do we tell if a point is above or below the line?

  44. Midpoint Algorithm – Implicit Forms • How do we tell if a point is above or below the line?

  45. Midpoint Algorithm – Implicit Forms • How do we tell if a point is above or below the line? Properties f(x,y)=0 (x,y) on the line f(x,y)<0 (x,y) below the line f(x,y)>0 (x,y) above the line

  46. Midpoint Algorithm – Implicit Forms

  47. Midpoint Algorithm – Implicit Forms

  48. Midpoint Algorithm – Implicit Forms

  49. Midpoint Algorithm – Implicit Forms

  50. Midpoint Algorithm – Implicit Forms

More Related