SlideShare a Scribd company logo
CAP 5415 Computer Vision
Fall 2011
Dr. Mubarak Shah
Univ. of Central Florida
www.cs.ucf.edu/~vision/courses/cap5415/fall2012
Office 247-F HEC
Filtering
Lecture-2
General
 Binary
 Gray Scale
 Color
Binary Images
0: Black
1: White p
q
X
Y
Row 1
Row q
1 1 1
0 0 0 0
0
1
Gray Level Image
10 5 9
100
Gray Scale Image
Color Image
Red, Green, Blue Channels
Image Histogram
Image Noise
 Light Variations
 Camera Electronics
 Surface Reflectance
 Lens
Image Noise
 I(x,y) : the true pixel values
 n(x,y) : the noise at pixel (x,y)
     
y
x
n
y
x
I
y
x
I ,
,
,
ˆ 


Gaussian Noise
  2
2
2
, 
n
e
y
x
n


Image Derivatives & Averages
Definitions
 Derivative: Rate of change
– Speed is a rate of change of a distance
– Acceleration is a rate of change of speed
 Average (Mean)
– Dividing the sum of N values by N
Derivative
x
x f
x
f
x
x
x
f
x
f
dx
df







 
 )
(
)
(
)
(
lim 0
on
accelerati
speed
dt
dv
a
dt
ds
v 

Examples
3
4
2
4
2 x
x
dx
dy
x
x
y




x
x
e
x
dx
dy
e
x
y







)
1
(
cos
sin
Discrete Derivative
)
(
)
(
)
(
lim 0 x
f
x
x
x
f
x
f
dx
df
x






 

)
(
1
)
1
(
)
(
x
f
x
f
x
f
dx
df





)
(
)
1
(
)
( x
f
x
f
x
f
dx
df





Discrete Derivative
Finite Difference
)
(
)
1
(
)
1
( x
f
x
f
x
f
dx
df






)
(
)
1
(
)
( x
f
x
f
x
f
dx
df





)
(
)
1
(
)
( x
f
x
f
x
f
dx
df




 Backward difference
Forward difference
Central difference
Example
0
5
20
15
5
10
5
0
)
(
0
0
5
15
0
5
5
0
)
(
20
20
20
25
10
10
15
10
)
(









x
f
x
f
x
f
Derivative Masks
Backward difference
Forward difference
Central difference
[-1 1]
[1 -1]
[-1 0 1]
Derivatives in 2 Dimensions
)
,
( y
x
f
Given function

























y
x
f
f
y
y
x
f
x
y
x
f
y
x
f )
,
(
)
,
(
)
,
(
Gradient vector
2
2
)
,
( y
x f
f
y
x
f 


Gradient magnitude
y
x
f
f
1
tan


Gradient direction
Derivatives of Images














1
0
1
1
0
1
1
0
1
3
1
x
f
Derivative masks














1
1
1
0
0
0
1
1
1
3
1
y
f

















20
20
20
10
10
20
20
20
10
10
20
20
20
10
10
20
20
20
10
10
20
20
20
10
10
I

















0
0
0
0
0
0
0
10
10
0
0
0
10
10
0
0
0
10
10
0
0
0
0
0
0
x
I
Derivatives of Images

















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
y
I

















20
20
20
10
10
20
20
20
10
10
20
20
20
10
10
20
20
20
10
10
20
20
20
10
10
I
Correlation
   
 



k l
l
j
k
i
h
l
k
f
h
f ,
,
Kernel
Image


f
f
h1 h2 h3
h4 h5 h6
h7 h8 h9
h
f1 f2 f3
f4 f5 f6
f7 f8 f9

9
9
8
8
7
7
6
6
5
5
4
4
3
3
2
2
1
1
*
h
f
h
f
h
f
h
f
h
f
h
f
h
f
h
f
h
f
h
f









f
Convolution
   
 


k l
l
j
k
i
h
l
k
f
h
f ,
,
*
Kernel
Image


h
f h7 h8 h9
h4 h5 h6
h1 h2 h3
h9 h8 h7
h6 h5 h4
h3 h2 h1
h1 h2 h3
h4 h5 h6
h7 h8 h9
h
flip
X 
flip
Y 
f1 f2 f3
f4 f5 f6
f7 f8 f9

1
9
2
8
3
7
4
6
5
5
6
4
7
3
8
2
9
1
*
h
f
h
f
h
f
h
f
h
f
h
f
h
f
h
f
h
f
h
f









f
Convolution
x
x
f
h
)
1
,
1
(
)
1
,
1
(
)
1
,
0
(
)
1
,
(
)
1
,
1
(
)
1
,
1
(
)
0
,
1
(
)
,
1
(
)
0
,
0
(
)
,
(
)
0
,
1
(
)
,
1
(
)
1
,
1
(
)
1
,
1
(
)
1
,
0
(
)
1
,
(
)
1
,
1
(
)
1
,
1
(
)
,
(
h
y
x
f
h
y
x
f
h
y
x
f
h
y
x
f
h
y
x
f
h
y
x
f
h
y
x
f
h
y
x
f
h
y
x
f
h
y
x
f





























 





1
1
1
1
)
,
(
)
,
(
i j
j
i
h
i
y
i
x
f
h
f
-1,0 0,1 1,1
-1,0 0,0 1,0
-1,-1 0,-1 1,-1
Coordinates
Averages
 Mean
n
I
n
I
I
I
I
n
i
i
n





 1
2
1 
 Weighted mean
n
I
w
n
I
w
I
w
I
w
I
n
i
i
i
n
n






 1
2
2
1
1 
Gaussian Filter
2
2
2
)
( 
x
e
x
g


 
011
.
13
.
6
.
1
6
.
13
.
011
.
)
( 
x
g
2
2
2
2
(
)
,
( 
y
x
e
y
x
g



1


Properties of Gaussian
 Most common natural model
 Smooth function, it has infinite number of
derivatives
 Fourier Transform of Gaussian is Gaussian.
 Convolution of a Gaussian with itself is a
Gaussian.
 There are cells in eye that perform Gaussian
filtering.
Alper Yilmaz, Mubarak Shah, UCF
Filtering
 Modify pixels based on some function of the
neighborhood
10 30 10
20 11 20
11 9 1
5.7
 
p
f
Linear Filtering
 The output is the linear combination of the
neighborhood pixels
1 3 0
2 10 2
4 1 1
Image
1 0 -1
1 0.1 -1
1 0 -1
Kernel
= 5
Filter Output

Alper Yilmaz, Mubarak Shah, UCF
Filtering Examples
0 0 0
0 1 0
0 0 0
* 
Alper Yilmaz, Mubarak Shah, UCF
Filtering Examples
0 0 0
0 0 1
0 0 0
* 
Alper Yilmaz, Mubarak Shah, UCF
Filtering Examples
1 1 1
1 1 1
1 1 1
9
1
* 
Alper Yilmaz, Mubarak Shah, UCF
Filtering Examples
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
25
1
* 
Alper Yilmaz, Mubarak Shah, UCF
Blurring Examples
original
original
pixel offset
pixel offset
filtered
filtered
0
0
8
8
4
0.3
0.3
2.4
8
4
6
4.8
Filtering Gaussian
* 
Alper Yilmaz, Mubarak Shah, UCF
Gaussian vs. Smoothing
Gaussian Smoothing Smoothing by Averaging
Alper Yilmaz, Mubarak Shah, UCF
Noise Filtering
Gaussian Noise
After Gaussian Smoothing
After Averaging
Alper Yilmaz, Mubarak Shah, UCF
MATLAB Functions
 conv: 1-D Convolution.
– C = conv(A, B) convolves vectors A and B.
 conv2: Two dimensional convolution.
– C = conv2(A, B) performs the 2-D convolution
of matrices A and B.
MATLAB Functions
 filter2: Two-dimensional digital filter.
– Y = filter2(B,X) filters the data in X with the 2-D
FIR filter in the matrix B.
– The result, Y, is computed using 2-D correlation and is
the same size as X.
– filter2 uses CONV2 to do most of the work. 2-
D correlation is related to 2-D convolution by a
180 degree rotation of the filter matrix.
MATLAB Functions
 gradient: Approximate gradient.
– [FX,FY] = gradient(F) returns the numerical
gradient of the matrix F. FX corresponds to dF/dx,
FY corresponds to dF/dy.
 mean: Average or mean value.
– For vectors, mean(X) is the mean value
(average) of the elements in X.
MATLAB Functions
 special: Create predefined 2-D filters
– H = fspecial(TYPE) creates a two-dimensional filter H of the
specified type. Possible values for TYPE are:
– 'average' averaging filter;
– 'gaussian' Gaussian lowpass filter
– 'laplacian' filter approximating the 2-D Laplacian operator
– 'log' Laplacian of Gaussian filter
– 'prewitt' Prewitt horizontal edge-emphasizing filter
– 'sobel' Sobel horizontal edge-emphasizing filter
– Example: H=fspecial('gaussian',7,1) creates a 7x7 Gaussian
filter with variance 1.

More Related Content

PDF
Lec05 filter
PPT
Computer Vision - Image Filters
PPT
Filtering.ppt
PPT
chapter5-2 restoration and depredations.ppt
PDF
Lecture04
PDF
Lecture-3-Filtering-Part-I.pdf
PDF
Gaussian filtering 1up
PPT
Image restoration and enhancement techniques
Lec05 filter
Computer Vision - Image Filters
Filtering.ppt
chapter5-2 restoration and depredations.ppt
Lecture04
Lecture-3-Filtering-Part-I.pdf
Gaussian filtering 1up
Image restoration and enhancement techniques

Similar to Lecture 2-Filtering.pdf (20)

PPT
cos323_s06_lecture13_sigproc bio signal processing
PPTX
03 cie552 image_filtering_spatial
PPTX
gaussian filter seminar ppt
PDF
Translation Invariance (TI) based Novel Approach for better De-noising of Dig...
PDF
Image noise &image_filteringin digital image processing
PPTX
Filtering in digital signal and image processing
PDF
Module 3 Computer Vision Image restoration and segmentation
PPTX
Digital Image restoration
PPT
Image denoising
PPTX
Image Restoration (Digital Image Processing)
PPTX
Computer vision - images and image filtering
PDF
Performance Evaluation of 2D Adaptive Bilateral Filter For Removal of Noise F...
DOCX
1 of 6 LAB 5 IMAGE FILTERING ECE180 Introduction to.docx
PPTX
IMAGE PROCESSING--image restoration.pptx
PPTX
IMAGE PROCESSING--image restoration.pptx
PPTX
DIP -Unit 3 ppt.pptx
PPTX
ESTIMATING NOISE PARAMETER & FILTERING (Digital Image Processing)
PPTX
Unit3 dip
PPTX
2. filtering basics
PPT
Digital Image Processing UNIT-2.ppt
cos323_s06_lecture13_sigproc bio signal processing
03 cie552 image_filtering_spatial
gaussian filter seminar ppt
Translation Invariance (TI) based Novel Approach for better De-noising of Dig...
Image noise &image_filteringin digital image processing
Filtering in digital signal and image processing
Module 3 Computer Vision Image restoration and segmentation
Digital Image restoration
Image denoising
Image Restoration (Digital Image Processing)
Computer vision - images and image filtering
Performance Evaluation of 2D Adaptive Bilateral Filter For Removal of Noise F...
1 of 6 LAB 5 IMAGE FILTERING ECE180 Introduction to.docx
IMAGE PROCESSING--image restoration.pptx
IMAGE PROCESSING--image restoration.pptx
DIP -Unit 3 ppt.pptx
ESTIMATING NOISE PARAMETER & FILTERING (Digital Image Processing)
Unit3 dip
2. filtering basics
Digital Image Processing UNIT-2.ppt
Ad

Recently uploaded (20)

PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPTX
Sustainable Sites - Green Building Construction
PPTX
web development for engineering and engineering
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
UNIT 4 Total Quality Management .pptx
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPT
Mechanical Engineering MATERIALS Selection
PPTX
OOP with Java - Java Introduction (Basics)
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
Construction Project Organization Group 2.pptx
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPT
Project quality management in manufacturing
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Sustainable Sites - Green Building Construction
web development for engineering and engineering
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
UNIT 4 Total Quality Management .pptx
Automation-in-Manufacturing-Chapter-Introduction.pdf
Mechanical Engineering MATERIALS Selection
OOP with Java - Java Introduction (Basics)
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Construction Project Organization Group 2.pptx
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Project quality management in manufacturing
Embodied AI: Ushering in the Next Era of Intelligent Systems
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Ad

Lecture 2-Filtering.pdf