1 / 58

Computer Graphics: Image Formation, Color,2D Viewing, First Graphics Program

Computer Graphics: Image Formation, Color,2D Viewing, First Graphics Program. Gerda Kamberova. Overview. Raster graphics Image formation Human visual system Pinhole camera model Synthetic camera Graphics API (object-viewer-projection) Color Physics of color

evita
Télécharger la présentation

Computer Graphics: Image Formation, Color,2D Viewing, First Graphics Program

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. Computer Graphics:Image Formation, Color,2D Viewing, First Graphics Program Gerda Kamberova Hofstra University

  2. Overview • Raster graphics • Image formation • Human visual system • Pinhole camera model • Synthetic camera • Graphics API (object-viewer-projection) • Color • Physics of color • 3-color theory and display technology • Human color perception • RGB color model in CG • Indexed color model Hofstra University

  3. Overview (cont) • 2D Viewing • Clipping window • Viewports • Window-to-viewport transformation • Simple graphics program Hofstra University

  4. Architecture of Early Graphic Systems: von Neumann Hofstra University

  5. Graphics Systems Architecture: Display Processor (DP) • Ivan Sutherland, MIT, 1963 • DP: special purpose graphics processor. Has instructions to display primitives on CRT. Repetitively executes DL at rate sufficient to avoid flicker. • Vector display CRT • Display list (DL) contains segment definitions • Refresh buffer in DP stores DL Hofstra University

  6. Raster Graphics • Became feasible when memory cost dropped (mid 70s) • Electron beam scans regular pattern of horizontal raster lines(rl) • Pixels are individual dots on rl. • A picture is array of pixels Hofstra University

  7. CRT Display • Most common • Phosphorous compound deposited on screen • Electron gun emits electron beam when heated • When beam hits screen pixel lights up • Beams go in order: line by line, pixel by pixel • Frame: consists of all scan lines • Picture: the pattern created on the screen Hofstra University

  8. CRT Display • Persistence: the time it takes for a pixel to loose 10% of its original energy • Most CRT 10-60 milsec persistence • Must refresh picture, beams redraws 60 times per sec, to avoid flicker of picture on screen. Thus, FB must be read 60 time per second. Hofstra University

  9. Frame Buffer(FB) • FB prescribes the pattern that the electron beam must draw • FB is core of the graphics hardware • FB stores the discretized picture (array of pixels) • Implemented with special memory that enables fast redisplay; VRAM, DRAM • FB spatial resolution: defined by number pixels • FB color resolution: defined by FB depth, number bits per pixel Hofstra University

  10. Frame Buffer • FB consists of bit planes • 1 bit plane: binary image (beam on/off) • 8 bit planes=1 pixmap: 256 gray levels; beam has 256 intensity levels; FB has 8 pixels depth • Color image: 3 pixmaps (R,G,B). • Each pixmap prescribes picture for an electron gun. Three guns emit 3 beams which create 3 close spots on the screen of 3 different color each. Human vision system averages and perceives a single color at the pixel. • Wit 8-bit color in (R,G,B) there are 24 bits in FB prescribing color. 24bits: 224 = 16K colors • FB usually 32 bits = 24 for color + 8bits for alpha value Hofstra University

  11. Raster Graphics • Rasterization: conversion of 2D geometric primitives and their attributes to pixel assignments and color in the FB • Video controller: controls operation of the display, can access FB directly • Video controller and DP free CPU from graphics operations: mainly, scan conversion, generating various line styles, interface with interactive input devices. Hofstra University

  12. Pipeline Architecture (PA) • Typical for contemporary CG systems • In PA, same set of operations (transformations) are applied thousands, millions of data primitives • PA exploits “assembly line” paradigm Vertex in 3D model -- Pixel in FB Hofstra University

  13. Pipeline Architecture: Fundamental Operations • Transformations: modeling/viewing • Clipping (ignore from further considerations all parts that are not in field of view) • Projection (from 3D to continuous 2D geometry) • Rasterization (from continuous 2D geometry to pixels in the frame buffer) Hofstra University

  14. Pipeline Architecture • Front-end (modeling/viewing transformations, clipping, and projection) utilize pipeline. The calculations are implemented in hardware. We will study the algorithms for the front-end • Back-end (rasterization) exploits fast memory, parallelism in FB access, and spatial continuity in the image. • PA is used in high-performance graphics workstations, and fancy graphics cards. Hofstra University

  15. Homework • Read Angel, Ch 1 • Read WND, Ch 1, pp 1-20 • Try to compile and run the example program hello.c • Use husun3, in addition if you will be working at home on a PC try compiling and running at home as well (see instructions on the web page). Hofstra University

  16. Object-Light-Viewer Light source Object 3D object is viewer, light source independent 2D image of the object observed by the viewer is dependent on the light source and on the viewer Viewer Hofstra University

  17. Human Visual System Hofstra University

  18. Pinhole Camera • Small hole in the center of one side • Film placed on opposite side • Need long exposure Hofstra University

  19. www.pinhole.com Hofstra University

  20. Pinhole Camera Model • Models geometry of image formation • Image (projection) plane • Optical center, C • Focal length, d • Projection: image of a point is a point • Infinite Depth of Field: every point within field of view is in focus • In basic computer graphics, all objects are in focus c Hofstra University

  21. Synthetic Camera Model • Creating a computer generated image is similar to forming an image using an optical system Hofstra University

  22. Synthetic Camera Model • Projector • Center of Projection • Projection Plane Hofstra University

  23. Synthetic Camera: simulates pinhole camera • Place optical (projection) center behind projection plane, so image is not inverted • Make image finite dimensions by placing Clipping Rectangle in the projection plane • The clipping rectangle acts as a window through which a viewer located at center of projection observes the world. Hofstra University

  24. Graphics Systems • Most API are based on the synthetic camera model • They provide functions to specify • Objects (defined by sets of primitives and attributes) • Viewer • Projection type • Camera position • Camera orientation • focal length (effects image size) • Image plane size (clipping rectangle) Hofstra University

  25. 2D Viewing: Window to Viewport transformation • Viewing/clipping window: part of projected image that is being viewed. In view/projection coordinates • Viewport: part of X-window (output window) where the viewing window is mapped. In normalized device coordinates (0 to 1). Device independent. • Screen (device specific) coordinates, integers. Hofstra University

  26. Window-to-viewport transformation • Range map: given values in range A, map them linearly in range B r Hofstra University

  27. Window to viewport transformation (4-11) • From world/view coordinates to NDC space • Simply 2D case of range map • Apply range map in x and y independently NDC space Hofstra University

  28. 2D Viewing: window to screen coordinates (4-130) Normalized Device coord. Screen coord. (device spec.) World coordinates Hofstra University

  29. Aspect Ratio • Aspect Ratio of a rectangle is the ratio of the rectangle’s width to its height • Adjust height & width of viewport to match the aspect ratio of viewing window. Hofstra University

  30. Coordinate systems used • Modeling coordinates: for specifying an object • World coord.: for placing the object in a scene • Viewing (eye) coord.: with respect to a coordinate system attached to the camera • Clipping coord.: with respect to clipping window • Normalized device coordinates: 2D, after projection, for display, but device independent • Physical device coordinates for pixels in FB Hofstra University

  31. Graphics Pipeline Transformations and Coordinate Systems Hofstra University

  32. Color • Light is electromagnetic radiation • Visible light, 350 (blue) – 780 (red) nm • Color light is characterized by a distribution • Monochromatic light – single frequency Hofstra University

  33. Color Attributes • Color is characterized also by attibutes • Hue, dominant wavelength • Brightness, intensity • Saturation, purity • Chromaticity, hue and saturation • Color on CRT display is created by exciting R,G,B phosphor. This approach is based on the three-color theory Hofstra University

  34. Three-color Theory • Color is described as aditive mixture of 3 primary colors, R,G,B • , the coefficients are called tristimulus values • Tristimulus values – determine the intensities of the primary colors • Three-color theory is based on popular theory, Thrichromatic theory, of human color perception Hofstra University

  35. Trichromatic Theory of Human Color Perception • Rushton:”…color vision is mediated by 3 different kinds of retinal receptors, each responding best to light from different part of the visible spectrum.” Each receptor is characterized by a censitivity curve. • Color perception is facilitated by the cones in the retina. There 3 types of pigments in the cones. • The trichromatic theory is based on empirically established trichromaticity of color matching Hofstra University

  36. Trichromaticity of color matching • By adjusting the radiance of the three lights of primary colors, R,G,B, match the fourth color, C. • Match is measured by the level of excitement of the photo receptors in the cones of the retina • The trichromatic theory predicts if two colors will look alike to an objective viewer, but it does not characterized how actually the colors will look to an observer. • The theory is proven wrong by Land, 1977. Color perception is subjective. It is not related solely to the wavelength (physics) of the light. Hofstra University

  37. Color in Computer Graphics • Based on the tricolor theory • Color is described usually by triple of numbers • Different CG color models differ by the meaning of those triples • There are 3 different context in which color is discussed in CG • Modeling/rendering • RGB monitor space, a triple produces here a particular color on a particular display • Storage and communication Hofstra University

  38. RGB Color Model • Traditional model for CG • R,G,B primaries • The triple gives relative weights, between 0 and 1, to the 3 primary colors in an additive system • The color gamut (all available colors) is represented by RGB color cube Hofstra University

  39. Color Cube Hofstra University

  40. Color Cube Hofstra University

  41. Color Formation http://www.color-tec.com/color.htm Hofstra University

  42. Comments on RGB Space • Perceptually nonlinear • Equal distances in space do not correspond to perceptually equal sensations • Same color sensation may reslut from multiple (r,g,b) triples • At low RGB values a noticeable change is produces very slowly. At high values the change is produced fast. Hofstra University

  43. Comments on RGB Space • With 3 primaries only a subset of the human perception color space can be generated, and reproduced on a monitor • (RGB) not good color descriptors for human use. There are better color models for use by people, (H,S,V). • RGB is good enough approximation for CG • Convenient for hardware implementations Hofstra University

  44. Frame Buffer Configurations • RBG color: FB bitplanes drive DAC directly (control guns) glColor3f(1.0, 0.0, 0.0) Hofstra University

  45. Indexed color • Index color: FB bitplanes specify index in a lookup color table • N bit planes  2^N entries in table • Each entry w-bits, w>=N • Thus, a small depth FB, N, can have more colors available, 2^w, but only 2^N simultaneously are available Hofstra University

  46. Graphics Programming Basic 2D Programs in OpenGL Hofstra University

  47. Vertex • Vertex – a location in space • Define the atomic geometric objects of our graphics system • Point in space – one vertexLine Segment , specified by two vertices • glVertex* Hofstra University

  48. Objects • Usually defined by a set of vertices glBegin(GL_POLYGON); glVertex3f(0.0, 0.0, 0.0); glVertex3f(0.0, 1.0, 0.0); glVertex3f(0.0, 0.0, 1.0); glEnd( ); Hofstra University

  49. glVertex* • glVertex*, were * can be nt or ntv • n siginifies number of dimensionst denotes the data type, integer (i), float (f), double (d)v pointer to an array • Ex: glVertex2f(1.0, 3.5, 6.7) Hofstra University

  50. Declarations • OpenGL typesGLfloatGLint • Two dimensions example:glVertex2i(Glint x, Glint y) • Three dimensions example:glVertex3f(Glfloat x, Glfloat y, Glfloat z) • Using an arrayGLfloat vertex[3]glVertex3fv(vertex) Hofstra University

More Related