8--5 Preview COLOR IMAGE PROCESSING Digital Image Processing Chapter 8 Preview Light Light is fundamental for color vision Unless there is a source of light, there is nothing to see! What do we see? We do not see objects, but the light that has been reflected by or transmitted through the objects Light and EM waves Light is an electromagnetic wave If its wavelength is comprised between 4 and 7 nm (visible spectrum), the wave can be detected by the human eye and is called monochromatic light Physical properties of light This distribution may indicate: ) a dominant wavelength (or frequenc which is the color of the light (hue), ) brightness (luminance), intensity of the light (value), 3) purity (saturation), which describes the degree of vividness.
8--5 Spectrum of White Light Electromagnetic Spectrum Visible light wavelength: from around 4 to 7 nm 666 Sir Isaac Newton, 4 year old, discovered white light spectrum.. For an achromatic (monochrome) light source, there is only attribute to describe the quality: intensity. For a chromatic light source, there are 3 attributes to describe the quality: Radiance = total amount of energy flow from a light source (Watts) Luminance = amount of energy received by an observer (lumens) Brightness = intensity Sensitivity of Cones in the Human Eye The color that human perceive in an object = the light reflected from the object Illumination source scene 6-7 millions cones in a human eye - 65% sensitive to Red light - 33% sensitive to Green light - % sensitive to Blue light Primary colors: Defined CIE in 93 Red = 7 nm Green = 546.nm Blue = 435.8 nm eye reflection CIE = Commission Internationale de l Eclairage (The International Commission on Illumination) Primary and Secondary Colors Primary color Secondary colors Primary and Secondary Colors (cont.) Additive primary colors: RGB use in the case of light sources such as color monitors RGB add together to get white Primary color Primary color Subtractive primary colors: CMY use in the case of pigments in printing devices White subtracted by CMY to get Black
8--5 Light and Color The frequency ( or mix of frequencies ) of the light determines the color. The amount of light(sheer quantity of photons ) is the intensity. Three independent quantities are used to describe any particular color. : hue, saturation, and lightness or brightness or intensity. The hue is determined by the dominant wavelength.(the apparent color of the light) When we call an object "red," we are referring to its hue. Hue is determined by the dominant wavelength. Light and Color The saturation of a color ranges from neutral to brilliant. The circle on the right is a more vivid red than the circle on the left although both have the same hue. Light and Color Lightness or brightness refers to the amount of light the color reflects or transmits. The saturation is determined by the excitation purity, and depends on the amount of white light mixed with the hue. A pure hue is fully saturated, i.e. no white light mixed in. Hue and saturation together determine the chromaticity for a given color. Finally, the intensity is determined by the actual amount of light, with more light corresponding to more intense colors ( the total light across all frequencies). Color Characterization CIE Chromaticity Diagram Hue: Saturation: Brightness: dominant color corresponding to a dominant wavelength of mixture light wave Relative purity or amount of white light mixed with a hue (inversely proportional to amount of white light added) Intensity Trichromatic coefficients: X x X Y Z Y y X Y Z Hue Saturation Chromaticity y Z z X Y Z x y z amount of red (X), green (Y) and blue (Z) to form any particular color is called tristimulus. x Points on the boundary are fully saturated colors 3
8--5 Color Gamut of Color Monitors and Printing Devices Color Gamut of Color Monitors and Printing Devices Color Monitors Printing devices Color Fundamentals (con t) Tri-stimulus values: The amount of Red, Green and Blue needed to form any particular color Denoted by: X, Y and Z Color Models The purpose of a color model (also called color space or color system) is to facilitate the specification of colors in some standard, generally accept way. Tri-chromatic coefficient: X Y x y X Y Z X Y Z x y z Z z X Y Z RGB (red, green, blue) : monitor, video camera. CMY(cyan, magenta, yellow),cmyk (CMY, black) model for color printing. and HSI model, which corresponds closely with the way humans describe and interpret color. RGB (red, green, blue) The RGB colour space is related to human vision through the tristimulus theory of colour vision. The RGB is an additive colour model. The primary colours red, green and blue are combined to reproduce other colours. In the RGB colour space, a colour is represented by a triplet (r,g,b) r gives the intensity of the red component g gives the intensity of the green component b gives the intensity of the blue component Here we assume that r,g,b are real numbers in the interval [,]. You will often see the values of r,g,b as integers in the interval [,55]. 4
8--5 RGB Color model The RGB Color Spaces Purpose of color models: to facilitate the specification of colors in some standard RGB color models: - based on Cartesian coordinate system Source: www.mitsubishi.com Active displays, such as computer monitors and television sets, emit combinations of red, green and blue light. This is an additive color model 5 RGB Color Cube RGB Color Model R = 8 bits G = 8 bits B = 8 bits Color depth 4 bits = 67776 colors Red fixed at 7 Hidden faces of the cube RGB Color Model (cont.) Most modern computer monitors can transmit true color, or 4-bit color. This means each channel (R, G, or B) contains 8 bits per channel that can transmit color. RGB Color Model (cont.) Eight-bit color also exists, 56 colors total. These are called web-safe colors, because they are sure to render accurately on anyone s monitor. Nowadays we don t have to worry about that as much. (Below: 8-bit vs. 4-bit color.) Eight bits means the channel can make eight combinations of on or off of the color, per pixel, 56 colors total. You have three channels. How many colors can be generated? 56 x 56 x 56=6,777,6 possible colors. 5
8--5 Safe RGB Colors Safe RGB colors: a subset of RGB colors. There are 6 colors common in most operating systems. RGB Safe-color Cube The RGB Cube is divided into 6 intervals on each axis to achieve the total 6 3 = 6 common colors. However, for 8 bit color representation, there are the total 56 colors. Therefore, the remaining 4 colors are left to OS. CMY Color model Additive color won t work for printing because we can t begin with black. We must begin with a piece of paper, and that s usually white. White, as we know, is all colors. So we can t add to all colors. We must subtract. Furthermore, an offset printing press can t generate the enormous number of colors available on a computer screen. We need to run a piece of paper through the press for each ink. CMY Color model The press below has four heads, one for each ink in the CMYK system. CMY Color model Printed color, therefore, is based on the subtractive system. While the additive primaries (used to generate all colors ) are RGB, beginning with black the subtractive primaries are Cyan, Magenta, Yellow and Black (CMYK), and begin with white. Cyan=blue-green. Magenta=red-blue. Yellow=red-green. Note the relationship between the additive and subtractive primaries. 6
8--5 CMY Color model You can actually project the additive colors to produce the subtractive. C = Cyan M = Magenta Y = Yellow K = Black CMY Color model C R M G Y B CMY Color model CMY Color model Why? Pigments absorb light Thinking: the Color Filters Question: Yellow + Cyan=? Source: www.hp.com Passive displays, such as color inkjet printers, absorb light instead of emitting it. Combinations of cyan, magenta and yellow inks are used. This is a subtractive color model. 4 CMY The CMY and CMYK Color Spaces CMY cartridges for colour printers. 7
8--5 8 The CMY and CMYK Color Models B G R Y M C Cyan, Magenta and Yellow are the secondary colors of light Most devices that deposit colored pigments on paper, such as color printers and copiers, require CMY data input. The conversion from RGB to CMY is given by the formula Example.: The red colour is written in RGB as (,,). In CMY it is written as that is, magenta and yellow. b g r y m c b g r y m c Example.3: The magenta is written in CMY as (,,). In RGB it is written as giving, that is, red and blue. b g r b g r The image on the left was printed with only CMY inks Black inks add contrast and depth to image on the image on the right CMYK Color model Subtractive primaries are based on ink colors of CMYK. Black is abbreviated K by tradition, perhaps because it is the key color. In color printing, you need black to make the other colors vibrant and snappy. This is why the subtractive process is also called the four-color process, producing color separations, or seps. Colors used are called the process colors. CMYK Color model CMYK Color model For printing and graphics art industry, CMY is not enough; a fourth primary, K which stands for black, is added. Conversions between RGB and CMYK are possible, although they require some extra processing.
8--5 Relationship Between RGB and HSI Color Models Relationship Between RGB and HSI Color Models HSI color model HSI Color Model Will you describe a color using its R, G, B components? Human describe a color by its hue, saturation, and brightness Hue : color attribute Saturation : purity of color (white->, primary color->) Brightness : achromatic notion of intensity RGB, CMY models are not good for human interpreting HSI Color model: Hue: Dominant color Saturation: Relative purity (inversely proportional to amount of white light added) Color carrying information Intensity: Brightness HSI Color Model Relationship Between RGB and HSI Color Models H dominant wavelength S purity % white I Intensity RGB HSI Source: http://www.cs.cornell.edu/courses/cs63/999sp/ 53 9
8--5 Hue and Saturation on Color Planes Hue is defined as an angle HSI Color Model degrees is RED degrees is GREEN 4 degrees is BLUE Saturation is defined as the percentage of distance from the center of the HSI triangle to the pyramid surface. Values range from to.. A dot is the plane is an arbitrary color. Hue is an angle from a red axis. 3. Saturation is a distance to the point. Intensity is denoted as the distance up the axis from black. Values range from to 56 HSI Color Model (cont.) HSI Color Model Intensity is given by a position on the vertical axis. Intensity is given by a position on the vertical axis. Example: HSI Components of RGB Cube RGB Cube Converting Colors from RGB to HSI if B G H 36 if B G cos 3 S R G B I ( R G B) 3 ( R G) ( R B) ( R G) ( R B)( G B) / Hue Saturation Intensity
Color 8--5 Converting Colors from HSI to RGB RG sector: H GB sector: H 4 S cosh R I cos(6 H ) B I( S) G ( R B) BR sector: 4 H 36 H H 4 S cosh B I cos(6 H ) G I( S) R ( G B) H H R I( S) S cosh G I cos(6 H ) B ( R G) Example: HSI Components of RGB Colors RGB Image Saturation Hue Intensity Example: Manipulating HSI Components RGB Image Hue Hue Saturation Color Image Processing There are types of color image processes. Pseudocolor image process: Assigning colors to gray values based on a specific criterion. Gray scale images to be processed may be a single image or multiple images such as multispectral images. Full color image process: The process to manipulate real color images such as color photographs. Saturation Intensity Intensity RGB Image Pseudocolor Image Processing Pseudo color = false color : In some case there is no color concept for a gray scale image but we can assign false colors to an image. Why we need to assign colors to gray scale image? Answer: Human can distinguish different colors better than different shades of gray. Intensity Slicing or Density Slicing Formula: C if f ( x, T g( x, C if f ( x, T C = Color No. C = Color No. T C C A gray scale image viewed as a 3D surface. T L- Intensity
Color 8--5 Intensity Slicing Example Multi Level Intensity Slicing g ( x, Ck for lk f ( x, l k An X-ray image of a weld with cracks C k = Color No. k l k = Threshold level k C k C k- C 3 After assigning a yellow color to pixels with value 55 and a blue color to all other pixels. C C l l l 3 l k- l k Intensity L- Multi Level Intensity Slicing Example g ( x, Ck for lk f ( x, l k C k = Color No. k l k = Threshold level k Color Coding Example A unique color is assigned to each intensity value. Gray-scale image of average monthly rainfall. Color map An X-ray image of the Picker Thyroid Phantom. After density slicing into 8 colors Color coded image South America region Gray Level to Color Transformation Gray Level to Color Transformation Example Assigning colors to gray levels based on specific mapping functions Red component An X-ray image of a garment bag An X-ray image of a garment bag with a simulated explosive device Gray scale image Green component (Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, nd Edition. Transformations Blue component Color coded images
8--5 Gray Level to Color Transformation Example Pseudocolor Coding An X-ray image of a garment bag An X-ray image of a garment bag with a simulated explosive device Used in the case where there are many monochrome images such as multispectral satellite images. Transformations (Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, nd Edition. Color coded images Color theory Some general guidelines for choosing color: Differences will be emphasized. For example, yellow surrounded by green will tend to appear more yellow; green surrounded by yellow will tend to appear more green. This is the rule of simultaneous contrast. Pseudocolor Coding Example Visible blue =.45-.5 mm Max water penetration Visible green =.5-.6 mm Measuring plant 3 4 Red = Green = Blue = Color composite images 3 Red = Green = Blue = 4 Visible red Near infrared =.63-.69 mm =.76-.9 mm Plant discrimination Biomass and shoreline mapping Washington D.C. area Pseudocolor Coding Example Psuedocolor rendition of Jupiter moon Io Basics of Full-Color Image Processing Methods:. Per-color-component processing: process each component separately.. Vector processing: treat each pixel as a vector to be processed. Example of per-color-component processing: smoothing an image By smoothing each RGB component separately. Yellow areas = older sulfur deposits. Red areas = material ejected from active volcanoes. A close-up 3
8--5 Example: Full-Color Image and Variouis Color Space Components Color image CMYK components RGB components Color Transformation Use to transform colors to colors. Formulation: g( x, T f ( x, f(x, = input color image, g(x, = output color image T = operation on f over a spatial neighborhood of (x, When only data at one pixel is used in the transformation, we can express the transformation as: s T r, r,, r ) i i( n i=,,, n HSI components Where r i = color component of f(x, s i = color component of g(x, For RGB images, n = 3 Example: Color Transformation Color Complements Formula for RGB: s ( x, kr ( x, R s ( x, kr ( x, G s ( x, kr ( x, B R G B Color complement replaces each color with its opposite color in the color circle of the Hue component. This operation is analogous to image negative in a gray scale image. Formula for HSI: s ( x, kr ( x, I I k =.7 Formula for CMY: I H,S Color circle s ( x, kr ( x, ( k) C s ( x, kr ( x, ( k) M s ( x, kr ( x, ( k) Y C Y M These 3 transformations give the same results. Color Complement Transformation Example Color Slicing Transformation We can perform slicing in color space: if the color of each pixel is far from a desired color more than threshold distance, we set that color to some specific color such as gray, otherwise we keep the original color unchanged. or.5 si ri W if rj a j otherwise any jn i=,,, n Set to gray Keep the original color.5 si ri if n j j r a otherwise j R i=,,, n Set to gray Keep the original color 4
8--5 Color Slicing Transformation Example After color slicing Tonal Correction Examples In these examples, only brightness and contrast are adjusted while keeping color unchanged. This can be done by using the same transformation for all RGB components. Original image Contrast enhancement Power law transformations Color Balancing Correction Examples Color imbalance: primary color components in white area are not balance. We can measure these components by using a color spectrometer. Color balancing can be performed by adjusting color components separately as seen in this slide. Histogram Equalization of a Full-Color Image Histogram equalization of a color image can be performed by adjusting color intensity uniformly while leaving color unchanged. The HSI model is suitable for histogram equalization where only Intensity (I) component is equalized. s T ( r ) k k j k n j N k j p ( r ) r j where r and s are intensity components of input and output color image. Histogram Equalization of a Full-Color Image Color Image Smoothing Original image After histogram equalization After increasing saturation component Methods:. Per-color-plane method: for RGB, CMY color models Smooth each color plane using moving averaging and the combine back to RGB K c( x, c( x, K ( x, S xy K K ( x, ( x, ( x, R( x, Sxy G( x, Sxy B( x, Sxy (Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, nd Edition.. Smooth only Intensity component of a HSI image while leaving H and S unmodified. Note: methods are not equivalent. 5
8--5 Color Image Smoothing Example (cont.) Color Image Smoothing Example (cont.) Color image Red Color image HSI Components Hue Saturation Intensity Green Blue Color Image Smoothing Example (cont.) Color Image Smoothing Example (cont.) Difference between smoothed results from methods in the previous slide. Smooth all RGB components Smooth only I component of HSI (faster) Color Image Sharpening We can do in the same manner as color image smoothing:. Per-color-plane method for RGB,CMY images. Sharpening only I component of a HSI image Color Image Sharpening Example (cont.) Difference between sharpened results from methods in the previous slide. Sharpening all RGB components Sharpening only I component of HSI 6
8--5 Color Segmentation Color Segmentation in HSI Color Space Methods:. Segmented in HSI color space: A thresholding function based on color information in H and S Components. We rarely use I component for color image segmentation. Color image Hue. Segmentation in RGB vector space: A thresholding function based on distance in a color vector space. 3 4 Saturation Intensity (Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, nd Edition. Color Segmentation in HSI Color Space (cont.) Binary thresholding of S component with T = % Product of and 5 Color Segmentation in HSI Color Space (cont.) 5 6 Red pixels Color image Segmented results of red pixels (Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, nd Edition. Histogram of 6 7 8 Segmentation of red color pixels (Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, nd Edition. Color Segmentation in RGB Vector Space Example: Segmentation in RGB Vector Space Color image. Each point with (R,G,B) coordinate in the vector space represents one color.. Segmentation is based on distance thresholding in a vector space g( x, D(u,v) = distance function if D( c( x,, c ) T if D( c( x,, c ) T T T c T = color to be segmented. c(x, = RGB vector at pixel (x,. Reference color c T to be segmented average color of pixel inthe box c T Results of segmentation in RGB vector space with Threshold value T =.5 times the SD of R,G,B values In the box 7
8--5 Gradient of a Color Image Since gradient is define only for a scalar image, there is no concept of gradient for a color image. We can t compute gradient of each color component and combine the results to get the gradient of a color image. Red Green Blue We see objects. Edges We see 4 objects. Gradient of a Color Image (cont.) One way to compute the maximum rate of change of a color image which is close to the meaning of gradient is to use the following formula: Gradient computed in RGB color space: F( ) tan g xx g xy ( g g ) ( g g )cos g sin xx yy g xy g xx g yy R G x x B x R R G G B B x y x y x y xx yy g yy xy R G y y B y Gradient of a Color Image Example Original image Obtained using the formula in the previous slide Gradient of a Color Image Example Red Green Blue Sum of gradients of each color component 3 Difference between and 33 Gradients of each color component Noise in Color Images Noise can corrupt each color component independently. AWGN s h =8 AWGN s h =8 Noise in Color Images Hue Saturation Intensity AWGN s h =8 Noise is less noticeable in a color image (Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, nd Edition. 8
8--5 Noise in Color Images Color Image Compression Salt & pepper noise in Green component Hue Original image Saturation Intensity JPEG File After lossy compression with ratio 3: 9