Chapter 6 Image Processing

Yinghua He z Color Fundamentals z Color Models z Pseudo-color Image Processing z Full-color Image Processing z Color Transformations z Smoothing and Sharpening z Color Segmentation z Noise in Color Images Introduction z Coloris a powerful descriptor z Human can discern thousands of color shades. z “Color" is more pleasing than " and “. z Full Color: color from full-color sensor, i.e., CCD camera z Pseudo color: assign a color to a particular monochromatic intensity.

z Basic quantities : used to describe the quality of a chromatic source z Radiance: total amount of energy (W) z Luminance: a measure of the amount of energy by an observer (lm) z Brightness: a subjective descriptor, impossible to measure Cones: sensors in eye responsible for z The that humans perceive of an object are determined by the nature of the light reflected from the object. z Incident light (electromagnetic wave) →human eye z The light is visible to human eyes if its wavelength is between 380-780 (nm). z Human eyes have the following sensitivity : z Brightness : light intensity (energy) z Color :different spectral composition Colors can be seen as combinations of 3 primary colors: R, G, B z Normalized tristimulus values: X, Y, Z→ Specify color by using chromaticity diagram

y=62% x=25% z=13% Chromaticity diagram is useful for . z Color Fundamentals z Color Models z Pseudo-color Image Processing z Full-color Image Processing z Color Transformations z Smoothing and Sharpening z Color Segmentation z Noise in Color Images z The ( or color system) is to facilitate the specification of colors in some standards. z Color model is a specification of a coordinate system and a subspace within the system where a color is represented. z RGB for color monitor. z CMY(cyan, magenta, ) for . z HIS(, intensity and saturation): decouple the color and gray-scale information. RGB Color Models RGB Color Models

3 (28 ) = 16,777,216 RGB Color Models RGB Color Models z Safe RGB colors (or all-system safe color, safe web color): a subset of colors that are likely to be reproduced faithfully reasonably independently of viewers hardware capability. z 216 colors = 6×6×6 z 6 levels in R, G, and B: in decimal: 0, 51, 102, 153, 204, or 255 z In hex: 00, 33, 66, 99, CC, FF Color Models Color Models CMY Color Models HSI Color Models z Human describes color in terms of hue saturation and brightness. z Hue: describe the pure color, pure yellow, , green or red. z Saturation measures the degree to which a pure color is diluted by white light. z Brightness is a subjective descriptor difficult to be measured. HSI Color Models

All pointes contained in the plane segment define by the intensity and boundary of the cube have the same hue. HSI Color Models

Primary colors are separated by 120 HSI Color Models HSI Color Models z From RGB to HSI HIS to RGB

作业 z 2,3,4章的作业做够一半题目即可。 上机 z 13周周一上午8:30-11:30到学院机房。

z 上机内容: z http://www.opencv.org.cn z 下载部分OpenCV例程程序,上机调试运行 z Color Fundamentals z Color Models z Pseudo-color Image Processing z Full-color Image Processing z Color Transformations z Smoothing and Sharpening z Color Segmentation z Noise in Color Images Pseudo Image Processing Pseudo Image Processing Pseudo Image Processing Pseudo Image Processing Pseudo Image Processing Pseudo Image Processing Pseudo Image Processinggray- level to color transformation z Three independent transformation functions on the gray-level of each . z Piecewise linear function z Smooth non-linear function Pseudo Image Processinggray- level to color transformation gray-level to color transformation gray-level to color transformation z Change the phase and frequency of each sinusoid can emphasize (in color) ranges in the gray scale. z Peak→constant color region. z Valley →rapid changed color region z A small change in the phase between the three transforms produces little change in whose gray level corresponding to the peaks in the sinusoidal. z Pixels with gray level values in the steep section of the sinusoids are assigned much strong color. Pseudo Image Processing

Combine several monochrome images into a single color image. Pseudo Image Processing z Color Fundamentals z Color Models z Pseudo-color Image Processing z Full-color Image Processing z Color Transformations z Smoothing and Sharpening z Color Segmentation z Noise in Color Images Full-Color Image Processing z Two categories: –Process each component individually and then form a composite processed color image from the components. –Work with color pixels directly. In RGB system, each color point can be interpreted as a vector.

