Lecture 1 Introduction No Ink
Lecture 1 Introduction No Ink
الرحيم
1
Recommended Texts
Unit 1
Introduction
What is “image processing
and computer vision”?
2
What is “Image Processing and
Computer Vision”?
1. Introduction
* Image Processing
• image in → image out
* Image Analysis
• image in → measurements out
3
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 7
Output
Image Description
Input
Image Image Pattern
Image Processing Recognition,
Computer Vision
4
Digital Image Definitions
• A digital image a [m, n] described in a 2D discrete space is derived
from an analog image a (x, y) in a 2D continuous space through a
sampling process that is frequently referred to as digitization.
• A digital image is a two dimensional matrix where its elements are
called pixels (abbreviation of picture elements (
10
5
The process of displaying an image creates a graphical
representation of this matrix where the pixel values are assigned a
particular grey-level (monochromatic image) or a particular color
Pixels with low values are assigned dark grey-levels, and high pixel
values are assigned bright grey-levels .
Below is a graphical representation of the image of a gull
11
12
6
Pixels: A "pixel" (picture element) is a relative unit and has
no absolute size. If you divide a picture into any number of
square samples of any size, you could call these samples as
pixels. It doesn't matter what size, only that they are all the
same size.
13
14
7
2. Applications (Examples)
15
16
8
Input Output
Template
Non-Normalised Correlation
120
100
80
60
40
20
0
1
26
51
76
101
126
151
176
201
226
251
276
301
326
351
376
401
426
Computer Vision By Dr Mohamed Berbar Position 17
17
• Characteristics
– less regularity
• Must examine components of character
18
9
Character recognition (OCR)
Examples: Cursive Text
• Totally irregular
• Careful analysis of strokes
19
– etc
20
10
Iris Scan
21
Analysis
Numerical description
22
11
3. System Overview
Captured data
Enhancement
Feature Extraction
Feature Recognition
Image Recognition
Labels
23
Image Representation
• Image capture
• Image resolution
• Colour representation
• Camera calibration
• Parallels with human visual system
24
12
Image Capture
• Many sources
– consider requirements of system
• resolution
– type of data
• transducer
25
Representation
• Sampled data
– spatial
– amplitude
26
13
Image Resolution
27
Spatial Resolution
28
14
Amplitude Resolution
29
Shades of Grey
30
15
4. Images in Matlab
31
31
32
32
16
33
33
34
34
17
35
35
36
36
18
37
Intensity Images
38
19
Binary Images
B= logical(A);
39
Indexed Images
40
20
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 )
41
21
https://www.mathworks.com/help/images/ref/imshow.html
Dr Mohamed Berbar 43
43
44
44
22
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
•
45
image format
Matrix with image filename
image data as a string
>> image(I) % display image
>> whos I
46
23
Representation of Images
• Images are just an array of numbers
>> I % ctrl+c to halt output!
47
47
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
from 0.0 to 1.0 7 8 6 7 4 15 8 2 1 3
0.8000 1.0000 0.2000
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.
48
24
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
49
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
50
25
(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 51
51
Histograms
• Frequency of the intensity values of the image
• Quantise frequency into intervals (called bins)
• (Un-normalised) probability density function of
image intensities
52
26
Visualising the intensity surface
>>surf(double(imresize(Lena(:,:,2),[50 50])))
53
53
54
54
27
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
55
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
56
28
Other Colour Models
• YMCK
• IHS
• YCrCb
• etc
57
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.
58
29
Additive and subtractive
colors
59
Subtractive Color
60
30
Additive Color
61
RGB model
• Additive model.
• An image consists of 3 bands, one for each primary color.
• Appropriate for image displays.
62
31
CMY model
C 1 R
M = 1 − G
Y 1 B
63
64
32
YIQ model
65
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 66
66
33
HSV model
67
Color models
CMYK
RGB
HSV
68
34
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.
69
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.
70
35
Examples: segmentation
71
72
36
Computer Vision By Dr Mohamed Berbar 73
73
37