Mobile Robotics and Olfaction Lab, AASS, Örebro University
# 1
Achim J. Lilienthal
Room T1227, Mo, 11-12 o'clock (please drop me an email in advance)
# 3 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
2.
Lectures 1. Week 47: Mon, Nov 17, 2014, 10:15 - 12:00 o'clock, T131 2. Week 47: Tue, Nov 18, 2014, 10:15 - 12:00 o'clock, T127 3. Week 47: Thu, Nov 20, 2014, 10:15 - 12:00 o'clock, T127 4. Week 48: Tue, Nov 25, 2014, 10:15 - 12:00 o'clock, T127 5. Week 48: Thu, Nov 27, 2014, 10:15 - 12:00 o'clock, T127 6. Week 49: Tue, Dec 2, 2014, 10:15 - 12:00 o'clock, T127 7. Week 49: Thu, Dec 4, 2014, 10:15 - 12:00 o'clock, T127 8. Week 50: Tue, Dec 9, 2014, 10:15 - 12:00 o'clock, T127 9. Week 50: Thu, Dec 11, 2014, 10:15 - 12:00 o'clock, T127 10. Week 51: Tue, Dec 16, 2014, 10:15 - 12:00 o'clock, T127
Exercises 1. Week 47: Wed, Nov 19, 2014, 08:15 - 12:00 o'clock, T124 2. Week 48: Wed, Nov 26, 2014, 08:15 - 12:00 o'clock, T124 3. Week 50: Wed, Dec 10, 2014, 08:15 - 12:00 o'clock, T124
General Introduction – Schedule
# 4 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
Contents
1. Colour Fundamentals
2. Colour Models
3. Pseudo Color Processing
4. Colour Transformations
5. Smoothing and Sharpening of Colour Images
6. Colour Edge Detection
# 12 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
Colour Fundamentals
1
# 13 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
1.
Why Colour? o colour is a powerful descriptor o humans can distinguish colours better than grey levels
Electromagnetic Spectrum
Colour Fundamentals
# 19 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
1.
The "Human Camera" o colours are seen as a combination of primary colours
Colour Fundamentals
s( )λ r( )λ
detector rods and cones
)(λb
)(λrred-sensitive green-sensitive blue-sensitive
)(λgr(λ), g(λ), b(λ): how cones respond to light of different wave lengths
# 20 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
1.
The "Human Camera"
Colour Fundamentals
445 nm 535 nm 575 nm
# 21 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
1.
Colour Characteristics o brightness
» perceived intensity (subjective) o hue
» associated with the dominant wavelength o saturation
» relative purity of a colour (inversely proportional to the amount of white light mixed in)
o chromaticity » hue and saturation taken together
Colour Fundamentals
# 22 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
Colour Models
2
# 23 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
2.
CIE Colour Space, 1931 o CIE = Commission Internationale de l´Eclairage o based on direct measurements of the human eye o associate each colour with a tristimulus x,y,z
x,y,z: amount of primary colors ↔ wave length → 3D space → separate brightness and chromaticity
o specifies the colour perceived by a standard observer (depends also on the light source)
Colour Models
# 24 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
2.
CIE Chromaticity (xy) Diagram o projection of the XYZ space
x+y+z=1 o shows all the chromaticities
visible to the average person (gamut of human vision)
o monochromatic colours (fully saturated) along the edge (spectral locus)
o less saturated in the "middle" o CIE standard white: X=Y=Z
(point of equal energy)
Colour Models
# 25 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
2.
CIE Chromaticity (xy) Diagram o each connection between two points defines colours
obtained by additive mixture of these colours o impossible to produce all colours
by mixing three fixed colours: triangle cannot enclose the entire colour region
o colour gamut of RGB monitors is defined by a triangle
Colour Models
Gamut of the CIE RGB primaries and location on the CIE 1931 xy chromaticity diagram
# 26 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
2.
Primary Colours o primary colours of light (emitting sources)
» Red, Green, Blue » color monitors » additive mixing
Colour Models
green
blue red
yellow cyan
magenta
# 27 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
2.
RGB Images
Colour Models
fR = imread('Chalk_Original_R.tif'); figure; imshow(fR); fG = imread('Chalk_Original_G.tif'); figure; imshow(fG); fB = imread('Chalk_Original_B.tif'); figure; imshow(fB);
# 28 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
2.
RGB Images
Colour Models
fR = imread('Chalk_Original_R.tif'); figure; imshow(fR); fG = imread('Chalk_Original_G.tif'); figure; imshow(fG); fB = imread('Chalk_Original_B.tif'); figure; imshow(fB); fColRGB = cat(3, fColR, fColG, fColB);
# 29 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
2.
RGB Images
Colour Models
fR = imread('Chalk_Original_R.tif'); figure; imshow(fR); fG = imread('Chalk_Original_G.tif'); figure; imshow(fG); fB = imread('Chalk_Original_B.tif'); figure; imshow(fB); fColRGB = cat(3, fColR, fColG, fColB); figure; imshow(fColRGB);
# 30 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
2.
Secondary Colours o primary colours of pigments (reflecting sources)
» CMY: Cyan, Yellow, Magenta
» printers: CMYK (+ blacK)
» subtractive mixing
Colour Models
green
blue
red
yellow
cyan magenta
# 31 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
2.
RGB Cube o hardware oriented (screens) o range [0,1] for each primary colour of light o RGB image = three grey-level images o 24 Bits: 16.7 million colours
(~350000 we can distinguish) o RGB in three corners o black, white and CMY in
the other corners o grey along the diagonal
Colour Models
# 33 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
2.
CMY/CMYK o hardware oriented (colour printing) o pigment primary colours = secondary colors of light
o example: surface with cyan
pigment illuminated by white light → no red light is reflected
o K (black) added for printing
Colour Models
−
=
BGR
YMC
111
# 34 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
2.
HSI o Hue, Saturation, Intensity o suitable for description and interpretation o separates intensity and hue o resembles human vision o difficult to display
directly (transformation to RGB necessary)
! singularities (hue is undefined if the saturation is zero)
Colour Models
# 36 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
2.
RGB to HSI
Colour Models
>−≤
=GBGB
H if360 if
θθ ( ) ( )[ ]
( ) ( )( )
−−+−
−+−= −
BGBRGR
BRGR
2
1 21
cosθ
( ) ( )[ ]BGRBGR
S ,,min31++
−=
( )BGRI ++=31
# 37 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
2.
HSI to RGB o RG sector
o GB sector
o BR sector
Colour Models
( )SIB −= 1
−
+=)60cos(
cos1H
HSIR ( )BRIG +−= 3
1200 <≤ H
240120 <≤ H
)1( SIR −=
−−
+=)180cos()120cos(1
HHSIG
( )GRIB +−= 3
360240 <≤ H
( )BGIR +−= 3 ( )SIG −= 1
−
−+=
)300cos()240cos(1
HHSIB
# 38 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
Pseudocolor Image Processing
3
# 39 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
3.
Why Pseudo Colours? o humans can distinguish colours better than grey levels
» ~ 30 grey levels versus ~ 105 – 106 different colours » display grey level as colour image → easier inspection
Pseudocolor Image Processing
the amount of information is not changed!
# 40 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
3.
Two Colour Intensity Slicing o image is interpreted as 3D function (x,y,intensity) o assign different colours to each side of the plane o two-color image
Pseudocolor Image Processing
color1
color2
# 42 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
3.
Pseudo Coloring
Pseudocolor Image Processing
fB = imread('Chalk_Original_B.tif'); figure; imshow(fB);
# 43 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
3.
Pseudo Coloring
Pseudocolor Image Processing
fB = imread('Chalk_Original_B.tif'); figure; imshow(fB); slfColB = grayslice(fColB, 256); pcfColB = ind2rgb(slfColB, jet(256));
# 44 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
3.
Pseudo Coloring
Pseudocolor Image Processing
fB = imread('Chalk_Original_B.tif'); figure; imshow(fB); slfColB = grayslice(fColB, 256); pcfColB = ind2rgb(slfColB, jet(256)); figure; imshow(pcfColB);
# 45 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
3.
Pseudo Coloring
Pseudocolor Image Processing
fB = imread('Chalk_Original_B.tif'); figure; imshow(fB); slfColB = grayslice(fColB, 32); pcfColB = ind2rgb(slfColB, flag(32)); figure; imshow(pcfColB);
# 46 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
3.
More General Intensity Slicing o 3 independent transformations
» R = fR(x,y), G = fG(x,y), B = fB(x,y) » fR, fG and fB not necessarily piecewise linear
o example: X-ray scanning systems at airports » sinusoidal transform functions
Pseudocolor Image Processing
# 48 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
Colour Transformations
4
# 49 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
4.
Representation o each pixel interpreted as a vector (r1, ..., rn)
Formulation o per-colour-component transformation
» si = Ti (ri) » per-colour-component process = vector-based process
• if process is applicable to vectors and scalars ... • ... and operation is independent of the other components
o general vector-based processing » si = Ti (r1, ..., rn)
Colour Transformations
in
out
in
out
in
out
# 50 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
4.
Representation o each pixel interpreted as a vector (r1, ..., rn)
Colour Transformations
# 53 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
4.
Colour Complement o hues opposite to each other (colour negatives) o enhancing details in dark regions o RGB: si = Ti (ri) o HSI: si ≠ Ti (ri)
Colour Transformations
# 54 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
4.
Colour Slicing o to highlight a specific range of colours o to define a mask for further processing o how to define the range of interest ?
» hypercube/sphere/ellipsoid (centred at a mean colour) » multiple colour prototypes (ranges of interest)
Colour Transformations
# 56 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
4.
Tonal Transformations o adjust the brightness and contrast in the image o colours are not changed o tonal transformations normally are selected interactively o colour histogram equalization ?
Colour Corrections o corrections normally are selected interactively o visual assessment of suitable regions
» white areas (RGB/CMY components should be equal) » skin tones (humans are highly perceptive of skin tones)
Colour Transformations
# 57 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
4.
Colour Transformations
image enhancement by histogram equalization
HE for each colour component: hue is not preserved...
# 59 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
4.
Histogram Equalisation (HE) o how to generalise grey level HE to colour HE?
» use HE for intensity in HSI
Colour Transformations
original
# 60 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
4.
Histogram Equalisation (HE) o how to generalise grey level HE to colour HE?
» use HE for intensity in HSI
Colour Transformations
histogram equalised I
# 62 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
Smoothing and Sharpening of Colour Images
5
# 64 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
5.
Smoothing (RGB) o mean filtering in RGB
(neighbourhood: Sxy) o neighbourhood averaging can
be done on a per-colour base
Smoothing and Sharpening of Colour Images
RGB: mean 5x5 for R,G,B
( )
( )( )
( )( )
( )( )
=
∑
∑
∑
∈
∈
∈
xy
xy
xy
Syx
Syx
Syx
yxBK
yxGK
yxRK
yx
,
,
,
,1
,1
,1
,c
# 65 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
5.
Smoothing (HSI) o filter intensity channel only o not identical to RGB smoothing since
the average of two colours is a mixture of them (neither of the original colours)
Smoothing and Sharpening of Colour Images
HSI: mean 5x5 for I
difference
# 66 DIP'14 © A. J. Lilienthal (Dec 11, 2014)
5.
Sharpening (HSI) o Laplacian applied to I only
Smoothing and Sharpening of Colour Images
RGB: Laplacian 5x5 for R,G,B
( )[ ]( )( )( )
∇∇∇
=∇yxByxGyxR
yx,,,
,2
2
2
2 c
Mobile Robotics and Olfaction Lab, AASS, Örebro University
# 86
Achim J. Lilienthal
Room T1227, Mo, 11-12 o'clock (please drop me an email in advance)