1 / 27

Image Synthesis

Image Synthesis. Rabie A. Ramadan, PhD 7. Image Rasterization. Rasterization and Fragment Processing. A precise sequence of steps for converting primitives into patterns of pixel values in the framebuffer.

Download Presentation

Image Synthesis

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. Image Synthesis Rabie A. Ramadan, PhD 7

  2. Image Rasterization

  3. Rasterization andFragment Processing A precise sequence of steps for converting primitives into patterns of pixel values in the framebuffer. Digital images created or captured (for example, by scanning in a photo) as a set of samples of a given space.

  4. The graphics pipeline

  5. Pipeline overview

  6. Primitives

  7. Rasterization First job: enumerate the pixels covered by a primitive Simple, aliased definition: pixels whose centers fall inside Second job: interpolate values across the primitive e.g., colors computed at vertices Will see applications later on

  8. Rasterizing lines

  9. Point sampling

  10. Point sampling in action

  11. Pixel addressing in raster graphics

  12. visual accuracy speed Raster conversion algorithms: requirements

  13. Line drawing algorithms

  14. Line – raster representation

  15. Screen made of pixels High-level language specifies line System must color pixels How does computer draw line?

  16. Line definition: ax+by+c = 0 Also expressed as: y = mx + d m = slope d = distance For x=xmin to xmax compute y = m*x+d light pixel (x,y) Naïve algorithm for lines

  17. Only works with -1 £m£ 1: Extension by symmetry m = 3 m = 1/3 Extend by symmetry for m > 1

  18. 2 floating-point operations per pixel Improvements: compute y = m*p+d For x=xmin to xmax y += m light pixel (x,y) Still 1 floating-point operation per pixel Compute in floats, pixels in integers Problems

  19. DDA ( Digital Differential Algorithm ) m < 1

  20. DDA ( Digital Differential Algorithm ) m > 1

  21. DDA ( Digital Differential Algorithm ) m > 1

  22. input line endpoints, (x0,y0) and (xn, yn) set pixel at position (x0,y0) calculate slope m Case |m|≤1: repeat the following steps until (xn, yn) is reached: yi+1 = yi + y/ x xi+1 = xi + 1 set pixel at position (xi+1,Round(yi+1)) Case |m|>1: repeat the following steps until (xn, yn) is reached: xi+1 = xi + x/ y yi+1 = yi + 1 set pixel at position (Round(xi+1), yi+1) Digital Differential Algorithm

  23. d2 y = m(x+1) + b d1 Bresenham's line algorithm y = mx + b y x x+1

  24. input line endpoints, (x0,y0) and (xn, yn) calculate x = xn - x0 and y = yn - y0 calculate parameter p0 = 2 y - x set pixel at position (x0,y0) repeat the following steps until (xn, yn) is reached: if pi < 0 set the next pixel at position (xi +1, yi ) calculate new pi+1 = pi + 2 y if pi ≥ 0 set the next pixel at position (xi +1, yi + 1 ) calculate new pi+1 = pi + 2(y - x) Bresenham's line algorithm (slope ≤ 1)

  25. DDA works with floating point arithmetic Rounding to integers necessary Bresenham’s algorithm uses integer arithmetic Constants need to be computed only once Bresenham’s algorithm generally faster than DDA DDA versus Bresenham’s Algorithm

  26. Circle equation: x2+y2-r2 = 0 Simple algorithm: for x = xmin to xmax y = sqrt(r*r - x*x) draw pixel(x,y) Work by octants and use symmetry Circle: naïve algorithm

  27. Choice between two pixels: Circle: Bresenham algorithm …or that one Circle drawn so far Either I lit this pixel…

More Related