Lecture 4: Non-Linear Filters & Image Compression: B14 Image Analysis Michaelmas 2014 A. Zisserman
Lecture 4: Non-Linear Filters & Image Compression: B14 Image Analysis Michaelmas 2014 A. Zisserman
• Image Compression
• Non-lossy vs lossy, JPEG
• Non-linear filters
• Median filter, bilateral filter, non-local means
• Inpainting
Image Compression
Why compress?
• Storage
• Bandwidth
The key attribute which enables compression is redundancy
Example
PAL colour video 768 x 576 pixels at 25 frames per second = 33 Mbytes per second
A 2hour video = 238 Gbytes (cf CD holds 0.7 Gbytes, a DVD holds 7 Gbytes)
Intensity histogram
frequency
intensity
• instead of using same length code
(1 byte) for every intensity,
use variable length coding use short use long
code code
d
e
c Reconstruct each
o Decode Recompose image
d block from its
i coefficients from 8 x 8 blocks
n DCT coefficients
g
Discrete Cosine Transform (DCT) (cf Fourier series)
where 1
for w 0 ,
C w 2
1 for w 1, 2 ,..., N 1
JPEG
Definition
1. rank-order neighbourhood intensities
2. select middle value
In 1D
The median of 2N+1 samples is the value which has N smaller
or equal values, and N larger or equal to it.
Example
sort
{ 5, 7, 3, 4, 5, 19, 6, 4, 9 } { 3, 4, 4, 5, 5, 6, 7, 9, 19 }
Median of set = 5
Note, “odd man out” effect: { 1, 1, 1, 7, 1, 1, 1 }
median width 3
{ ?, 1, 1, 1, 1, 1, ? }
filters have width 5
Median filter
• no new grey values are created
• edge is preserved
• spike is removed
Median filter in 2D
• A median filter operates over a window by selecting
the median intensity in the window
Source: K. Grauman
Median properties
Suppose f{i} and g{i} are two sets of 2N+1 values, then
1. med( k f{i} ) = k med( f{i} )
2. med( k + f{i} ) = k + med( f{i} )
Gaussian
Median
• patchy effect
• important details lost (e.g. ear-ring)
Salt and Pepper noise
Gaussian
= 1 pixel
3x3
median
Median filter
Salt and
Median
pepper
filtered
noise
Gaussian filter = 2
Can we remove noise but
not blur edges?
6
Gaussian filter = 4
6
filtering f(x,y) with a Gaussian filter h(x,y)
1newX
In(p) = Gσs (||p−q||)Gσr (|I(p)−I(q)|)I(q)
W q∈S
spatial range
weight weight
normalization
factor I
1D illustration
pixel
intensity
pixel position
1 X
In(p) = Gσs (||p−q||)Gσr (|I(p)−I(q)|)I(q)
W q∈S
1D illustration
spatial
range
pixel
intensity
p
pixel position
1 X
In(p) = Gσs (||p−q||)Gσr (|I(p)−I(q)|)I(q)
W q∈S
Only pixels close in space and in range are considered
Gaussian blur vs bilateral Filter
Gaussian blur
p
spatial
Bilateral filter
p range
spatial
1 X
In(p) = Gσs (||p−q||)Gσr (|I(p)−I(q)|)I(q)
W q∈S
p p
q
output input
input
s = 2
s = 6
s = 18
Basic denoising
Image self-similarity
A. Buades, B. Coll, J.M. Morel "A non local algorithm for image denoising”, CVPR 2005
Non-Local Means Denoising
1 X − d(Np2,Nq) Nq
In(p) = e h I(q) q
W q∈Φ
d(Np ,Nq )
P −
where Φ is the set of neighbourhoods and W = q∈Φ e h2
−d(Np ,Nq )
d(Np, Nq) e h2
black = low
Parameters:
• neighbourhood size: 5 x 5
• search region: 7 x 7
Removing film grain
original
Removing film grain
denoised
Inpainting
Inpainting techniques
Texture
sample
Output
p
input image
synthesized image
input
original frame
Removal of foreground objects using inpainting
inpainted frame
Removal of foreground objects using inpainting
original frame
Removal of foreground objects using inpainting
inpainted frame
There is much more …
scale
retarget