c(x, y) = [cR (x, y),cG (x, y),cB (x, y)] Full-Color Image Processing z Color Fundamentals z Color Models z Pseudo-color Image Processing z Full-color Image Processing z Color Transformations z Smoothing and Sharpening z Color Segmentation z Noise in Color Images z Formulation z Color Complements z Color Slicing z Tone and Color Corrections z Histogram Processing Color Transformation- formulation

Color Transformation- formulation z To modify the intensity of the image g(x, y) = kf (x, y), 0 < k < 1

z HIS: s3 = kr3

z RGB: si = kri , i = 1,2,3

z CMY: si = kri + (1− k) i = 1,2,3 Color Transformation-formulation z Formulation z Color Complements z Color Slicing z Tone and Color Corrections z Histogram Processing Color Transformation -Color Complements z The directly opposite one another on the color circle are called complements

z Color complements are useful for enhancing detail that is embedded in dark regions of a color image Color Transformation -Color Complements z Formulation z Color Complements z Color Slicing z Tone and Color Corrections z Histogram Processing Color Transformation -Color Slicing z Highlighting a specific range of colors in an image is useful for separating object from their surrounding. z The simplest way to “slice”a color image is to map the colors outside some range of interest to a nonprominent neutral color (e.g., (R, G, B)=(0.5, 0.5, 0.5)). If the colors of interest are enclosed by a cube (or hypercube for n>3) of width W and centered at a

average color with component ( a 1 , a 2 ,..., a n ) the necessary set of transformation is ⎧0.5 if [r − a > W / 2] 1 ≤ j ≤ n ⎪ j j any si = ⎨ ⎩⎪ri otherwise Color Transformation -Color Slicing z If a sphere is used to specify the colors of interest then n ⎧ 2 2 ⎪0.5 if ∑(r − a) > R0 si = ⎨ j=1 ⎪ ⎩ri otherwise z Forcing all other colors to the mid point of the reference color space. z In RGB color space, the neural color is (0.5, 0.5, 0.5) Color Transformation -Color Slicing z Formulation z Color Complements z Color Slicing z Tone and Color Corrections z Histogram Processing z The amounts of red, green, and blue needed to form any particular color are called the tristimulus valued and are denoted, X, Y, and Z, respectively. z The L*a*b* color components are given by the following equations: ⎛ Y ⎞ L * = 116 ⋅ h ⎜ ⎟ − 16 ⎝ Y W ⎠ ⎡ ⎛ X ⎞ ⎛ Y ⎞ ⎤ a * = 500 ⎢ h ⎜ ⎟ − h ⎜ ⎟ ⎥ ⎣ ⎝ X W ⎠ ⎝ Y W ⎠ ⎦ ⎡ ⎛ Y ⎞ ⎛ Z ⎞ ⎤ b * = 200 ⎢ h ⎜ ⎟ − h ⎜ ⎟ ⎥ ⎣ ⎝ Y W ⎠ ⎝ Z W ⎠ ⎦ z where ⎪⎧3 q q > 0.008856 h(q) = ⎨ ⎩⎪7.787q +16 /116 q ≤ 0.008856 z The tonal range of an image, also called its key type, refers to its general distribution of color intensities. z Most of the information in high-key images are located predominantly at low intensities; z The colors of low-key images are located predominantly at low intensities; z Middle-key images lie in between.

z Formulation z Color Complements z Color Slicing z Tone and Color Corrections z Histogram Processing Color Transformation –Histogram Processing z Equalized the histogram of each component will results in error color. z Spread the color intensity (I) uniformly, leaving the color themselves (hues) unchanged. z Equalizating the intensity histogram affects the relative appearance of colors in an image. z Increasing the image’s saturation component after the intensity histogram equalization. Color Transformation –Histogram Processing z Color Fundamentals z Color Models z Pseudo-color Image Processing z Full-color Image Processing z Color Transformations z Smoothing and Sharpening z Color Segmentation z Noise in Color Images z Color Image Smoothing z Color Image Sharpening Smoothing and Sharpening z Let Sxy denote the set of coordinates defining a neighborhood centered at (x, y)in an RGB color space. ⎢ 1 ⎥ ⎢ R(x, y)⎥ K ∑ ⎢ (x, y)∈Sxy ⎥ ⎢ 1 ⎥ c(x, y) = ⎢ G(x, y)⎥ K ∑ ⎢ (x, y)∈Sxy ⎥ ⎢ 1 ⎥ B(x, y) ⎢ K ∑ ⎥ ⎣ (x, y)∈Sxy ⎦ Smoothing and Sharpening

