Color Image Processing Jesus J. Caban Outline Discuss Assignment #1 Project Proposal Color Perception & Analysis 1
Discuss Assignment #1 Project Proposal Due next Monday, Oct 4th Project proposal Submit a 1-2 page document Include: Abstract Introduction / Motivation Plan / Schedule APIs / Libs / Resources you plan to use 2
Reading List Reading for Wednesday. Chapter #1: http://www.csee.umbc.edu/~caban1/fall2010/cmsc691/docs/reading/ Review: What we know so far 3
9/27/10 Formation of a Digital Image Steps: 1. 2. 3. 4. 5. 6. World: reality / geometry Optics: focus light from world onto sensor Sensor: convert light to electrical energy Signal: representation of incident light as continuous electrical energy Digitizer: converts continuous signal to discrete signals Digital Representation: final representation of reality in computer memory (i,j) 1 2 3 4 5 6 4
Basics of Spatial Filtering In general, linear filtering of an image f of size MxN is given by This concept called convolution. Filter masks are sometimes called convolution masks or convolution kernels. Smoothing 1 / 9 1 / 9 1 / 9 1 / 16 2 / 16 1 / 16 1 / 9 1 / 9 1 / 9 2 / 16 4 / 16 2 / 16 1 / 9 1 / 9 1 / 9 1 / 16 2 / 16 1 / 16 5
1 st Derivative Filtering Roberts cross-gradient operators Sobel operators The Inverse DFT 6
Morphology: Erosion After erosion with a disc of radius 5 Original image After erosion with a disc of radius 20 After erosion with a disc of radius 10 Noise Models There are many different models for the image noise term η(x, y): Gaussian Most common model Rayleigh Erlang Exponential Uniform Impulse Salt and pepper noise 7
Image Restorization Different kinds of mean filters Arithmetic Mean Geometric Mean Harmonic Mean Contraharmonic Mean Statistical Techniques Median filter Max and min filter Midpoint filter Alpha trimmed mean filter Color Image Processing 8
Introduction The use of color in image processing is important given that: color is a powerful descriptor humans can discern thousands of color shades and intensities Color image processing Color spaces Convert between different color spaces color Newton s summary drawing of his experiments with light. Using a point source of light and a prism, Newton separated sunlight into its fundamental components. He also showed that the decomposition is reversible. 9
Color Fundamentals In 1666 Sir Isaac Newton discovered that when a beam of sunlight passes through a glass prism, the emerging beam is split into a spectrum of colors Colors ranged from violet to red Visible Light Chromatic light spans the electromagnetic spectrum from approximately 400 to 700 nm Ultra - Short- Gamma X rays violet Infrared Radar FM TV wave AM AC electricity 10-12 10-8 10-4 1 10 4 10 8 Wavelength in meters (m) Visible light 400 nm 500 nm 600 nm 700 nm Wavelength in nanometers (nm) 10
Color Fundamentals During the Image Formation lecture, we mentioned that human color vision is achieved through 6 to 7 million cones in each eye 66% of these cones are sensitive to red light 33% to green light 6% to blue light Color Fundamentals The colors that humans and most animals perceive in an object are determined by the nature of the light reflected from the object A green object reflects light with wave lengths in the range of 500 570 nm while absorbing most of the energy at other wavelengths White Light Green Light Colours Absorbed 11
Color Fundamentals Three basic qualities are used to describe the quality of a chromatic light source: 1. Radiance: the total amount of energy that flows from the light source (measured in watts) 2. Luminance: the amount of energy an observer perceives from the light source (measured in lumens) 1. Note we can have high radiance, but low luminance 3. Brightness: a subjective (practically not measurable) notion that embodies the intensity of light What about color? Primary Colors Adaptive Color Mixing But, what s red? Subtractive Color Mixing 12
CIE standard CIE - Commision Internationale d Eclairage In 1931, CIE defined a standard system for color representation. XYZ coordinate system Strangely these do not match the CIE standards for red (700nm) green (546.1nm) blue (435.8nm) Color Fundamentals (cont ) 13
CIE Chromacity Diagram Specifying colors systematically can be achieved using the CIE chromacity diagram The point green 25% red 62% green 13% blue The positions of the various spectrum colors (from violet to red) are indicated around the boundary CIE Chromacity Diagram (cont ) On this diagram the x-axis represents the proportion of red and the y-axis represents the proportion of green used The proportion of blue used in a color is calculated as: z = 1 (x + y) 14
CIE Chromacity Diagram Any color located on the boundary of the chromacity chart is fully saturated The point of equal energy has equal amounts of each color and is the CIE standard for pure white Any straight line joining two points in the diagram defines all of the different colors that can be obtained by combining these two colors additively This can be easily extended to three points Color Models There are different ways to model color Color Spaces: Linear (RGB, CMYK) Artistic View (Munsell, HSV, HLS, HSI) Standard (CIE-XYZ) Perceptual (Luv, Lab, L*a*b*) Opponent (YIQ, YUV) We will consider two very popular models used in color image processing: RGB (Red Green Blue) HSI (Hue Saturation Intensity) 15
RGB In the RGB model each color appears in its primary spectral components of red, green and blue The model is based on a Cartesian coordinate system RGB values are at 3 corners Cyan, magenta and yellow are at three other corners Black is at the origin White is the corner furthest from the origin Different colors are points on or inside the cube represented by RGB vectors RGB 16
RGB Image 111 14 126 36 12 36 36 111 36 12 17 111 200 36 1712 11136 200 14 36 36 12 36 200 111 14 14 361261217 36111 14 36 10 1283612636200 17111 12 11136 111 14 14 12636 17 111 17 36 1736 126 14127236 126 126 72 200 17 36111 12 36 12 14 17 200 1263617 12111 3620012 2007236 12 12 171261117 14 126 36 126 200 111 14 36 72 36 12 17 72 106 155 10 128 126 200 12 111 200 36 12 36 14 36 111 14 126 36 12 36 17 200 36 111 36 14 14 126 36 17 72 111 36 111 36 12 17 111 12 36 17 36 126 111 17 36 111 14 200 36 17 111 200 36 12 36 14 17 200 126 36 72 12 126 126 17 17 111 14 36 12 36 14 36 126 200 200 36 111 12 14 36 36 12 72 126 17 111 14 126 17 111 36 72 12 12 17 17 72 111 106 14 155 36 12 126 200 36 12 36 RGB Images represented in the RGB color model consist of three component images one for each primary color When fed into a monitor these images are combined to create a composite color image The number of bits used to represent each pixel is referred to as the color depth A 24-bit image is often referred to as a full-color image as 3 8 it allows 2 = 16,777,216 colors ( ) 17
RGB Monitors RGB to XYZ RGB to XYZ is a linear transformation X Y Z = 0.490 0.310 0.200 0.177 0.813 0.011 0.000 0.010 0.990 R G B 18
RGB to XYZ X Y Z X = x X+Y+Z Y = y X+Y+Z Z = z X+Y+Z x+y+z = 1 CIE Chromacity Diagram & RGB The entire color range cannot be displayed based on any three colors The triangle shows the typical color gamut produced by RGB monitors The strange shape is the gamut achieved by high quality color printers 19
Beyond the RGB color space RGB is useful for hardware implementations and is related to the way in which the human visual system works However, RGB is not a particularly intuitive way in which to describe colors Rather when people describe colors they tend to use Hue Saturation Brightness Cylindrical Coordinate Representations Cylindrical-coordinate representation of points in an RGB color model Created as an attempt to be more perceptually relevant than the (X,Y,Z) model. Common representations HSL (aka HLS): hue, saturation, and lightness HSV (aka HSB): hue, saturation, and value (or brightness) HSI: hue, saturation, intensity 20
The HSI Color Model The HSI model uses three measures to describe colors: Hue: A color attribute that describes a pure color (pure yellow, orange or red) Saturation: Gives a measure of how much a pure color is diluted with white light Intensity: Brightness is nearly impossible to measure because it is so subjective. Instead we use intensity. Intensity is the same achromatic notion that we have seen in grey level images HSI, Intensity & RGB Intensity can be extracted from RGB images Remember the diagonal on the RGB color cube that we saw previously ran from black to white Now consider if we stand this cube on the black vertex and position the white vertex directly above it 21
HSI, Intensity & RGB Now the intensity component of any color can be determined by passing a plane perpendicular to the intensity axis and containing the color point The intersection of the plane with the intensity axis gives us the intensity component of the color HSI, Hue & RGB In a similar way we can extract the hue from the RGB color cube Consider a plane defined by the three points cyan, black and white All points contained in this plane must have the same hue (cyan) as black and white cannot contribute hue information to a color 22
The HSI Color Model Consider if we look straight down at the RGB cube as it was arranged previously We would see a hexagonal shape with each primary color separated by 120 and secondary colors at 60 from the primaries The HSI Color Model Hexagonal shape and an arbitrary color point The hue is determined by an angle from a reference point, usually red The saturation is the distance from the origin to the point The intensity is determined by how far up the vertical intensity axis this hexagonal plane sits 23
The HSI Color Model Because the only important things are the angle and the length of the saturation vector this plane is also often represented as a circle or a triangle HSI Model Examples 24
HSI Model Examples HSV vs HSL 25
HSV Saturation Value Hue Converting From RGB To HSI Given a color as R, G, and B its H, S, and I values are calculated as follows: H = θ if B G 360 θ if B > G S =1 3 R + G + B ( ) I = 1 R + G + B 3 ( ) [ min( R,G,B) ] 1 θ = cos 1 2 R G R G [( ) + ( R B) ] [( ) 2 + ( R B) ( G B) ] 1 2 26
Converting From HSI To RGB Given a color as H, S, and I it s R, G, and B values are calculated as follows: RG sector (0 <= H < 120 ) ScosH R = I 1+ cos 60 H ( ) G = 3I ( R + B) B = I( 1 S) GB sector (120 <= H < 240 ) ( ) G = I 1+ R = I 1 S ( ) ( ) S cos H 120 cos H 60 B = 3I ( R + G) Converting From HSI To RGB (cont ) BR sector (240 <= H <= 360 ) R = 3I ( G + B) G = I( 1 S) ( ) Scos H 240 B = I 1+ cos( H 180) 27
HSV Saturation Value Hue Manipulating Images In The HSI Model In order to manipulate an image under the HIS model we: First convert it from RGB to HIS Perform our manipulations under HSI Finally convert the image back from HSI to RGB RGB Image HSI Image RGB Image Manipulations 28
Example RGB Image Hue Saturation Intensity Hue Saturation Intensity 29
Example CIELAB In 1976 CIE established CIELAB with coordinates L*, a*, b* The intention of CIELAB was to create a space which can be computed via simple formulas from the XYZ space, but is more perceptually uniform than XYZ L*a*b* L closely matches human perception of lightness A* & B* represent color opponent channels 30
L*: CIELAB L* = 0 yields black L* = 100 indicates diffuse white a*: position between red/magenta and green -a* indicates green +a* indicates magenta b*: position between yellow and blue -b* indicates blue +b* indicates yellow Benefits of CIELAB CIELAB is a highly accurate mathematical model that emulates normal human color vision based on standard viewing conditions, light sources and a defined "standard observer" set by the CIE. Includes all of the colors visible to the human eye. Device independent. 31
Pseudocolor Image Processing Pseudocolour (also called false color) image processing consists of assigning colors to grey values based on a specific criterion The principle use of pseudocolor image processing is for human visualization Humans can discern between thousands of color shades and intensities, compared to only about two dozen or so shades of grey Example 32
Example 3 CCDs 33
Summary Color Fundamentals Color Models XYZ, RGB, HSI, L*a*b Acknowledgements Some of the images and diagrams have been taken from the Gonzalez et al, Digital Image Processing book. 34