
Note 7. Color Spaces and Models Light interactions with material Fluorescence(scattering & re-emission) Light in Reflection (diffuse) Reflection Transmitted Light (specular) Refractio Internal reflection • Other than the fluorescence effect, the rest will be taken into account with our illumination models. • Combination of wavelengths of light presented in the reflected or transmitted light determines what we perceive as color of the object. Light vs Color light : visible spectrum of EM radiation that affects our perception of colors. color: perceived property by which we can tell different lights apart. When view a light source, sense: • color ( or hue or dominant frequency ) • luminance ( or brightness ) = perceived intensity of light source, ( Watt / solid angle-projected area ) • purity ( or saturation ) = pureness of color CS527 Computer Graphics 1 Color models • The retina of human eyes consists of receptor cells, cones, that are color sensitive. According to the tri-stimulus theory, the color we perceive is the result of our cones’ relative responses to red, green and blue light. It is therefore convenient to represent color in terms of 3 primaries and work in a 3D color space. • A color model chooses 3 descriptors (or primaries) to describe colors. Different choices of descriptor sets give rise to different color spaces. • The range of colors that can be described by a color model is called the color gamut of the model. 1. RGB color space • RGB color scheme is an additive color system. A color C is expressed as a SUM of certain amounts of RGB primaries. It is used in video monitor in which a color pattern is produced by combining lights from the 3 screen phosphors. CRGB = RR + GG + BB • Each component of (R G B) is in the range of [0,1]. RGB color space is therefore confined to a unit cube. A color is specified by a 3-tuple (R,G,B), a point in the RGB cube. • Colors at diagonally opposite corners are complementary. They mix up to form white. G Complementary colors Grayscale Green (0,1,0) Yellow If C1 + C2 = white, then (1,1,0) C1 & C2 are complementary color pair Cyan (0,1,1) White (1,1, e.g. red & cyan; green & Black 1) (0,0, magenta; blue & yellow. (they 0) are at opposite corners of Red R the cube) (1,0,0 ) Blue Magenta (0,0,1 (1,0,1) B ) 2 CS527 Computer Graphics 2. CMY color space • CMY color model is a subtractive color system. Its 3 primaries are cyan, magenta and yellow. • It functions as a filter to subtract color from white light through reflection. A color, CCMY = ( C,M,Y), is formed from white by subtracting amount C of the complement of cyan (i.e. red), amount M of the complement of magenta (i.e. green), and amount Y of the complement of yellow (i.e. blue). Thus CMY and RGB color models are related as: M C 1 R Grayscale Magenta = (0,1,0) M 1 - G Blue (1,1,0) Y 1 B Red (0,1,1 Blac ) Whit k e (1 1 (0 0 Cyan C (1,0,0 ) Yellow Green (0,0,1) (1,0,1) Y • Origin = white as no components of the incident white light is absorbed. • Point (1,1,1) = black as all components of incident light are subtracted. 3. HSV color space • Instead of a set of color primaries, HSV model uses (hue, saturation, value) for color description. More natural for user interaction. • CONSTRUCTION of HSV color space - hexcone! Form a hexagon by projecting the RGB cube (1x1x1) along its body diagonal from white to black onto a plane. Green G Cyan Yellow Green Cyan Yellow White Red Blue Red Blue R Magenta B Magenta CS527 Computer Graphics 3 • Repeat projection with a smaller RGB cube (each edge reduced by 1/256 in length) to obtain another smaller projected hexagon until the origin is reached. Yellow Green G Red White (1 Cyan ) Magenta (2 Blue ) (2 ) R B Black • The HSV hexcone is formed by stacking up the 256 hexagons in decreasing order of size. • HSV coordinates is cylindrical. Colors are defined on and within the hexcone. V = MAX ( R, G, B ) on the surface of the cube concerned • The hue H is measured by the angle around the vertical gray axis. Red is 0o , Green 120o and Blue 240o . • Saturation or color strength, S % of non-white content in color ( purity of the color ). For a given V-plane, connect a line from the center to a point on the edge of the hexagon. For a point on the line, its S value is the ratio from 0 on the gray line to 1 on the edge of the hexagon. CS527 Computer Graphics 4 V (l) Yellow Green o (120 ) o Red 60 o (0 ) V =1 (White Cyan ) Magenta Blue (240o ) Gray scale Hue angle V =0 S (Black ) • HSV model corresponds to artist’s concept of shade, tint and tone. Any color in the RGB cube can be produced by the sum of a pure color (hue) and white. • When RGB units are normalized, H,S,V will also be normalized. Pure hue occurs at V = 1, S = 1. When S = 0, H is undefined ⇒ gray scale . CS527 Computer Graphics 5 Interactive Specification of Color V Tints - adding white white Pure hue ( V = 1, S = 1 ) tones Shades - adding Gray ( black ( de rease V S=0) ( 60 o , 1.0, tones: 04) Hue + black + white ( decreasing S, V) S black • HSV model provides intuitive color interface for users. Shade : hue + black tints: hue + white tones: hue + black + white • RGB model provides color interface to video monitor. CS527 Computer Graphics 6 #include <math.h> #define MIN(a,b) (a<b?a:b) #define MAX(a,b) (a>b?a:b) #define NO_HUE –1 /* Input: r, g, b in range [0..1] Output: h, s, v in range [0..1] Note: h is also normalized to 1. */ Void RgbToHsv ( float r, float g, float b, float *h, float *s, float *v ) { float max = MAX (r, MAX(g,b)), min = MIN (r, MIN(g,b)); float delta = max – min; *v = max; if ( max != 0.0 ) *s = delta / max; else *s = 0.0; if (*s == 0.0) *h = NO_HUE; else { if ( r == max ) *h = (g-b) / delta; else if ( g == max ) *h = 2+ (b-r) / delta; else if ( b == max ) *h = 4+ (r-g) / delta; *h *= 60.0; if ( *h < 0 ) *h += 360.0; *h /= 360.0; } } CS527 Computer Graphics 7 Aliasing and anti-Aliasing (Reading: Angel, section 7.11) • Rasterized line segments and edges of polygons look jagged. Jagged edges (aliasing) cannot be eliminated by increasing resolution - it only diminishes the problem at expensive cost. • Less costly approach can be used, e.g. by varying pixel intensity. Pixel closer to the centre of line will be shaded with higher intensity than those further away. • The application of techniques that reduce aliasing is called anti-aliasing. It is a sampling problem in nature. Anti-aliasing by unweighted Area Sampling • Assume a line is expressed as an idealized line segment in the frame buffer as being one pixel wide (use a square to represent a pixel area) • assume a line contributes to each pixel’s intensity an amount proportional to the percentage of the pixel’s tile it covers, e.g. pixel (2,1) is ~70% black, pixel (2,2) ~25% black, etc. A smoother-appearing image is produced. CS527 Computer Graphics 8 Properties of Unweighted Area Sampling 1. The intensity of a pixel intersected by a line edge decreases as the distance, d, between the pixel center and the edge increases. 2. Primitive cannot influence the intensity at a pixel at all if it does not intersect the pixel. 3. Equal areas dA contribute equal intensity dI, independent of d. dA1 = dA2 ⇒ dV1 = dV2 with ( dI ∝ dV ) ( refer to Fig 3.37on pg. 3-5) The blurring effect produced by this unweighted area sampling scheme makes the line look better at a distance. Modify 3rd property ⇒ Weighted Area Sampling • Associate each pixel with a circular base with radius larger than the pixel area, e.g. set pixel radius = pixel grid edge. dA1 L dA2 A small area dA closer to the pixel center has greater influence than does one at a greater distance. Anti-aliasing by weighted Area Sampling • Define a weighting function ( Filter function ), W(x,y), as a function of dA’s distance from the center of the pixel, d . Desirable properties of W(x,y): CS527 Computer Graphics 9 maximum at the center of pixel, decreases linearly with increasing d . Use the height of a circular cone to represent W(x,y) • Total intensity of a pixel is proportional to WS = WS ∫W (x,y) dA where ∫dA is the total area covered by the line segment, 1 ≥ WS ≥ 0 . for dA2 = dA1 dV2 > dV1 WS1 > WS2 dV2 dV1 Vtotal ≡ 1 dA2 (normalized, when dA 1 pixel is fully covered) • Net effect of weighted area sampling is to decrease the contrast between adjacent pixels in order to provide smoother transition. Unweighted Area Sampling ~ a box filter CS527 Computer Graphics 10 Weighted Area Sampling ~ cone weighting function Values above same area is greater as it approaches pixel center which coincides with center of cone. CS527 Computer Graphics 11 .
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages11 Page
-
File Size-