z Color Image Smoothing z Color Image Sharpening z The Laplacian of vector c is

⎡∇ 2 R(x, y)⎤ 2 ⎢ 2 ⎥ ∇ []c(x, y) = ⎢∇ G(x, y)⎥ ⎢ 2 ⎥ ⎣∇ B(x, y)⎦ z Color Fundamentals z Color Models z Pseudo-color Image Processing z Full-color Image Processing z Color Transformations z Smoothing and Sharpening z Color Segmentation z Noise in Color Images Color Segmentation z Partition an image into regions. z Segmentation in HSI color space. z Saturation is used as a masking image to isolate further regions of interest in the hue image. z The intensity image is used less frequently. z Segmentation in HIS Color Space z Segmentation in RGB Vector Space z Color Edge Detection z Color is conveniently represented in the hue image. z Saturation is used as a masking image in order to isolate further regions of interest in the hue image. z The intensity image is used less frequently for segmentation of color images because it carries no color information. z Segmentation in HIS Color Space z Segmentation in RGB Vector Space z Color Edge Detection Color Segmentation z Segmentation in RGB color space z The measurement of color similarity is the Euclidean distance between two colors z, and a, 1/ 2 D(z,a) = z − a = [(z − a)T (z − a)]

[]2 2 2 1/ 2 = (z R − aR ) + (zG − aG ) + (z B − aB ) z A generalization of distance measure is 1/ 2 D(z,a) = z − a = [(z − a)T C −1 (z − a)] z Where C is the covariance matrix of the samples representative of the color we want to segment. z In Figure 6.43(b) describes the solid elliptical body with the principal axes oriented in the direction of maximum data spread. Color Segmentation z Segmentation in HIS Color Space z Segmentation in RGB Vector Space z Color Edge Detection Color Segmentation

z Find the distance of color ( H j , S j , I j ) and the dominant color (H , S , I )

d int ensity ( j) = I j − I

2 2 d chroma ( j) = (S j ) + (S ) − 2S j cos(θ ( j))

2 2 d cylindiral ( j) = (dint ensity ( j)) + (d chroma ( j))

⎪⎧Ω( j) if Ω( j) ≤ 1800 ⎨ 0 ⎩⎪360 − Ω( j) otherwise

Ω( j) = H − H j Color Edge detection z The gradient operators introduced is effective for scalar image. z Compute the gradient on individual images and then using the results to form a color image will lead to erroneous results. Color Edge detection Color Edge detection z Let r,g,b be a unit vector along the R, G, B axis and define the unit vector as ∂R ∂G ∂B u = r + g + b ∂x ∂x ∂x ∂R ∂G ∂B v = r + g + b ∂y ∂y ∂y

2 2 2 g xx = u ⋅u = ∂R / ∂x + ∂G / ∂x + ∂B / ∂x 2 2 2 g yy = v ⋅ v = ∂R / ∂y + ∂G / ∂y + ∂B / ∂y

g xy = u ⋅ v = (∂R / ∂x)(∂R / ∂y) + (∂G / ∂x)(∂G / ∂y) + (∂B / ∂x)(∂B / ∂y) Color Edge detection z The direction of maximum rate of change of c(x,y) is given by the angle θ 1 ⎡ 2g xy ⎤ θ = tan −1 ⎢ ⎥ 2 ⎣⎢(g xx − g yy )⎦⎥ z The value of the rate of change at (x,y) in the direction is θ 1/ 2 F( ) = {}0.5[(g xx + g yy ) + (g xx − g yy )cos + 2g xy sinθ ] z There are two solved θ or θ + π / 2 in orthogonal directions. z One generate maximum F and the other generate minimum F.

z Color Fundamentals z Color Models z Pseudo-color Image Processing z Full-color Image Processing z Color Transformations z Smoothing and Sharpening z Color Segmentation z Noise in Color Images Noise in Color Image z The noise content of a color image has the same characteristics in each color . z It is possible for color channels to be affected differently by noise. z The fine grain noise (in Figure 6.48) tends to be less visually noticeable in a color image than it is in a monochrome image.