Вы находитесь на странице: 1из 43

1

Unacional Bogota
Image and Video Processing
Fundamentals
Professor Ebroul Izquierdo
Multimedia and Vision Research Group
Queen Mary, University of London
Summer Course, Universidad Nacional de Colombia
Bogota, Marzo-June 2012
El ect r oni c Engi neer i ng
Road Map
Digital image representation
Sampling
Quantization
Colour spaces
Colour images
2
El ect r oni c Engi neer i ng
What is a Digital Image?
A discrete function from a 2D domain in a set of real
positive numbers
Digital image:
Having values at discrete samples usually in a regular
rectilinear grid
The function values represent gray levels, color
channels, opacities, transparency or tissue density in an
MR Images
+
9 D I :
El ect r oni c Engi neer i ng
Types of Signals: Dimensions
Temporal signal: function of time
f(t): voice, music, nerve impulses, radar
Spatial signal: function of two (or three) spatial dimensions
f(x, y): images (grayscale, color, multi-spectral)
f(x, y, z): medical scans (CT, MRI, PET)
Spatial-temporal signal: 2/3-D space, 1-D time
f(x, y, t): video/movies
3
El ect r oni c Engi neer i ng
Using a Single Sensor
El ect r oni c Engi neer i ng
Using Sensor Strips
4
El ect r oni c Engi neer i ng
Using Sensor Arrays
El ect r oni c Engi neer i ng
What does this mean?
2D
Domain
Sampling Positions
5
El ect r oni c Engi neer i ng
What does this mean?
Function
Values at
discrete
grid
points
0 200
128 60
128 60
128 60
El ect r oni c Engi neer i ng
Pixels or Pels
2D
Domain
Sampling Positions
A Single
sampling
position
and its
function
value
6
El ect r oni c Engi neer i ng
Digital Images (I)
A digital image is a nD array of pixel values.
For example, in the 2D case the image data contains information
of the graylevel at each position in the image.
Magnifyed pixels at few
sampling positions
El ect r oni c Engi neer i ng
Digital Images (II)
94 100 104 119 125 136 143 153 157 158
103 104 106 98 103 119 141 155 159 160
109 136 136 123 95 78 117 149 155 160
110 130 144 149 129 78 97 151 161 158
109 137 178 167 119 78 101 185 188 161
100 143 167 134 87 85 134 216 209 172
104 123 166 161 155 160 205 229 218 181
125 131 172 179 180 208 238 237 228 200
131 148 172 175 188 228 239 238 228 206
161 169 162 163 193 228 230 237 220 199
Corresponding array
Pixels
7
El ect r oni c Engi neer i ng
Grey Level Images
Standard pixel values for rows, columns and gray levels
The number of gray levels is usually a power of 2:
where B is the number of bits in the binary representation of the
image.
E.g., B = 8 implies L = 256 gray levels numbered from 0,,255.
Parameter Symbol Typical Values
Rows N 256, 512, 525, 625, 1024, 1035
Columns M 256, 512, 768, 1024, 1320
No. Gray Levels L 2, 64, 256, 1024, 4096, 16384
L
B
= 2
El ect r oni c Engi neer i ng
Image Formats (I)
GIF(GIF87a,GIF89a):
Graphics Interchange Format (GIF) devised by the
UNISYS Corp. and Compuserve, initially for transmitting
graphical images over phone lines via modems.
Uses the Lempel-Ziv Welch algorithm (compression).
Supports only 8-bit (256) color images.
Supports interlacing
GIF89a supports simple animation
8
El ect r oni c Engi neer i ng
Image Formats (II)
JPEG:
A standard for photographic image compression created by
the Joint Photographics Experts Group
Takes advantage of limitations in the human vision system
to achieve high rates of compression
Lossy compression which allows user to set the desired
level of quality/compression
More on JPEG later
El ect r oni c Engi neer i ng
TIFF:
Tagged Image File Format (TIFF), stores many
different types of images (e.g., monochrome, grayscale,
8-bit & 24-bit RGB, etc.)
Developed by the Aldus Corp. in the 1980's and later
supported by the Microsoft
TIFF is a lossless format (when not utilizing the new
JPEG tag which allows for JPEG compression)
It does not provide any major advantages over JPEG
and is not as user-controllable it appears to be declining
in popularity
Image Formats (III)
9
PGN: Portable Network Graphics was designed to replace the
older and simpler GIF format and the more complex TIFF format.
Advantages over GIF:
Alpha channels (variable transparency)
Gamma correction (cross-platform control of image
brightness)
Two-dimensional interlacing (a method of progressive
display)
GIF uses 1-D interlacing.
Better Compression (5-25% better)
Shortcoming: No Animation
Features: Supports three main image types: truecolor, grayscale
and palette-based (``8-bit''). JPEG supports the first two;
GIF only the third.
Image Formats (IV)
El ect r oni c Engi neer i ng
PGM: Portable Grey Map
PPM: Portable PixMap
Are the lowest common denominator grey level and color
image file format
These formats are a convenient (simple) method of saving image
data
They are easy to understand and simple to develop own
applications from scratch
The file consists of two parts:
Simple Header
Pixel data
Recommended Image Formats for the Labs
10
El ect r oni c Engi neer i ng
A PPM header consists of at least three parts normally separated
by carriage returns and/or linefeeds but the PPM specification
only requires white space
The first "line" is a magic PPM identifier, it can be P3 or P6
The next line consists of the width and height of the image as ascii
numbers
The last part of the header gives the maximum value of the colour
components for the pixels, this allows the format to describe more
than single byte (0..255) colour values
In addition to the above required lines, a comment can be placed
anywhere with a "#" character, the comment extends to the end of
the line.
PPM Header
El ect r oni c Engi neer i ng
The following are all valid PPM headers.
Example 1
P6 1024 788 255
Example 2
P6
1024 788
# My own comment on this image
255
Example 3
P3
1024 # the image width
788 # the image height
# Another comment
1023
PPM Header
11
El ect r oni c Engi neer i ng
The format of the image data itself depends on the
magic PPM identifier. If it is "P3" then:
the image is given as ascii text
the numerical value of each pixel ranges from 0 to the
maximum value given in the header
the lines should not be longer than 70 characters.
PPM Header
El ect r oni c Engi neer i ng
P3
# example from the man page
4 4
15
0 0 0 0 0 0 0 0 0 15 0 15
6 0 0 0 15 7 0 7 0 0 0 0
0 0 0 0 0 0 0 15 7 3 0 0
15 0 15 0 0 0 0 0 0 0 6 0
P3 PPM Header Example
12
El ect r oni c Engi neer i ng
If the PPM magic identifier is "P6" then the image
data is stored in byte format, one byte per colour
component (r,g,b)
Comments can only occur before the last field of the
header and only one byte may appear after the last
header field, normally a carriage return or line feed
"P6" image files are obviously smaller than "P3" and
much faster to read
Note that "P6" PPM files can only be used for single
byte colours
PPM Header
El ect r oni c Engi neer i ng
While not required by the format specification it is a
standard convention to store the image in top to
bottom, left to right order
Each pixel is stored as a byte
The value 0 represents black,
The value 255 represents white
The components are stored in the "usual" order, R/G/B
(red - green blue)
PPM Format
13
El ect r oni c Engi neer i ng
This format is identical to PPMbut it stores greyscale
information
That is, one value per pixel instead of 3 (r,g,b)
The only difference in the header section is the magic
identifiers which are P2 and P5
P2 corresponds to the ascii form of the data
P5 corresponds to the binary form of the data
PGM Format
El ect r oni c Engi neer i ng
P2
24 7
9
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 3 3 3 3 0 0 7 7 7 7 0 0 1 1 1 1 0 0 5 1 5 5 0
0 3 0 0 0 0 0 7 0 0 0 0 0 1 0 0 0 0 0 5 0 0 1 0
0 3 3 3 0 0 0 7 7 7 0 0 0 1 1 1 0 0 0 1 1 1 1 0
0 3 0 0 0 0 0 7 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0
0 3 0 0 0 0 0 7 7 7 7 0 0 1 1 1 1 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
PGM Example
14
El ect r oni c Engi neer i ng
P2 - PGM grey scale image, stored in ASCII, one
value per pixel
P3 - PPM color image, stored in ASCII, 3 values
rgb per pixel
P5 - PGM grey scal image stored in binary
(compressed) format
P6 - PPM color image stored in binary
(compressed) format
PPM and PGM Magic Numbers
El ect r oni c Engi neer i ng
Road Map
Digital image representation
Sampling
Quantization
Colour spaces
Colour images
15
El ect r oni c Engi neer i ng
How Digital Images Are Generated
Two basic step (Digitization):
Sampling
Quantization
El ect r oni c Engi neer i ng
Image Digitization
Digitizer
(e.g.,
scanner)
Scene
I(i, j)
16
El ect r oni c Engi neer i ng
Sampling
Sampler
Continuous Domain
(i, j) array of
sampling positions
The continuous image domain D is scanned the brightness values
I(i, j) are measured or sampled at discrete locations to form an
array of intensity values
Converting the continuous 2D signal in a digital image
by sampling per scanlines
Definition
17
Example
Example
El ect r oni c Engi neer i ng
Image sampling
18
El ect r oni c Engi neer i ng
Image sampling
512 256
128 64 32
Image Resolution
Full Resolution
1/4 Resolution
19
Image Resolution
1/8 Resolution
Full Resolution
Low Resolution
64 X 64
1/8 Resolution
The Image at 1/8 resolution appears blocky
To accurately represent the original continuous scene, the
sampling rate must be sufficiently high
20
El ect r oni c Engi neer i ng
Methods for Image Sampling
Uniform - same sampling frequency everywhere
Adaptive - higher sampling frequency in areas with
greater detail (Compression strategy)
El ect r oni c Engi neer i ng
Representing a line with discrete pixel values leads to
sampling error and loss of information
Standard midpoint line on a binary representation
Sampling Effects
21
Same line with twice the linear resolution
Sampling Effects
El ect r oni c Engi neer i ng
Doubling resolution does not solve the problem
It costs 4 times memory, bandwidth and scan
conversion time!
The problem can be alleviated using more
grey-levels
Sampling Effects
22
El ect r oni c Engi neer i ng
Happen whenever we try to sample a signal at less than
twice the maximum frequency
Analog sine wave
The sine wave sampled at too low a rate
Aliasing
El ect r oni c Engi neer i ng
The sine wave sampled at too low a rate
Reconstructed wave based on these samples
Aliasing
23
El ect r oni c Engi neer i ng
Sine wave sampled at the Nyquist limit. This time it
works fine
The sample points shifted. Now we get no signal!
Nyquist Limit
El ect r oni c Engi neer i ng
Road Map
Digital image representation
Sampling
Quantization
Colour spaces
Colour images
24
El ect r oni c Engi neer i ng
Quantization
Each element in the matrix is quantized, i.e, replaced by an
integer
Quantized values are called gray levels
I(i, j)
Quantizer
Digital Image Visualization
Usually each pixel in the image is shown by a single
pixel on the screen.
E.g., for L = 256 gray levels, 0 maps into black,
255 into white and values in between map
linearly into various levels of gray.
0
0
0
0
0
0
0
0
0
0 0 0
127
127 255
255
Image Screen
25
El ect r oni c Engi neer i ng
Intensity Resolution
Refers to how accurately a pixels gray level represents the
brightness of the corresponding point in the original scene
During quantization, the brightness sampled at each point in
the continuous-tone image is replaced by an integer value
Scene brightness
G
r
a
y

