Document 15072448

advertisement
Mata kuliah : T0283 - Computer Vision
Tahun
: 2010
Lecture 03
Area Based Image Processing
Learning Objectives
After carefully listening this lecture, students will be able
to do the following :
understand spatial information based image operation
such as area-based processing
demonstrate how area-based image processing is
performed (i.e. convolution-based image processing)
January 20, 2010
T0283 - Computer Vision
3
What is a Mask ?
A mask is a small matrix whose values are called weights
Each mask has an origin, which is usually one of its positions
The origin of symmetric masks are usually their center pixel
position
For non-symmetric masks, any pixel location may be chosen
as the origin (depending on the intended use)
1
1
1
1
2
1
1
1
1
1
2
4
2
1
1
1
1
1
2
1
1
1
January 20, 2010
T0283 - Computer Vision
4
Applying Masks to Images : Linear Filtering
Linear filtering is filtering in which the value of an output pixel
is a linear combination of the values of the pixels in the input
pixel's neighborhood.
Linear filtering of an image is accomplished through an
operation called convolution.
Convolution is a neighborhood operation in which each output
pixel is the weighted sum of neighboring input pixels. The
matrix of weights is called the convolution kernel, also known
as the filter.
January 20, 2010
T0283 - Computer Vision
5
Applying Masks to Images : Linear Filtering
January 20, 2010
T0283 - Computer Vision
6
Computing the (2,4) Output of Convolution
Rotate the convolution kernel 180 degrees about its center
element.
Slide the center element of the convolution kernel so that it
lies on top of the (2,4) element of A.
Multiply each weight in the rotated convolution kernel by the
pixel of A underneath.
Sum the individual products from step 3.
Hence the (2,4) output pixel is
1*2 + 8*9 + 15*4 + 7*7 + 14*5 + 16*3 + 13*6 +
20*1 + 22*8 = 575
January 20, 2010
T0283 - Computer Vision
7
Computing the (2,4) Output of Convolution
Values of rotated Kernel
Image pixel
values
January 20, 2010
17
24
1
2
8
9
Center of
15 4 Kernel
23
5
7
7
14
5
16
3
4
6
13 6
20
1
22
8
10
12
19
21
3
11
18
25
2
9
T0283 - Computer Vision
8
Computing the (2,4) Output of Correlation
Slide the center element of the correlation kernel so that it
lies on top of the (2,4) element of A.
Multiply each weight in the rotated correlation kernel by the
pixel of A underneath.
Sum the individual products from step 2.
Hence the (2,4) output pixel is
1*8 + 8*1 + 15*6 + 7*3 + 14*5 + 16*7+ 13*4 +
20*9 + 22*2 = 585
January 20, 2010
T0283 - Computer Vision
9
Computing the (2,4) Output of Correlation
Values of Correlation Kernel
Image pixel
values
January 20, 2010
17
24
1
23
5
7
4
6
10
11
8
8
1
15
6
3
14 5
16
7
13 4
20 9
22
2
12
19
21
3
18
25
2
9
T0283 - Computer Vision
Center of
Kernel
10
Dealing with Image Borders
Only convolve with interior
Shrinks image
Zero-padding
Results in spurious gradients
Border replication
January 20, 2010
T0283 - Computer Vision
1
1
1
-1
2
4
2
2
3
-1
2
-2
1
3
3
2
2
1
2
1
3
2
2
11
Filtering Example
How to treat image borders : Zero Padding
1
-1
-1
1
2
-1
1
1
1
Rotate
1
1
1
-1
2
1
-1
-1
1
January 20, 2010
2
2
2
3
2
1
3
3
2
2
1
2
1
3
2
2
T0283 - Computer Vision
12
Step 1
1
1
1
2
2
2
3
-1
2
1
2
1
3
3
-1 -1
1
2
2
1
2
1
3
2
2
January 20, 2010
1
1
1
-1
2
4
2
2
3
2
-1 -2
1
3
3
2
2
1
2
1
3
2
2
T0283 - Computer Vision
5
13
Step 2
1
1
1
2
2
2
3
-1
2
1
2
1
3
3
-1 -1
1
2
2
1
2
1
3
2
2
January 20, 2010
1
1
1
2
-2
2
4
2
3
2 -1
1
-2
3
3
2
2
1
2
1
3
2
2
T0283 - Computer Vision
5
4
14
Step 3
1
1
1
-1
2
1
-1 -1
1
January 20, 2010
1
1
1
2
2
-2
2
4
3
2
1 -3
3
-1
3
2
2
1
2
1
3
2
2
T0283 - Computer Vision
5
4
2
2
2
3
2
1
3
3
2
2
1
2
1
3
2
2
4
15
Step 4
1
1
1
-1
2
1
-1 -1
1
January 20, 2010
1
1
1
2
2
2
-2
3
6
1
2
1
3 -3
3
-3
1
2
2
1
2
1
3
2
2
5
T0283 - Computer Vision
4
2
2
2
3
2
1
3
3
2
2
1
2
1
3
2
2
4
-2
16
Step 5
1
1
1
-1
2
1
-1 -1
1
January 20, 2010
1
2
2
2
3
5
-1
4
2
1
3
3
9
-1 -2
2
2
1
2
1
3
2
2
T0283 - Computer Vision
4
2
2
2
3
2
1
3
3
2
2
1
2
1
3
2
2
4
-2
17
Final Result
2
2
2
3
5
4
4
-2
2
1
3
3
9
6
14
5
2
2
1
2
11
7
6
5
1
3
2
2
9
12
8
5
I
January 20, 2010
I’
T0283 - Computer Vision
18
Smoothing (Low Pass Filtering)
Useful for noise reduction and image blurring
It removes the finer details of an image
Averaging or Mean (Box) Filter
The elements of the mask must be positive
The size of the mask determines the degree of smoothing
1
1
1
1
1
1
1
1
1
3 x 3 box filter kernel
January 20, 2010
T0283 - Computer Vision
19
Gaussian Filter (LPF)
The weights are sampled from a Gaussian function which fall off
to zero at the mask’s edges
0.003
0.013
0.022
0.013
0.003
0.013
0.059
0.097
0.059
0.013
0.022
0.097
0.159
0.097
0.022
0.013
0.059
0.097
0.059
0.013
0.003
0.013
0.022
0.013
0.003
5 x 5,  = 1
January 20, 2010
T0283 - Computer Vision
20
Gaussian Filter (cont’d)
Gaussian smoothing can be implemented efficiently, thanks to the
fact that the kernel is separable
January 20, 2010
T0283 - Computer Vision
21
Gaussian Filter (cont’d)
To convolve an image I with a n x n Gaussian mask G with
 = G
