Professional Documents
Culture Documents
2
Content
• Remind: digital image representation
• Point Operators
• Image Filtering
3
Digital images ?
4
Digital images ?
• For an image I x
5
Digital images ?
• Gray image:
- I(x,y) Î [0..255]
- 1 pixel: 8 bits (1 byte)
• Color image
- IR(x,y), IG(x,y) IB(x,y) Î [0..255]
- 1 pixel: 24 bits (3 bytes )
6
Color image in RGB space
7
Images are sampled and quantized
• Pixel value:
‒ “grayscale”
(or “intensity”): [0,255]
231
148
8
Images are sampled and quantized
‒ “grayscale”
(or “intensity”): [0,255]
‒ “color”
[249,
• RGB: [R, G, B] 215,
• Lab: [L, a, b] 203]
• HSV: [H, S, V] [213, 60, 67]
9
Modification of images values
10
Pixel transformation
12
Point processing
• The output at one point depends only on that point
but not other neighborhoods
s = T(r)
§ r = f(x, y)
§ s = g(x, y)
§ T: transformation function
13
Homogenous transformation
s=T(r)
light
The output is
T(r) identical as the
input : s = r
m
r
Dark
m
Dark Light
14
Linear / Non-linear transformation
s=T(r) s=T(r)
light
light
T(r) T(r)
n n
r Dark r
Dark
m m
Dark Light Dark Light
15
Contrast stretching
s=T(r)
Light
r
Dark
m
Dark Light
16
Thresholding function
s=T(r)
1
T(r)
Thresholding function T(r)
outputs the image as binary
image:
• s = 0 if r <m
• s = 1 if r >= m
0 r
m
17
Some Basic Gray Level Transformations
• Image Negatives
• Log Transformations
• Power-Law Transformations
• Piecewise-Linear Transformation Functions
• Histogram Processing
18
Image Negatives
• The negative of an image with gray levels in the range
[0, L-1] is obtained by s = L - 1 – r
L-1
3L/4
Ouput gray level, s
L/2 Negative
L/4
19
Log Transformations
3L/4
Output gray leve, s
Log
L/2
L/4 Inverse
log
21
Inverse Log Transformations
• This transformation maps
‒ a wide range of low gray-level values in the input image
into a more narrow range of output levels.
‒ The opposite is true of higher values of input levels.
• Use this Inverse Log if you want to compress the
values of dark pixels in an image while expanding
the higher-level values.
22
Power-Law (Gamma) Transformations
• The general form of power-law
transformation is:
𝑠 = 𝑐. 𝑟 g
‒ g > 1: compress values in dark
area, while expanding values in
light area
‒ g < 1 : expand values in dark
area, while compressing values
in light area
‒ r : normalized values to [0, 1]
‒ c : scaling constant c
corresponding to the bit size
used
23
Power-Law (Gamma) Transformations
• γ1 = 1; γ1 = 3; γ2 = 4; γ3 = 5;
Increasing
the dynamic
ranges of
high
intensities
24
Gama correction
25
Gama correction
Image: Wikipedia
26
Piecewise-Linear Transformation
• Contrast stretching:
L-1
‒ the idea behind contrast
stretching is to increase the
(r2, s2)
dynamic range of the gray 3L/4
levels in the image being
processed T(r)
L/2
• Output:
‒ Output values of input ones from (0,
0) to (r1, s1) decrease L/4
‒ Output values of input ones from (r1, s1)
(r1, s1) đến (r2, s2) increase.
27
Piecewise-Linear Transformation
L-
L-1
1
3L/4
‒ the function become
thresholding function T(r)
L/2
‒ Output is a binary image
L/4
(r1, s1)
0 L/4 L/2 3L/4 L-1
28
Piecewise-Linear Transformation
(r2, s2)
255
0 (r1, s1)
0 rmi rsmin rmax
• If (r1, s1) = (rsmin, 0), rsmin > rmin 255
n
(r2, s2)
(r2, s2) = (rsmax, 255) rsmax < rmax
‒ Linear stretching with saturation
T(r)
0 (r1, s1)
0 rmin rsmin rsmax rmax
29
Piecewise-Linear Transformation
30
Image histogram
• What is histogram?
‒ Histogram of an image with gray level range [0, L-1] is a
discrete function: ℎ 𝑟! = 𝑛!
• 𝑟! is kth gray level
• 𝑛! : number of pixels that have level 𝑟!
‒ Histogram is a graphical representation of the repartition
of colours among the pixels of a digital image
31
Image histogram
• Normalized histogram?
‒ The histogram should be normalized by dividing all elements
"
to total number of pixels in the image (n) : ℎ 𝑟! = "
"
32
Image histogram
• Properties?
‒ Only statistic information
‒ No indication about the location of pixel (no spatial
information)
‒ Different images can have the same histogram
33
Image Brightness
• Brightness of a grayscale image is the average intensity
of all pixels in an image
‒ refers to the overall lightness or darkness of the image
34
Contrast
• The contrast of a grayscale image indicate how easily
object in the image can be distinguished
• Many different equations for contrast exist
‒ Standard deviation of intensity values of pixels in the image
& (
1 )
𝐶= ( ( 𝐼 𝑢, 𝑣 − 𝑚𝑒𝑎𝑛
𝑤ℎ
#$% '$%
35
Contrast
¡ Contrast vs histogram
36
Histogram and Brightness
Dark image
Light image
37
Histogram and Contrast
Low- contrast
image
High- contrast
image
38
Histogram
• If we can somehow equalize the histogram of an
image à we can make it higher contrast.
39
Histogram Equalization
40
Histogram Equalization
41
Discrete Implementation
42
Histogram equalization
Ex. 1. Input image I has 10 levels.
Equalize the histogram of I # pixels
2 3 3 2 6
4 2 4 3 5 Histogram
3 2 3 5 4
2 4 2 4 3
2
k 0 1 2 3 4 5 6 7 8 9
1
nk 0 0 6 5 4 1 0 0 0 0 Gray level
0 1 2 3 4 5 6 7 8 9
43
Histogram equalization
k 0 1 2 3 4 5 6 7 8 9
nk 0 0 6 5 4 1 0 0 0 0
! 𝑛! 0 0 6 11 15 16 16 16 16 16
!"#
44
Histogram equalization
k sk 2 3 3 2 # pixcels
0 0 6
4 2 4 3
1 0 5
3 2 3 5
2 3 4
2 4 2 4
3 6
3
4 8
2
5 9
3 6 6 3
6 9 1 Gray
8 3 8 6 level
7 9
8 9 6 3 6 9 0 1 2 3 4 5 6 7 8 9
9 9 3 8 3 8 Histogram after equalization
45
Histogram equalization
46
Histogram equalization
If we take the same image with different contrasts, histogram equalization
will give the same results for all images
47
Histogram equalization
• Discussion
‒ Compare between histogram equalization and
Piecewise-Linear Transformation Functions
‒ Is histogram equalization always good?
48
Histogram equalization
• Change histogram of modified image into uniform distribution
49
Histogram equalization
52
Histogram equalization
53
Histogram matching/specification
• In some cases: uniform histogram does not have a
best result
àSpecify a good histogram
àTransform the image to have the specific histogram
54
Histogram matching
Desired histogram
è Additional lecture
55
Contrast enhancement for color
images ?
• Histogram egalization of color images ?
‒ Apply separately the procedure to each of the three
channels
• will yield in a dramatic change in the color balance
• NOT RECOMMENED unless you have a good reason for
doing that.
‒ Recommended method
• Convert the image into another color space such as the
Lab color space or HSL/HSV color space
• Apply the histogram equalization on the Luminance
channel
• Convert back into the RGB color space
63
Content
• Rappel: digital image representation
• Point Processing
• Image filtering
64
Image filtering
Filtering:
– Forming a new image whose pixel values are
transformed from original pixel values
Goals:
• Goal is to extract useful information from
images, or transform images into another
domain where we can modify/enhance image
properties
• Features (edges, corners, blobs…)
• super-resolution; in-painting; de-noising
65
Super-resolution
De-noising
In-painting
Bertamio et al
66
Image filtering
67James Hays
Image filtering
• Image filtering:
‒ Compute function of local neighborhood at each
position
h[m, n] = å f [k , l ] I [m + k , n + l ]
k ,l
68James Hays
Image filtering
• Image filtering:
‒ Compute function of local neighborhood at each
position
h=output f=filter I=image
h[m, n] = å f [k , l ] I [m + k , n + l ]
k ,l
2d coords=k,l 2d coords=m,n
[ ] [ ]
[ ]
69
Example: box filter
f [× ,× ]
1 1 1
1 1 1
1 1 1
f [× ,× ] 1 1 1
1 1 1
I [.,.] h[.,.]
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0
0 0
0 0
0 90
90 0
0 90
90 90
90 90
90 0
0 0
0
0
0 0
0 0
0 90
90 90
90 90
90 90
90 90
90 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 90
90 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 0
0 0
0 0
0
h[m, n] = å f [k , l ] I [m + k , n + l ]
k ,l Credit:
71S. Seitz
Image filtering 1 1 1
f [× ,× ] 1 1 1
1 1 1
I [.,.] h[.,.]
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
h[m, n] = å f [k , l ] I [m + k , n + l ]
k ,l Credit:
72S. Seitz
Image filtering 1 1 1
f [× ,× ] 1 1 1
1 1 1
I [.,.] h[.,.]
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
h[m, n] = å f [k , l ] I [m + k , n + l ]
k ,l Credit:
73S. Seitz
Image filtering 1 1 1
f [× ,× ] 1 1 1
1 1 1
I [.,.] h[.,.]
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
h[m, n] = å f [k , l ] I [m + k , n + l ]
k ,l Credit:
74S. Seitz
Image filtering 1 1 1
f [× ,× ] 1 1 1
1 1 1
I [.,.] h[.,.]
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
h[m, n] = å f [k , l ] I [m + k , n + l ]
k ,l Credit:
75S. Seitz
Image filtering 1 1 1
f [× ,× ] 1 1 1
1 1 1
I [.,.] h[.,.]
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
?
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
h[m, n] = å f [k , l ] I [m + k , n + l ]
k ,l Credit:
76S. Seitz
Image filtering 1 1 1
f [× ,× ] 1 1 1
1 1 1
I [.,.] h[.,.]
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
?
0 0 0 90 0 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0 50
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
h[m, n] = å f [k , l ] I [m + k , n + l ]
k ,l Credit:
77S. Seitz
Image filtering f [× ,× ] 1 1 1
1 1 1
1 1 1
I [.,.] h[.,.]
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 20 10
0 0 0 90 90 90 90 90 0 0 0 20 40 60 60 60 40 20
0 0 0 90 90 90 90 90 0 0 0 30 60 90 90 90 60 30
0 0 0 90 90 90 90 90 0 0 0 30 50 80 80 90 60 30
0 0 0 90 0 90 90 90 0 0 0 30 50 80 80 90 60 30
0 0 0 90 90 90 90 90 0 0 0 20 30 50 50 60 40 20
0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 30 20 10
0 0 90 0 0 0 0 0 0 0 10 10 10 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
h[m, n] = å f [k , l ] I [m + k , n + l ]
k ,l Credit:
78S. Seitz
Box Filter
f [× ,× ]
What does it do?
• Replaces each pixel with 1 1 1
an average of its
neighborhood 1 1 1
1 1 1
• Achieve smoothing effect
(remove sharp features)
f [× ,× ]
What does it do?
• Replaces each pixel with 1 1 1
an average of its
neighborhood 1 1 1
1 1 1
• Achieve smoothing effect
(remove sharp features)
81
Image filtering
• Image filtering:
‒ Compute function of local neighborhood at each
position
h[m, n] = å f [k , l ] I [m + k , n + l ]
k ,l
• Really important!
‒ Enhance images
• Denoise, resize, increase contrast, etc.
‒ Extract information from images
• Texture, edges, distinctive points, etc.
‒ Detect patterns
• Template matching
82James Hays
Think-Pair-Share time
0 0 0
1. 0 1 0
0 0 0
0 0 0
2. 0 0 1
0 0 0
1 0 -1
3. 2 0 -2
1 0 -1
0 0 0 1 1 1
4. 0
0
2
0
0
0
- 1
1
1
1
1
1
83
1. Practice with linear filters
0 0 0
0 1 0 ?
0 0 0
Original
84 Lowe
Source: D.
1. Practice with linear filters
0 0 0
0 1 0
0 0 0
Original Filtered
(no change)
85 Lowe
Source: D.
2. Practice with linear filters
0 0 0
0 0 1 ?
0 0 0
Original
86 Lowe
Source: D.
2. Practice with linear filters
0 0 0
0 0 1
0 0 0
87 Lowe
Source: D.
3. Practice with linear filters
1 0 -1
2 0 -2
1 0 -1
Sobel
Vertical Edge
(absolute value)
88David Lowe
3. Practice with linear filters
1 2 1
0 0 0
-1 -2 -1
Sobel
Horizontal Edge
(absolute value)
89David Lowe
4. Practice with linear filters
0 0 0 1 1 1
0
0
2
0
0
0
- 1
1
1
1
1
1
?
(Note that filter sums to 1)
Original
90 Lowe
Source: D.
4. Practice with linear filters
0 0 0 1 1 1
0
0
2
0
0
0
- 1
1
1
1
1
1
Original
Sharpening filter
- Accentuates differences with local
average
91 Lowe
Source: D.
4. Practice with linear filters
92 Lowe
Source: D.
Correlation and Convolution
• 2d correlation
h[m, n] = å f [k , l ] I [m + k , n + l ]
k ,l
h=filter2(f,I); or h=imfilter(I,f);
• 2d convolution
h[m, n] = å f [k , l ] I [m - k , n - l ]
k ,l
h=conv2(f,I); or h=imfilter(I,f,’conv’);
93James Hays
1D Discrete convolution (symbol: )
h[k,l] f[k,l]
94
1D Discrete convolution (symbol: )
h[k] h[n-k]
95
Discrete convolution (symbol: )
h[-2-k]
f[k] g[-2]
96
Discrete convolution (symbol: )
h[-1-k]
f[k] g[-1]
97
Discrete convolution (symbol: )
h[-k]
f[k] g[0]
98
Discrete convolution (symbol: )
h[1-k]
f[k] g[1]
99
Discrete convolution (symbol: )
h[2-k]
f[k] g[2]
100
Discrete convolution (symbol: )
h[n-k]
f[k] g[n]
101
2D convolution
2D convolution is very similar to 1D.
• The main difference is that we now have to iterate over 2 axis instead of 1.
f [n, m] ⇤ h[n, m]
102
2D convolution
2D convolution is very similar to 1D.
• The main difference is that we now have to iterate over 2 axis instead of 1.
f [n, m] ⇤ h[n, m]
103
2D convolution
2D convolution is very similar to 1D.
• The main difference is that we now have to iterate over 2 axis instead of 1.
f [n, m] ⇤ h[n, m]
104
2D convolution
2D convolution is very similar to 1D.
• The main difference is that we now have to iterate over 2 axis instead of 1.
f [n, m] ⇤ h[n, m]
105
2D convolution
2D convolution is very similar to 1D.
• The main difference is that we now have to iterate over 2 axis instead of 1.
f [n, m] ⇤ h[n, m]
106
2D convolution
2D convolution is very similar to 1D.
• The main difference is that we now have to iterate over 2 axis instead of 1.
f [n, m] ⇤ h[n, m]
107
2D convolution example
108
2D convolution example
109
2D convolution example
110
2D convolution example
111
2D convolution example
112
2D convolution example
113
2D convolution example
114
Convolution in 2D - examples
•0 •0 •0
* •0 •1 •0
= ?
•0 •0 •0
Original
Courtesy of D Lowe
115
Convolution in 2D - examples
•0 •0 •0
* •0 •1 •0
•0 •0 •0
=
Original Filtered
Courtesy of D Lowe
(no change)
116
Convolution in 2D - examples
•0 •0 •0
* •0 •0 •1
= ?
•0 •0 •0
Original
Courtesy of D Lowe
117
Convolution in 2D - examples
•0 •0 •0
* •0 •0 •1
•0 •0 •0
=
Original Shifted right
Courtesy of D Lowe
By 1 pixel
118
Convolution in 2D - examples
•1 •1 •1
* •1 •1 •1
•1 •1 •1
= ?
Original
Courtesy of D Lowe
119
Convolution in 2D - examples
•1 •1 •1
* •1 •1 •1
•1 •1 •1
=
Original Blur (with a
Courtesy of D Lowe
box filter)
120
Convolution in 2D - examples
•0 •0 •0 •1 •1 •1
•0 •2 •0
•0 •0 •0
- •1 •1 •1
•1 •1 •1
=?
(Note that filter sums to 1)
Original
“details of the image”
•0 •0 •0 •0 •0 •0 •1 •1 •1
Courtesy of D Lowe
•0 •1 •0
•0 •0 •0
+ •0 •1 •0
•0 •0 •0
- •1 •1 •1
•1 •1 •1
121
• What does blurring take away?
– =
+a =
122
Convolution in 2D – Sharpening
filter
•0 •0 •0 •1 •1 •1
•0 •2 •0
•0 •0 •0
- •1 •1 •1
•1 •1 •1 =
Original
Courtesy of D Lowe
Sharpening filter: Accentuates differences with local average
123
Convolution properties
Commutative: a * b = b * a
‒ Conceptually no difference between filter and signal
‒ But particular filtering implementations might break this
equality, e.g., image edges
Associative: a * (b * c) = (a * b) * c
‒ Often apply several filters one after another: (((a * b1) * b2) *
b3)
‒ This is equivalent to applying one filter: a * (b1 * b2 * b3)
Source: S.124
Lazebnik
Convolution properties
Proof of associativity of convolution
125
Convolution properties
Commutative: a * b = b * a
‒ Conceptually no difference between filter and signal
‒ But particular filtering implementations might break this
equality, e.g., image edges
Associative: a * (b * c) = (a * b) * c
‒ Often apply several filters one after another: (((a * b1) * b2) *
b3)
‒ This is equivalent to applying one filter: a * (b1 * b2 * b3)
‒ Correlation is _not_ associative
‒ Why important?
Source: S.126
Lazebnik
Convolution properties
• Commutative: a * b = b * a
‒ Conceptually no difference between filter and signal
‒ But particular filtering implementations might break this equality,
e.g., image edges
• Associative: a * (b * c) = (a * b) * c
‒ Often apply several filters one after another: (((a * b1) * b2) * b3)
‒ This is equivalent to applying one filter: a * (b1 * b2 * b3)
‒ Correlation is _not_ associative (rotation effect)
‒ Why important?
x 5 x 5, s = 1
y
129
James Hays
Smoothing with box filter
130
Gaussian filters
• Remove “high-frequency” components from the image
(low-pass filter)
‒ Images become more smooth
• Gaussian convolved with Gaussian…
…is another Gaussian
– So can smooth with small-width kernel, repeat, and get same
result as larger-width kernel would have
– Convolving two times with Gaussian kernel of width σ is same
as convolving once with kernel of width σ√2
• Separable kernel
– Factors into product of two 1D Gaussians
Source: K.131
Grauman
Separability of the Gaussian filter
132D. Lowe
Source:
Separability example
2D convolution =
(center location only)
Perform convolution
along rows: * =
Followed by convolution =
along the remaining column: *
Source: K. 133
Grauman
Separability
Why is separability useful in practice?
134
Separability
Why is separability useful in practice?
Speed up = PQ/(P+Q)
9x9 filter = ~4.5x faster
135
Practical matters
How big should the filter be?
• Values at edges should be near zero
• Gaussians have infinite extent…
• Rule of thumb for Gaussian: set filter half-width to
about 3 σ
136James Hays
Practical matters
• What about near the edge?
‒ the filter window falls off the edge of the image
‒ need to extrapolate
‒ methods:
• clip filter (black)
• wrap around
• copy edge
• reflect across edge
137
Source: S. Marschner
Convolution in Convolutional Neural
Networks
• Convolution is the basic operation in CNNs
• Learning convolution kernels allows us to learn
which `features’ provide useful information in
images.
138
Non-linear filters
139
Median filters
• Operates over a window by selecting the median
intensity in the window.
• ‘Rank’ filter as based on ordering of gray levels
‒ E.G., min, max, range filters
f [× ,× ] 1 1 1
1 1 1
I [.,.] h[.,.]
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
?
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
h[m, n] = å f [k , l ] I [m + k , n + l ]
k ,l Credit:
141S. Seitz
Image filtering - mean 1 1 1
f [× ,× ] 1 1 1
1 1 1
I [.,.] h[.,.]
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0 50
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
h[m, n] = å f [k , l ] I [m + k , n + l ]
k ,l Credit:
142S. Seitz
Median filter?
I [.,.] h[.,.]
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
?
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
Credit:
143S. Seitz
Median filters
• Operates over a window by selecting the median
intensity in the window.
• What advantage does a median filter have over a
mean filter?
145
Mean Jack – 3 x 3 filter
146
Very Mean Jack – 11 x 11 filter
147
Noisy Jack – Salt and Pepper
148
Median Jack – 3 x 3
149
Very Median Jack – 11 x 11
150
Median filters
• Operates over a window by selecting the median
intensity in the window.
• What advantage does a median filter have over a
mean filter?
• Is a median filter a kind of convolution?
Slide:
152 Hoiem
Review: questions
1. Write down a 3x3 filter that both:
- Returns a positive value if the average value of the 4-
adjacent neighbors is less than the center,
[ 0 -1/4 0;
- Returns a negative value otherwise. -1/4 1 -1/4;
0 -1/4 0 ]
Slide:
153 Hoiem