1 Lecture 6 Attributes of graphical primitives Colors Colors in OpenGL Algorithms for scan-conversion.

  • Published on
    21-Dec-2015

  • View
    214

  • Download
    0

Embed Size (px)

Transcript

  • Slide 1
  • 1 Lecture 6 Attributes of graphical primitives Colors Colors in OpenGL Algorithms for scan-conversion
  • Slide 2
  • 2 Colors It is difficult to explain colors: they should be experienced. Color is nothing more that wavelengths of light at a certain frequency. Actually, the human eye is only said to perceive a small fraction of the total light available. Certain lights called Gamma Rays, X-rays, and Ultraviolet lights are too low of a frequency for humans to see. Lights like Infrared, Microwaves, and Radio waves, are too high of a frequency for the human eye to see. Humans only see a small portion of light between these frequencies and we calls these lights color.
  • Slide 3
  • 3 Colors The color of an object is evident by the amount of light it reflects. For example, a red apple reflects mostly red light, and absorbs mostly all other colors. The color white is obtained when all colors are reflected off an object (no colors absorbed) giving the object appearance of white. Black is the absorption of all colors. It is not considered as a color. Black is considered the absence of color, and therefore is not allowed to join its color family.
  • Slide 4
  • 4 Colors: RGB Model There are different ways to choose color for your drawing. The easiest and most powerful way is to use RGB color. RGB color stands for Red, Green, and Blue, and is called additive color. It is given this name because RGB starts with the absence of color, and then adds elements of red, green, and blue to achieve the desired color.
  • Slide 5
  • 5 Colors: RGB Model It is not possible to obtain all colors with RGB model, or with any other color model. RGB just matches a color as close as possible. Usually there are 256 different values for each red, green, and blue. This also means that there are about 16.7 million different colors available (256*256*256 = 2 8 * 2 8 * 2 8 ). Some systems and languages, such as OpenGL, uses a similar idea with RGB color, except that they may use numbers from 0.0 to 1.0. Theoretically this means that there is an infinite amount of colors formed from RGB because there is an infinite amount of numbers between 0 and 1.
  • Slide 6
  • 6 Colors RGB model
  • Slide 7
  • 7 Colors RGB Color cube
  • Slide 8
  • 8 Colors CMY model
  • Slide 9
  • 9 Colors CMY cube
  • Slide 10
  • 10 Colors HSV model (hue, saturation, value): used by artists Called also HSL model (L-light) Hue: the name that we give to a color: red, yellow, cyan, etc. Saturation: how pure the color is, that is how far is a hue from the same hue mixed with white so that the color has more pastel shade Value/Light - how bright the color appear
  • Slide 11
  • 11 Colors HSV model (hue, saturation, value)
  • Slide 12
  • 12 Levels of Gray Levels of gray/colors: instead of 0/1 more digits
  • Slide 13
  • 13 Levels of Gray Reducing the levels of gray: Original scanned picture
  • Slide 14
  • 14 Levels of Gray Reducing the levels of gray: Three bits per pixel
  • Slide 15
  • 15 Levels of Gray Reducing the levels of gray: One bit per pixel
  • Slide 16
  • 16 Color palette Color table (palette)
  • Slide 17
  • 17 Colors in OpenGL OpenGL uses RGB color model The values of red, green, and blue are numbers from 0.0 to 1.0.
  • Slide 18
  • 18 Colors in OpenGL The instruction glColor3f( float red, float green, float blue ) sets a color. The syntax is the same as in the sample program for drawing a triangle. Problem: Draw 5 triangles with different colors. Write the values of RGB and the color obtained.
  • Slide 19
  • 19 Colors in OpenGL Syntax of OpenGL instructions: FunctionName2i or FunctionName3f 2 or 3 means number of parameters: 2 or 3 i - integer values, f- float values, d-double values. All the following instructions will give the same color - red: glColor1f( 1.0 ); glColor1d( 1.0 ); glColor4i( 1, 0, 0, 0 );
  • Slide 20
  • 20 Colors in OpenGL There is an optional fourth value in the color definition called the alpha value. Alpha values are used for displaying different effects, e.g., blending, transparency, lighting and shadows. OpenGL may interpolate different colors. Problem: Use the sample triangle program and assign different colors for each vertex. Describe the result.
  • Slide 21
  • 21 Colors in OpenGL glBegin( GL_TRIANGLES ); // Begin a triangle glColor3f( 1.0, 0.0, 0.0 );// Red color glVertex3f( 0.25, 0.25, 0.0 ); glColor3f( 0.0, 1.0, 0.0 );// Green color glVertex3f( 0.75, 0.25, 0.0 ); glColor3f( 0.0, 0.0, 1.0 );// Blue color glVertex3f( 0.75, 0.75, 0.0 ); glEnd(); // End the triangle
  • Slide 22
  • 22 Scan-Conversion
  • Slide 23
  • 23 Triangle Scan-Conversion
  • Slide 24
  • 24 Simple Algorithm
  • Slide 25
  • 25 Inside Triangle Test
  • Slide 26
  • 26 Inside Triangle Test
  • Slide 27
  • 27 Triangle Sweep-Line Algorithm
  • Slide 28
  • 28 Triangle Sweep-Line Algorithm
  • Slide 29
  • 29 Polygon Scan Conversion
  • Slide 30
  • 30 Inside Polygon Rule
  • Slide 31
  • 31 Polygon Sweep-Line Algorithm
  • Slide 32
  • 32 Polygon Sweep-Line Algorithm
  • Slide 33
  • 33 FloodFill Algorithm
  • Slide 34
  • 34 Scan Conversion of Polygons: Hardware Conversion

Recommended

View more >