Chap3 Image Processing (2018)
Chap3 Image Processing (2018)
what is an image?
Digital Camera
What is this?
coordinate systems
y
y
x
x x
42 45 49 57 65 54 66 63 42 64 95
73 72 68 67 69 75 59 62 55 35 37
82 83 83 84 85 81 79 90 77 76 73
n 96
93
95
91
95
93
92
95
90
95
93
96
88
97
79
104
95
94
88
96
93
104
110 107 102 104 110 107 103 102 110 97 106
109 112 113 109 105 107 101 108 116 115 111
f(m,n) 109 107 109 112 113 101 119 128 143 121 122
CCD sensor m 114 114 115 115 113 119 146 154 115 110 116
125 125 120 118 121 160 140 112 118 116 122
114 110 115 137 161 132 119 119 107 124 120
pixel
image types
gray scale images binary images multi-spectral images
color images
neighborhood 4
N4 (i , j ) = {(i - 1, j ), (i + 1, j ), (i , j - 1), (i , j + 1)}
neighborhood 8
N8 (i , j ) = {(i - 1, j - 1), (i - 1, j ), (i - 1, j + 1), (i , j - 1),
(i , j + 1), (i + 1, j - 1), (i + 1, j ), (i + 1, j + 1)}
connectivity
y
x are x, y connected?
NO
binary image
connectivity: two pixels x, y of a binary image u(m,n) are connected iif (if and
only if) there a sequence of points z1, z2, ..., zn:
1 n
z = x, z = y
i i +1
z ,z are neighbors "i Î { 1, 2, ..., n - 1}
i
u( z ) = 1 "i = 1,..., n
regions
1 1
1 2 1 2
1 1 1 3 3 3
3 3
4↔5
4 4
5 5 5 5
5 5 5 5
5 5 5 5
image filtering
Modify the pixels in an image based on some function
of a local neighborhood of each pixel
10 5 3 Some function
4 5 1 7
1 1 7
Local image data Modified image data
examples
original blurred
i +N j +N
g(i , j) = 1 å å f(k, l) N=1
( 2N +1)2 k = i - N l = j - N
mean filter
2N+1
N=2
2N+1
gaussian filter
filtered image 2 2
- k +l
G(k , l ) = C e 2s 2
g(i , j) = å G(k - i,l - j)f(k , l)
k ,l
j j
f(i,j)
weighted average i i
g(i,j)
orig. s=0.2
s=1 s=2
s =0 s =1 s =3 s =6
g (i , j ) = å M (k - i , l - j )f (k , l ) = M (i , j ) Ä f (i , j ) M(i , j ) mask
k,l
separable filters
matrix notation
g = Hf g, f Î IR p , H Î IR p´ p
M(i,j) = 1 2 1 M(i,j) = -1 -2 -1
2 4 2 0 0 0
1 2 1 1 2 1
example
J (m, n ) = h(m, n ) * I (m, n ) h(m, n ) = δ (m, n ) - G(m, n )
original filtered
gradient vector:
|| g ( x ) ||= g12 ( x ) + g 22 ( x )
Ðg ( x ) = arctan g2( x )
1
( )
g (x)
gradient discretization
High pass filtering in one direction, and low pass filtering in the orthogonal direction
example
g1
g2 |g|
effects of noise
• Consider a single row or column of the image
– Plotting intensity as a function of position gives a signal
!(#)
Laplacian of Gaussian
operator
Laplacian of a 2D image
( "# ( "#
! " # $, & = + zero crossings are associated to transitions
($ " (& "
Since the derivatives increase noise, the image should first be filtered using a
Gaussian filter
$" + &" 2
! "* $, & = − *($, &)
./ ."
, , #+
# + + . ,% + 24 +6
ℎ" #, % = exp − cos 5
20 ,
#′, + . , %′, #′
ℎ, #, % = exp − , sin 24 + 6
20 5
rotation
# + = # cos : + % sin :
% + = −# sin : + % cos :
Jorge s. Marques, José Santos-Victor, 2018 39
10
12
2 4 6 8 10 12
non-linear filtering
Is it possible to solve this conflict i.e., removing the noise, preserving the
contours?
1D median filter
f g
g (n ) = median{ f (n - M ),..., f (n + M )}
filter
f 1 0 2 4 5 g 1
1 0
example
f g
filter
example
original image
video sequence
time
diffusion
linear diffusion
gaussian filtering
time
Gaussian space-scale
The Gaussian space-scale is obtained by filtering the image using a
Gaussian kernel and changing the parameter s from 0 to infinity.
!" # = %" ∗ #
Limitations:
- It destroys the contour information: how can we overcome this difficulty?
- Can be generated with a linear diffusion process
g(x) - concentration
mass flows from regions of high concentration to regions with smaller concentration
taking the gradient opposite direction.
Fick’s law Mass conservation law
¶g j(x,t) – diffusion flux
j = -cÑg = -div j c(x,t) – diffusion coefficient
¶t g(x,t) – concentration
conductivity
1
c( x,t ) =
2
1 + a Ñg ( x,t )
0 1 2 3 |Ñg|
¶g 1
= div (c(x, t)Ñg) c( x,t ) =
2
¶t 1 + a Ñg ( x,t )
remark:
¶A ¶B
div v = + v = (A,B )
¶x ¶y
discretization
Perona & Malik algorithm is based on a discretization of the diffusion equation in
which the partial derivatives are replaced by first order differences.
where
N um-1,n
,n = gm,n + l [cN ÑN g + cS ÑS g + cE ÑE g + cW ÑW g ]m,n
t +1 t t
gm 0 £ l £ 1/ 4
W E um,n+1
um,n-1
um,n
0 d
% 0, . = 1 − . % 0,0 + .% 0,1
h 1
% 1, . = 1 − . % 1,0 + .% 1,1
% 2, . = 1 − 2 % 0, . + 2% 1, .
1
0.8 Replacing
0.6
"
! " = - " ∗ ℎ " = ∑ - 7 ℎ(" − 7)
- " = .& + " = '+
0 01ℎ2+3"42
= $ & ' ℎ(" − '+) 7 = '+
%
2D
! ", 9 = $ & ', ; ℎ(" − '+, 9 − ;+)
%,:
Jorge s. Marques, José Santos-Victor, 2018 64
Interpolation results
filters bilinear bicubic (a=-1)
decimation
Decimation reduces the image resolution by a factor k. It involves two
steps: 1) lowpass filtering (anti-aliasing) and 2) subsampling.
f(i)
f(i) d(i) g(i)
1D h(i) r
0 r 2r 3r i
d(i)
! " = $ & ' ℎ(" − ')
%
0 r 2r 3r i
g(i)
, " = !(-") = $ & ' ℎ(-" − ')
%
0 1 2 3 i
2D
, ", / = $ & ', 1 ℎ(-" − ', -/ − 1) , ", / = $ & ', 1 ℎ(" − '/-, / − 1/-)
%,0 %,0
Jorge s. Marques, José Santos-Victor, 2018 h(k,l) is the decimation kernel if h(k,l) is the interpolation kernel 66
Gaussian pyramid (Burt & Adelson)
lowpass filter
!
!" 14641
reconstruction
reconstruction
Block diagram
• perfect reconstruction
• inefficient representation
Richard Szeliski,
Computer Vision: Algorithms and Application,
Springer, 2011