330 likes | 502 Views
CS559: Computer Graphics. Lecture 5: Color and Edge Li Zhang Spring 2008. Today. Eyes Cameras. Represented by a matrix. Image as a discreet function. Color Vision. Three kinds of cones:. Trichromacy. Experiment: Show a target color spectrum beside a user controlled color
E N D
CS559: Computer Graphics Lecture 5: Color and Edge Li Zhang Spring 2008
Today • Eyes • Cameras
Represented by a matrix Image as a discreet function
Color Vision Three kinds of cones:
Trichromacy • Experiment: • Show a target color spectrum beside a user controlled color • User has knobs that adjust primary sources to set their color • Primary sources are just lights with a fixed spectrum and variable intensity • Ask the user to match the colors – make their light look the same as the target • Experiments show that it is possible to match almost all colors using only three primary sources - the principle of trichromacy • Sometimes, have to add light to the target • In practical terms, this means that if you show someone the right amount of each primary, they will perceive the right color • This was how experimentalists knew there were 3 types of cones © University of Wisconsin, CS559 Spring 2004
Trichromacy For almost any given E_target(λ), we can solve for [r,g,b] so that the displayed color looks indistinguishable from the target color to our eyes.
RGB Cube Cyan (0,1,1) White(1,1,1) Yellow (1,1,0) Green(0,1,0) Blue (0,0,1) Magenta (0,1,1) Red (1,0,0) Black (0,0,0) Demo
Other Color Space • Hue-Saturation-Value (HSV) [Alvy Smith, 1978] • Hue: dominant color component • Saturation: color purity • Value: lightness or brightness • HSV-RGB transformation http://alvyray.com/Papers/hsv2rgb.htm http://www.mandelbrot-dazibao.com/HSV/HSV.htm
Other Color Space • L-A-B • L: luminance • A: position between magenta and green (negative values indicate green while positive values indicate magenta) • B: position between yellow and blue (negative values indicate blue and positive values indicate yellow) http://en.wikipedia.org/wiki/Lab_color_space http://en.wikipedia.org/wiki/CIE_1931_color_space
Spatial resolution and color R G B original
R G B Blurring the G component processed original
R G B Blurring the R component processed original
R G B processed Blurring the B component original
Lab Color Component L A rotation of the color coordinates into directions that are more perceptually meaningful: L: luminance, a: magenta-green, b: blue-yellow a b
L a b processed Bluring L original
L a b processed Bluring a original
L a b processed Bluring b original
Application to image compression • (compression is about hiding differences from the true image where you can’t see them).
Edge Detection • Convert a 2D image into a set of curves • Extracts salient features of the scene • More compact than pixels
Edge detection • One of the most important uses of image processing is edge detection: • Really easy for humans • Really difficult for computers • Fundamental in computer vision • Important in many graphics applications
What is an edge? • Q: How might you detect an edge in 1D?
Gradients • The gradient is the 2D equivalent of the derivative: • Properties of the gradient • It’s a vector • Points in the direction of maximum increase of f • Magnitude is rate of increase • How can we approximate the gradient in a discrete image?
Steps in edge detection • Edge detection algorithms typically proceed in three or four steps: • Filtering: cut down on noise • Enhancement: amplify the difference between edges and non-edges • Detection: use a threshold operation • Localization (optional): estimate geometry of edges, which generally pass between pixels
Edge enhancement • A popular gradient magnitude computation is the Sobel operator: • We can then compute the magnitude of the vector (sx, sy).
Canny Edge Detector • Smooth image I with 2D Gaussian: • Find local edge normal directions for each pixel • Along this direction, compute image gradient • Locate edges by finding max gradient magnitude (Non-maximum suppression)
Non-maximum Suppression • Check if pixel is local maximum along gradient direction • requires checking interpolated pixels p and r
The Canny Edge Detector original image (Lena)
The Canny Edge Detector magnitude of the gradient
The Canny Edge Detector After non-maximum suppression
Canny Edge Detector original Canny with Canny with • The choice of depends on desired behavior • large detects large scale edges • small detects fine features