1 / 18

Tools for Raster Displays

Tools for Raster Displays. CVGLab. Goals of the Chapter. To describe pixmaps and useful operations on them. To develop tools for copying, scaling, and rotating pixmaps. To discuss different drawing modes, such as XOR mode. To develop tools for compositing images.

omana
Télécharger la présentation

Tools for Raster Displays

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. Tools for Raster Displays CVGLab

  2. Goals of the Chapter • To describe pixmaps and useful operations on them. • To develop tools for copying, scaling, and rotating pixmaps. • To discuss different drawing modes, such as XOR mode. • To develop tools for compositing images. • To develop ways to define and and manipulate regions. • To develop Bresenham’s line-drawing algorithm. • To build tools for filling regions-particularly polygon-defined ones. • To discuss aliasing and to develop antialiasing methods. • To develop dithering and error-diffusion tools for creating more gray levels.

  3. Introduction • Showing ways to draw lines and to fill polygons with colors and textures. The rasterization step in the graphics pipeline.

  4. Manipulating Pixmaps • Operations of Interest for Pixmaps • Drawing a Picture • Copying a Pixmap from One Place to Another -. read operation -. draw operation • glRead Pixels( ) ; ← reads a region of the frame buffer into off-screen memory • glCopyPixels( ) ; ← copies a region of the frame buffer into another part of the frame buffer • glDrawPixels( ) ; ← draws a given pixmap into the frame buffer

  5. Manipulating Pixmaps • Useful Data Types for Pixmaps -. The bitmap: Each pixel is stored in a single bit, so each pixel is either “on” or “off.” -. The gray-scale pixmap: Each pixel is stored in a single byte, representing levels of gray from 0 for black up to 255 for white. -. LUT indices: Each pixel contains a number that represents an index into a color lookup table(LUT). Very often, the LUT contains 256 entries, so an index value can be stored in a single byte. -. The RGB pixmap: Each pixel consists of three bytes, one each for the red, green, and blue components of the pixel. Such pixels are considered to represent “true color.” -. The RGBA pixel: Each pixel consists of four bytes: the same three as n the RGB pixmap and a fourth byte that contains an “alpha value,” which represents opacity.

  6. Manipulating Pixmaps • Scaling and Rotating Images -. In scaling a pixmap by some factor, s: when s is larger than unity, the pixmap is enlarged; otherwise it is reduced. -. glPixelZoom (sx, 1); glutPostRedisplay ( ); Multiple versions of a pixmap formed by scaling in x.

  7. Manipulating Pixmaps • More General Scaling and Rotations Computing the transformed image

  8. Combining Pixmaps • Combining pix maps is useful for such things as moving cursors around a screen, comparing two images, and morphing one image into another. • Tow pixmaps A and B are combined to form a third pixmap C

  9. Combining Pixmaps • The Read-Modify-Write Cycle First the pixels in D are read from memory, then they are modified by combining them with the pixels of S, and finally, the result is written back into D. A read-modify-write cycle applied to the frame buffer. • The Alpha Channel and Image Blending

  10. Combining Pixmaps glblendFunc (GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); • Logical Combinations of Pixmaps • -. Other way of combining pixmap. • -. The pixmaps are combined pixel by pixel as before, but the bits in a pixel are combined logically, bit by bit.

  11. Combining Pixmaps -. OR-ed, AND-ed, EXCLUSIVE OR-ed… ex) A RGB (21, 127, 0) → (00010101, 01111111, 00000000) B → (01010101, 11110000, 10000101) C = (01010101, 11111111, 10000101) ← the OR of A and B. C = (01000000, 10001111, 10000101) ← the XOR of A and B. Effect of various logical operations.. Possible logical operations in OpenGL.

  12. Combining Pixmaps

  13. Combining Pixmaps • The BitBLT Operation -. Stands for bit boundary block transfer. • Definition of the BitBLT Operation -. The BitBLT copies source pixels S to the destination rectangle D using the logical combination method described earlier: Various choices for are available. -. Most BitBLT processors: clipping rectangle.

  14. Do-It-Yourself Line Erawing:Fresenham’s Algorithm • Bresenham’s line-drawing algorithm – present a much faster method. -. the ideal line satisfies the equation float y = a.y; // initial value for (int x = a.x; x<=b.x; x++, +=m) setpixel(x, round(y));

  15. Do-It-Yourself Line Erawing:Fresenham’s Algorithm • Bresenham’s Line-Drawing Algorithm -. Offers a significant advantage over the method just set out, as it avoids floating-point arithmetic and rounding. -. midpoint algorithm: produces the same pixels as bresenham’s algorithm for straight lines, and its approach can be extended directly to the drawing of more complex shapes such as circles and ellipses.

  16. Do-It-Yourself Line Erawing:Fresenham’s Algorithm -. The important property of F(x, y) is that its sign tells whether (x, y) lies above or below the ideal line: if F(x, y) < 0 then (x, y) lies above the line; if F(x, y) > 0 then (x, y) lies below the line;

  17. Do-It-Yourself Line Erawing:Fresenham’s Algorithm • Removing the Restrictions on Bresenham’s Algorithm -. To Get the Same Line when ax > bx. -. Lines Having Slope Greater than Unity. -. Lines with Negative Slopes. -. Horizontal and Vertical Lines. • Summary of Properties a Drawn Line Should Have -. Straight, pass both of the given endpoints. -. Smooth and have uniform brightness along its length. -. Repeatable. -. (bx, by) to (ax, ay) = (ax, ay) to (bx, by).

  18. Do-It-Yourself Line Erawing:Fresenham’s Algorithm • Drawing Lines in Patterns -. It is simple to incorporate such patterns into Bresenham’s algorithm.

More Related