color image processing - national institute of technology ... · full color image processing color...

23

Upload: others

Post on 16-Jun-2020

22 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Color Image Processing - National Institute of Technology ... · Full Color Image Processing Color ransfoTrmations s i = T i (r i) (8) s i and r i denote color components. i = 1 ;

Color Image Processing

Dr. Praveen Sankaran

Department of ECE

NIT Calicut

February 11, 2013

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 February 11, 2013 1 / 23

Page 2: Color Image Processing - National Institute of Technology ... · Full Color Image Processing Color ransfoTrmations s i = T i (r i) (8) s i and r i denote color components. i = 1 ;

Outline

1 Color Models

2 Full Color Image Processing

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 February 11, 2013 2 / 23

Page 3: Color Image Processing - National Institute of Technology ... · Full Color Image Processing Color ransfoTrmations s i = T i (r i) (8) s i and r i denote color components. i = 1 ;

Color Models

The Prism

Perception of color → depends on wavelength re�ected from the

object + luminance wavelength.

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 February 11, 2013 3 / 23

Page 4: Color Image Processing - National Institute of Technology ... · Full Color Image Processing Color ransfoTrmations s i = T i (r i) (8) s i and r i denote color components. i = 1 ;

Color Models

Primary Colors

No single wavelength may be called red, green or blue. Again

approximation!

Secondary colors → magenta (red + blue), cyan (green + blue) and

yellow (red + green).

The above is for the light, the order is reversed for the pigment (which

would absorb a primary and re�ect other two).

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 February 11, 2013 4 / 23

Page 5: Color Image Processing - National Institute of Technology ... · Full Color Image Processing Color ransfoTrmations s i = T i (r i) (8) s i and r i denote color components. i = 1 ;

Color Models

Quality of Chromatic Light

1 Radiance: total amount of energy that �ows from the light source

(Watts).

2 Luminance: amount of energy an observer perceives from a light

source (Lumens).

3 Brightness: Intensity.

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 February 11, 2013 5 / 23

Page 6: Color Image Processing - National Institute of Technology ... · Full Color Image Processing Color ransfoTrmations s i = T i (r i) (8) s i and r i denote color components. i = 1 ;

Color Models

Distinguishing Color

1 Brightness

2 Hue: dominant wavelength in a mixture of light waves.

Dominant wavelength as perceived by an observer.Color as we represent, red or yellow refers to the hue.

3 Saturation: the amount of white light mixed with a hue.

degree of saturation inversely proportional to the amount of white light.

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 February 11, 2013 6 / 23

Page 7: Color Image Processing - National Institute of Technology ... · Full Color Image Processing Color ransfoTrmations s i = T i (r i) (8) s i and r i denote color components. i = 1 ;

Color Models

Chromaticity

Amount of red (X), green (Y) and blue (Z) needed to form any color

→ tristimulus values.

Trichromatic coe�cients

x =X

X +Y +Z(1)

y =Y

X +Y +Z(2)

z =Z

X +Y +Z(3)

x + y + z = 1 (4)

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 February 11, 2013 7 / 23

Page 8: Color Image Processing - National Institute of Technology ... · Full Color Image Processing Color ransfoTrmations s i = T i (r i) (8) s i and r i denote color components. i = 1 ;

Color Models

Chromaticity Diagram

White → point of equal energy, corresponds to equal fractions of the

three primary colors.

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 February 11, 2013 8 / 23

Page 9: Color Image Processing - National Institute of Technology ... · Full Color Image Processing Color ransfoTrmations s i = T i (r i) (8) s i and r i denote color components. i = 1 ;

Color Models

RGB

Based on Cartesian coordinate system.

RGB primary values at 3 corners. Secondary values at other 3 corners.

24 bit cube =(28)3

colors.

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 February 11, 2013 9 / 23

Page 10: Color Image Processing - National Institute of Technology ... · Full Color Image Processing Color ransfoTrmations s i = T i (r i) (8) s i and r i denote color components. i = 1 ;

Color Models

Generating RGB Image

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 February 11, 2013 10 / 23

Page 11: Color Image Processing - National Institute of Technology ... · Full Color Image Processing Color ransfoTrmations s i = T i (r i) (8) s i and r i denote color components. i = 1 ;

Color Models

CMY (Cyan, Magenta, Yellow) and CMYK (Black)

CMY

=

111

−RGB

(5)

Assume all color values in range [0,1].

CMYK has an additional color de�ne - black. Mostly for printing since

mixing C, M, Y gives a muddy black.

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 February 11, 2013 11 / 23

Page 12: Color Image Processing - National Institute of Technology ... · Full Color Image Processing Color ransfoTrmations s i = T i (r i) (8) s i and r i denote color components. i = 1 ;

Color Models

HSI (Hue, Saturation, Brightness)

Intensity: pass a perpendicular plane to the intensity axis joining

[0,0,0] and [1,1,1]. The plane should contain the point under

consideration.

Hue: Form a plane with intensity axis as an edge and cyan point as

one corner. The corner point in this plane can be moved around

keeping the axis constant.

All points contained in the plane has the same hue.

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 February 11, 2013 12 / 23