l
e
v
e
l

o
f

i
m
a
g
e
0
7
I
max
B = 3 bits
El ect r oni c Engi neer i ng
Intensity Resolution
Intensity resolution depends on the number of bits
available
This figure shows a digital image quantized with 8 bits (256
gray levels). The image appears continuous
26
El ect r oni c Engi neer i ng
Intensity Resolution
The same image quantized with only 4 bits (16 gray
levels). Now the image brightness appears
discontinuous
El ect r oni c Engi neer i ng
Intensity Resolution
With fewer bits, we cannot accurately represent the
gradual intensity variations in the original scene
because a wider range of intensities in the original
scene is mapped into a single gray level.
Generally, the more bits we have, the better the
brightness resolution
27
El ect r oni c Engi neer i ng
256
Grey-level quantization
32 82
El ect r oni c Engi neer i ng
Quantization Methods
Uniform or linear - intensity of object is lineary mapped to gray-
levels of image
Logarithmic - higher intensity resolution in darker areas (the
human eye is logarithmic)
object intensity
i
m
a
g
e

i
n
t
e
n
s
i
t
y
object intensity
i
m
a
g
e

i
n
t
e
n
s
i
t
y
28
El ect r oni c Engi neer i ng
Common Quantization Levels
I(i,j) is given by integer values [0-max], max=2
n
-1
n=1 [0 - 1] binary image
n=5 [0 - 31] maximum the human
eye can resolve (locally)
n=8 [0 - 255] 1 byte, very common
n=16 [0 - 65535] common in research
n=24 [0 - 16.2*10
6
] common in color images
(i.e. 3*8 for RGB)
El ect r oni c Engi neer i ng
Choice of Sampling and
Quantization
What will the image be used for?
What are the limitations in memory and speed?
Will the image only be used for visual
interpretation or for any image
analysis/processing?
What information is relevant for the analysis (i.e.
color, spatial and/or graylevel resolution)?
29
El ect r oni c Engi neer i ng
Road Map
Digital image representation
Sampling
Quantization
Colour spaces
Colour images
El ect r oni c Engi neer i ng
Light as a Waveform
Light can be split into its component wavelengths and
intensity
The wavelength of visible light lies roughly between 400nm
and 700nm
these measurements can be combined into a spectral
power distribution (SPD)
a description of how the intensity of light from some
particular source varies with wavelength
The SPD for some light source corresponds closely to its
colour components:
short wavelength (440nm) = blue
medium (550) = green
long (590) = red
30
El ect r oni c Engi neer i ng
Tristimulus Theory of
Colour Vision
This theory states that human perception of colour derives
from the eyes responses to three different groups of
wavelengths
i.e. those corresponding to red, green and blue (RGB)
El ect r oni c Engi neer i ng
Tristimulus Theory of
Colour Vision
Therefore: any sensation of colour can be produced by
mixing together suitable amounts of these colours
Red, Green & Blue are called the additive primary
colours
Although this is broadly true, the operation of the receptors
in the eye is not quite that simple:
the receptors inter-operate in a more complex way for some
visible colours
therefore it is not possible to represent any visible colour as
a combination or R, G & B
31
El ect r oni c Engi neer i ng
Color in Images and Video
Light and Spectrum: visible light is an electro-
magnetic wave in the 400 nm - 700 nm range.
Most light we see is not one wavelength, it's a
combination of many wavelengths
El ect r oni c Engi neer i ng
The Human Retina Simple Model-
The eye functions on the same principle as a camera
Each neuron is either a rod or a cone.
The rods contain the elements that are sensitive to light intensities. Rods are
not sensitive to color.
Cones come in 3 types: red, green and blue. Each responds differently to
various frequencies of light.
32
El ect r oni c Engi neer i ng
Properties of the Human Visual
System
The eye is more sensitive to changes in brightness than
colour
The eye is unable to perceive brightness levels above or
below certain thresholds
The eye cant distinguish minor changes in brightness or
colour. Certain ranges of brightness or colour are more
important visually than others.
E.g. eye is more sensit ive t o minor changes in shades of
green t han ot her colours
Sensitivity of the eye is not linear.
El ect r oni c Engi neer i ng
Color Composition
A color can be specified as the sum of three colors. So colors
form a 3 dimensional vector space.
The following figure shows the amounts of three primaries
needed to match all the wavelengths of the visible spectrum.
33
El ect r oni c Engi neer i ng
Hue distinguishes among colors such as red, green,
purple, and yellow
Saturation refers to how pure the color is, how much
white/gray is mixed with it
red is highly sat urat ed; pink is relat ively
unsat urat ed
royal blue is highly sat urat ed;
sky blue is relat ively unsat urat ed
past els are less vivid, less int ense
Chromatic Color
Lightness embodies the achromatic notion of perceived intensity
of a reflecting object
Brightness is used instead of lightness to refer to the perceived
intensity of a self-luminous (i.e., emitting rather than reflecting
light) object, such as a light bulb, the sun, or a CRT
Can distinguish ~7 million colors when samples placed side-by-
side (JNDs)
about 128 fully sat urat ed hues are dist inct
eye less discriminat ing for less sat urat ed light (from
16 t o 23 sat urat ion st eps for fixed hue and light ness),
and less sensit ive for less bright light
Chromatic Color
34
El ect r oni c Engi neer i ng
Occurs with inks for print medium, paints that absorb light. In
subtractive mixture, the light passed by two filters (or reflected
by two mixed pigments)
Subtractive Mixture
blue green yellow red
green
El ect r oni c Engi neer i ng
Used to mix R, G, B guns of CRT. The figure shows two
projectors throwing pure blue and yellow filtered light upon the
same portion of the screen. In contrast to what happens in a
subtractive mixture, the result of adding these two colors is gray.
Additive Mixture
35
El ect r oni c Engi neer i ng
These complementary unique hues play a role in
opponent color perception discussed later
Note that only for perfect red and green do you get gray
Complementary Hues
El ect r oni c Engi neer i ng
The gray patches on the blue and yellow backgrounds are
physically identical. But they do not look similar
Color Contrast
36
El ect r oni c Engi neer i ng
Hardware-oriented models: not intuitive
RGB, used with color CRT monitors
YIQ, the broadcast TV color system
CMY (cyan, magenta, yellow) for color printing
CMYK (cyan, magenta, yellow, black) for color
printing
User-oriented models
HSV (hue, saturation, value) also called HSB (hue,
saturation, brightness)
HLS (hue, lightness, saturation)
The Munsell system
CIE Lab
Color Models
El ect r oni c Engi neer i ng
Color Models for Images (I)
RGB Additive Model: A color image is a 2-D
array of (R,G,B) integer triplets. These triplets
encode how much the corresponding phosphor
should be excited in devices such as a monitor.
Blue
Cyan
Red Yellow
Green
Magenta
Black(0,0,0)
White(1,1,1)
37
El ect r oni c Engi neer i ng
Main diagonal => gray levels
black is (0, 0, 0)
whit e is (1, 1, 1)
RGB Color Model
El ect r oni c Engi neer i ng
Color Models for Images (II)
Blue Cyan
Red
Yellow
Green
Magenta
Black(1,1,1)
White(0,0,0)
CMY Subtractive Model: Cyan, Magenta, and Yellow
(CMY) are complementary colors of RGB.
CMY model is mostly used in printing devices where the color
pigments on the paper absorb certain colors (e.g., no red light
reflected from cyan ink)
38
El ect r oni c Engi neer i ng
Used in electrostatic and in ink-jet plotters that deposit pigment on
paper
Cyan, magenta, and yellow are complements of red, green , and
blue
Subtractive primaries: colors are specified by what is removed or
subtracted from white light, rather than by what is added to
blackness
Cartesian coordinate system
Subset is unit cube
whit e is at origin, black at (1, 1, 1):
The CMY(K) Color Model
(
(
(

(
(
(

=
(
(
(

B
G
R
Y
M
C
1
1
1
El ect r oni c Engi neer i ng
In the CMY model colours are specified by what is removed
(absorbed) from white light, rather than by what is added to
blackness.
C + M + Y at full intensity = Black
Subtractive scheme: E.g.Cyan objects absorb red, so cyan is white
minus red (or blue + green)
C = G + B = W - R
M = R + B = W - G
Y = R = G = W - B
To obtain a good black for printing, another primary is
added: K (CMYK)
The CMY(K) Color Model
39
El ect r oni c Engi neer i ng
Color Models (IV)
YUV Model: Human perception is more sensitive to brightness
than chrominance. Therefore, instead of separating colors, one can
separate the brightness info. from the color info.
Y is luminance
Y = 0.299R + 0.587G + 0.114B
Chrominance is defined as the difference between a color and a
reference white at the same luminance. It can be represented by U
and V -- the color differences.
U = B - Y
V = R - Y
Eye is most sensitive to Y. Therefore, any error in the resolution of the
luminance (Y) is more important than the chrominance (U,V) values.
In PAL, 5 (or 5.5) MHz is allocated to Y, 1.3 MHz to U and V.
HSV models colour in terms of:
HUE:
the dominant wavelength, i.e. where most of the energy of the
light is concentrated.
hues usually identified by names: mixtures of red, yellow,
green and blue.
SATURATION
a measure of the colours purity or intensity:
the presence of other hues makes the colour paler
BRIGHTNESS
a measure of how light or dark the colour is.
HSV corresponds more closely to the way humans think about
colour than RGB.
Color Models (VI)
40
El ect r oni c Engi neer i ng
Hue, saturation, value (brightness)
Hexcone subset of cylindrical (polar) coordinate system
The V = 1 plane contains the RGB models R = 1, G = 1, B = 1, in
the regions shown
The HSV Color Model
El ect r oni c Engi neer i ng
Hue, lightness, saturation. Double-hexcone subset
Maximally saturated hues are at S = 1, L = 0.5
The HLS color Model
41
El ect r oni c Engi neer i ng
Munsell color-order system
set of samples in 3D space
hue, value/ light ness, chroma (sat urat ion)
equal perceived dist ances bet ween neighbors
Defining Color
El ect r oni c Engi neer i ng
Munsell color definition
Black
Grays
White
Tints Pure
color
Tones
Shades
Decrease saturation
Decrease
lightness
42
El ect r oni c Engi neer i ng
Road Map
Digital image representation
Sampling
Quantization
Colour spaces
Colour images
El ect r oni c Engi neer i ng
Channels in Colour Images
Blue Channel of Image
1 sample per pixel
Green Channel of Image
1 sample per pixel
Red Channel of Image
1 sample per pixel
3 samples per pixel
43
El ect r oni c Engi neer i ng
Colour Vs. Grey
El ect r oni c Engi neer i ng
Colour Vs. B&W

Вам также может понравиться