Build a 1-D Gaussian mask g, of width n, with g = G
Convolve each column of I with g, yielding a ne image Ic
Convolve each row of Ic with g
The value of  determines degree of smoothing
January 20, 2010
T0283 - Computer Vision
22
Gaussian Filter (examples)
Original image
Box filter
7 x 7 kernel
=1
January 20, 2010
=3
T0283 - Computer Vision
23
Median Filter (non-linear)
Effective for removing “salt & pepper” noise (random
occurences of black & white pixels)
Replace each pixel value by the median of the gray-levels in
the neighborhood of the pixels
10 20 20 15 99 20 20 25 20
sort
10 15 20 20 20 20 20 25 99
median
January 20, 2010
T0283 - Computer Vision
24
Median Filter (non-linear)
January 20, 2010
T0283 - Computer Vision
25
Median Filter (non-linear)
January 20, 2010
T0283 - Computer Vision
26
Sharpening (High Pass Filtering)
It is used to emphasize the fine details of an image
Points of high contrast can be detected by computing intensity
differences in local image regions
The weights of the mask are both positive and negative
When the mask is over an area of constant or slowly varying gray
level, the result of convolution will be close to zero
When gray level is varying rapidly within the neighborhood, the
result of convolution will be a large number
Typically, such points form the border between different objects or
scene parts (i.e., sharpening is a precursor step to edge detection
January 20, 2010
T0283 - Computer Vision
27
Sharpening (cont’d)
January 20, 2010
T0283 - Computer Vision
28
Download