LECTURE 1 Introduction Image processing
LECTURE 1 Introduction Image processing
Image Processing
Prof. Mohamed Berbar
Recommended Texts
1
Lecture 1
Introduction
What is “image processing
and computer vision”?
2
1. Introduction
* Image Processing
• image in → image out
* Image Analysis
• image in → measurements out
Sources of images:
1.Digital cameras
2.Scanners
3. Instruments which produce digital images from X-rays, gamma rays,
and ultrasound waves
4. Satellite sensors from measurements of reflected or emitted visible,
infrared, or microwave radiation.
Computer Vision By Dr Mohamed Berbar 6
3
Output
Image Description
Input
Image Image Pattern
Image Processing Recognition,
Computer Vision
4
The image shown in Figure 1 has been divided into N = 16
rows and M = 16 columns. The value assigned to every pixel is
the average brightness in the pixel rounded to the nearest
integer value. The process of representing the amplitude of the
2D signal at a given coordinate as an integer value with L
different gray levels is usually referred to as amplitude
quantization or simply quantization.
Computer Vision By Dr Mohamed Berbar 9
10
5
• The image shown is a small image of
size 10x10 extracted from around the
eye of the seagull.
The user can zoom or "expand" the region for
better visualization.
The user can also display or "print" the values of
the 10x10 ROI image
142 174 164 218 250 255 250 252 255 255
107 107 102 80 127 174 237 218 252 255
90 34 24 34 34 24 51 88 127 164
80 26 19 53 34 19 24 85 117 137
78 76 34 44 26 26 34 24 71 90
85 85 90 26 26 26 26 34 76 83
88 102 90 53 26 26 34 73 85 78
102 110 105 90 98 105 105 110 107 93
107 115 110 110 110 117 115 110 107 102
105 110 110 117 110 132 115 110 107 105
Computer Vision By Dr Mohamed Berbar 11
11
12
6
Bands: A scene may have several
images associated with it
Examples:
1. Color images Red Green
Blue
13
2. Applications (Examples)
14
7
2.1 Character recognition (OCR)
Example: Printed text
• Characteristics
– regular shape
– regular orientation
– good contrast
15
Input Output
Template
120
Non-Normalised Correlation
100
80
60
40
20
0
1
26
51
76
101
126
151
176
201
226
251
276
301
326
351
376
401
426
16
8
2.1 Character recognition (OCR)
Examples: Hand Printed Text
• Characteristics
– less regularity
• Must examine components of character
17
• Totally irregular
• Careful analysis of strokes
18
9
2.2 Biometry (Using personal
characteristics to identify a person
• Using personal characteristics to
identify a person
– fingerprints
– face
– iris
– DNA
– etc
19
Iris Scan
20
10
Locate the eye in the head image
Analysis
Numerical description
21
3. System Overview
Captured data
Enhancement
Feature Extraction
Feature Recognition
Image Recognition
Labels
22
11
Image Representation
• Image capture
• Image resolution
• Colour representation
• Camera calibration
• Parallels with human visual system
23
Image Capture
• Many sources
– consider requirements of system
• resolution
– type of data
• transducer
24
12
Image Resolution
25
Spatial Resolution
26
13
Amplitude Resolution
27
Shades of Grey
28
14
4. Images in Matlab
29
29
30
Classes in MATLAB
• Data types in MATLAB
– Double (64-bit double-precision floating point)
– Single (32-bit single-precision floating point)
– Int32 (32-bit signed integer)
– Int16 (16-bit signed integer)
– Int8 (8-bit signed integer)
– Uint32 (32-bit unsigned integer)
– Uint16 (16-bit unsigned integer)
– Uint8 (8-bit unsigned integer)
– char (2 bytes per element).
– Logical Values are 0 or 1 (1 byte per element).
30
15
31
Image types
31
32
Image Types – Intensity Image
• MATLAB stores an intensity image as a single matrix,
with each element of the matrix corresponding to one
image pixel.
32
16
33
33
34
34
17
35
Image Types – RGB Images
Intensity Images
36
18
Binary Images
B= logical(A);
37
Indexed Images
38
19
RGB Images
An RGB image, sometimes referred to as a
"truecolor" image, is stored in MATLAB as an m-by-
n-by-3 data array that defines red, green, and blue
color components for each individual pixel. RGB
images do not use a palette. The color of each pixel is
determined by the combination of the red, green, and
blue intensities stored in each color plane at the
pixel's location. Graphics file formats store RGB
images as 24-bit images, where the red, green, and
blue components are 8 bits each. This yields a
potential of 16 million colors. The precision with
which a real-life image can be replicated has led to
the nickname "truecolor image."
© Dept. of Computer Science, Swami Vivekanand Mahavidyalay, Udgir (Mah )
39
20
https://www.mathworks.com/help/images/ref/imshow.html
Dr Mohamed Berbar 41
41
42
42
21
Image Arithmetic Functions
• The following table lists the image arithmetic functions.
For more complete descriptions, see their reference
pages.
Function Description
•
imabsdiff Absolute difference of two images
•
imadd Add two images
•
imcomplement Complement an image
•
imdivide Divide two images
•
imlincomb Compute linear combination of two
images
•
immultiply Multiply two images
•
43
image format
Matrix with image filename
image data as a string
>> image(I) % display image
>> whos I
44
22
Representation of Images
• Images are just an array of numbers
>> I % ctrl+c to halt output!
45
45
Indexed images
• An indexed image is where the pixel values are indices to elements in
a colour map or colour lookup table.
• The colour map will contain entries corresponding to red, green and
blue intensities for each index in the image.
>> jet(20) % Generate a jet colourmap for 20 indices
ans =
0 0 0.6000
0 0 0.8000
0 0 1.0000
RGB Entry for index value 3 3 4 7 3 6 19 8 9 1 2
0 0.2000 1.0000 5 6 14 4 2 5 6 1 4 5
0 0.4000 1.0000 2 8 9 4 2 13 7 8 4 5
0 0.6000 1.0000 5 1 11 5 6 4 1 7 4 4
0 0.8000 1.0000 1 9 5 6 5 5 14 4 6 5
0 1.0000 1.0000 5 9 2 1 11 1 3 6 1 9
0.2000 1.0000 0.8000 7 6 8 18 1 8 1 9 13 3
0.4000 1.0000 0.6000 Values can range 9 2 3 7 2 9 8 16 6 4
0.6000 1.0000 0.4000
0.8000 1.0000 0.2000 from 0.0 to 1.0 7 8 6 7 4 15 8 2 1 3
1.0000 1.0000 0
7 5 10 8 4 10 4 3 6 4
1.0000 0.8000 0
1.0000 0.6000 0
1.0000 0.4000 0 Red, green and blue intensities
1.0000 0.2000 0
1.0000 0 0 of the nearest index in the
0.8000 0 0
0.6000 0 0
colourmap are used to display
the image.
46
23
Displaying indexed images
>> I2=I(:,:,2); % green values of I
>> image(I2)
>> colorbar % display colourmap
Matlab considers I2 as an indexed image as it doesn’t
contain entries for red, green and blue entries
Index
Associated
color
Colour
Lookup
Table
47
12000
10000
8000
Frequency
6000
4000
2000
0
106
121
136
151
166
181
196
211
226
241
256
1
16
31
46
61
76
91
Grey Value
48
24
(a) (b) (c)
The one dimensional histogram: The histogram of image in (a)
may be represented as a table (b) or as a plot ( c)
Computer Vision By Dr Mohamed Berbar 49
49
Histograms
• Frequency of the intensity values of the image
• Quantise frequency into intervals (called bins)
• (Un-normalised) probability density function of
image intensities
50
25
Visualising the intensity surface
>>surf(double(imresize(Lena(:,:,2),[50 50])))
51
51
52
52
26
Other useful functions
Convert polar coordinates to Check if a variable is null Trigonometric functions
cartesian coordinates >>isempty(I) sin, cos, tan
>>pol2cart(rho,theta)
Convert polar coordinates to Find indices and elements in a Fast Fourier Transform
cartesian coordinates matrix
>>cart2pol(x,y) >>[X,Y]=find(I>100) fft2(I
)
Get size of matrix Change the dimensions of a Discrete Cosine Transform
>>size(I) matrix
>>reshape(rand(10,10),[100 1])
dct(I)
Add elements of a Matrix Exponentials and Logarithms
(columnwise addition in matrices) exp
>>sum(I) log
log10
53
Colour Representation
• Newton
– white light composed of seven colours
• red, orange, yellow, green, blue, indigo,
violet
– three primaries could approximate
many colours
• red, green, blue
54
27
Other Colour Models
• YMCK
• IHS
• YCrCb
• etc
55
Color models
• They provide a standard way of specifying a
particular color using a 3D coordinate system.
• Hardware oriented
– RGB: additive system (add colors to black)
used for displays.
– CMY: subtractive system used for printing.
– YIQ: used for TV and is good for compression.
• Image processing oriented
– HSV: good for perceptual space for art,
psychology and recognition.
56
28
Additive and subtractive
colors
57
Subtractive Color
58
29
Additive Color
59
RGB model
• Additive model.
• An image consists of 3 bands, one for each primary color.
• Appropriate for image displays.
60
30
CMY model
C 1 R
M = 1 − G
Y 1 B
61
62
31
YIQ model
63
HSV model
• HSV: Hue, saturation, value are non-linear functions of
RGB.
• Hue relations are naturally expressed in a circle.
( R+G+B )
I=
3
min( R, G, B )
S = 1−
I
1 / 2[( R − G )+( R − B )]
H = cos −1 if BG
( R − G ) 2 +( R − B )(G − B )
1 / 2[( R − G )+( R − B )]
H = 360 − cos −1 if BG
( R − G ) 2 +( R − B )(G − B )
Adapted from Octavia Camps, Penn State
CS 484, Spring 2007 ©2007, Selim Aksoy 64
64
32
HSV model
65
Color models
CMYK
RGB
HSV
66
33
Examples: segmentation
• Can cluster on color values and pixel locations.
• Can use connected components and an approximate color
criteria to find regions.
• Can train an algorithm to look for certain colored regions – for
example, skin color.
67
Examples: segmentation
Skin color in RGB
space:
Purple region shows
skin color samples
from several people.
Blue and yellow
regions show skin in
shadow or behind a
beard.
68
34
Examples: segmentation
69
70
35
Computer Vision By Dr Mohamed Berbar 71
71
36