Page 13: Color Image Processing - National Institute of Technology ... · Full Color Image Processing Color ransfoTrmations s i = T i (r i) (8) s i and r i denote color components. i = 1 ;

Color Models

Color Spaces Example

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 February 11, 2013 13 / 23

Page 14: Color Image Processing - National Institute of Technology ... · Full Color Image Processing Color ransfoTrmations s i = T i (r i) (8) s i and r i denote color components. i = 1 ;

Full Color Image Processing

Classi�cation

Each component image separately.

form a processed output color image from the individual components.use standard gray-scale image processing methods.

Work with color pixels as vectors.

c =

cRcGcB

=

RGB

(6)

c [x,y] =

cR [x ,y ]cG [x ,y ]cB [x ,y ]

=

R [x ,y ]G [x ,y ]B [x ,y ]

(7)

x = 0,1, · · · ,M−1; y = 0,1, · · · ,N−1

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 February 11, 2013 14 / 23

Page 15: Color Image Processing - National Institute of Technology ... · Full Color Image Processing Color ransfoTrmations s i = T i (r i) (8) s i and r i denote color components. i = 1 ;

Full Color Image Processing

Are they same?

Process has to be applicable to both scalars and vectors.

Operation on each component of a vector must be independent of the

other components.

Any given process depending on the above criteria may produce same

result or not for the two types of processing.

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 February 11, 2013 15 / 23

Page 16: Color Image Processing - National Institute of Technology ... · Full Color Image Processing Color ransfoTrmations s i = T i (r i) (8) s i and r i denote color components. i = 1 ;

Full Color Image Processing

Color Transformations

si = Ti (ri ) (8)

si and ri denote color components.

i = 1, · · · ,n. n denotes the number of channels.

RGB → n = 3.

The type of transformation to obtain the same result varies in di�erent

color models.

have to take into account the model you are working in and thenchoose your transformation function.some functions easier and better in some models.

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 February 11, 2013 16 / 23

Page 17: Color Image Processing - National Institute of Technology ... · Full Color Image Processing Color ransfoTrmations s i = T i (r i) (8) s i and r i denote color components. i = 1 ;

Full Color Image Processing

Example - Adjust Intensity

HSI

s3 = kr3 (9)

RGB: Modify all three components

si = kri (10)

CMY

si = kri + (1−k) (11)

0< k < 1

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 February 11, 2013 17 / 23

Page 18: Color Image Processing - National Institute of Technology ... · Full Color Image Processing Color ransfoTrmations s i = T i (r i) (8) s i and r i denote color components. i = 1 ;
Page 19: Color Image Processing - National Institute of Technology ... · Full Color Image Processing Color ransfoTrmations s i = T i (r i) (8) s i and r i denote color components. i = 1 ;

Full Color Image Processing

Histogram Processing

Di�erent color components NOT independent.

Approach

Convert to HSI model.

Leave Hue as such.

Change intensity.

Adjust Saturation.

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 February 11, 2013 19 / 23

Page 20: Color Image Processing - National Institute of Technology ... · Full Color Image Processing Color ransfoTrmations s i = T i (r i) (8) s i and r i denote color components. i = 1 ;
Page 21: Color Image Processing - National Institute of Technology ... · Full Color Image Processing Color ransfoTrmations s i = T i (r i) (8) s i and r i denote color components. i = 1 ;

Full Color Image Processing

Color Image Smoothing

1 Refer equation 6.

2 Recall spatial �ltering in gray scale image.

Averaging

Consider neighborhood Sxy ,

c̄ [x ,y ] =1

K∑

s,t∈Sxyc [s, t] =

1K ∑s,t∈Sxy

R [s, t]

1K ∑s,t∈Sxy

G [s, t]

1K ∑s,t∈Sxy

B [s, t]

(12)

Independently smoothing each plane of the RGB image using

conventional gray scale neighborhood processing.

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 February 11, 2013 21 / 23

Page 22: Color Image Processing - National Institute of Technology ... · Full Color Image Processing Color ransfoTrmations s i = T i (r i) (8) s i and r i denote color components. i = 1 ;

Full Color Image Processing

Color Image Sharpening

Laplacian

∇2 [c [x ,y ]] =

∇2R [x ,y ]∇2G [x ,y ]∇2B [x ,y ]

(13)

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 February 11, 2013 22 / 23

Page 23: Color Image Processing - National Institute of Technology ... · Full Color Image Processing Color ransfoTrmations s i = T i (r i) (8) s i and r i denote color components. i = 1 ;

Assignment 5

OpenCV has a function to convert between BGR to HSV. Image read in is

in the BGR format. Note here the usage order of channels. You can make

use of this function to convert between color models.

1 Perform image smoothing using an averaging 5×5 window. You will

perform spatial averaging in two ways on a color image.

1 Apply �lter on the three separate channels, then display the resultingimage.

2 Apply �lter on the intensity channel (third one) of the HSV model.Diplay the image.

3 Now compute the di�erence between the two images and display thedi�erence image.

2 Perform image sharpening with a 3×3 Laplacian �lter.

1 Apply �lter on the three separate channels, then display the resultingimage.

2 Apply �lter on the intensity channel (third one) of the HSV model.Diplay the image.

3 Now compute the di�erence between the two images and display thedi�erence image.