一. 线性移不变系统
1.线性系统 H
- 可叠加性: H [ ( f 1 ( x , y ) + f 2 ( x , y ) ] = H ( f 1 ( x , y ) ) + H ( f 2 ( x , y ) ) H[(f_1(x,y)+f_2(x,y)]=H(f_1(x,y))+H(f_2(x,y)) H[(f1(x,y)+f2(x,y)]=H(f1(x,y))+H(f2(x,y))
- 伸缩性: H [ a f ( x , y ) ] = a H [ f ( x , y ) ] H[af(x,y)]=aH[f(x,y)] H[af(x,y)]=aH[f(x,y)]
2. 移不变系统H
- 移不变性: 若 H [ f ( x , y ) ] = g ( x , y ) ,则 H [ f ( x − a , y − b ) ] = g ( x − a , y − b ) H[f(x,y)]=g(x,y),则H[f(x-a,y-b)]=g(x-a,y-b) H[f(x,y)]=g(x,y),则H[f(x−a,y−b)]=g(x−a,y−b)
二. 卷积运算
(
f
∗
g
)
(
x
)
=
∫
−
∞
∞
f
(
τ
)
g
(
x
−
τ
)
d
τ
(f * g)(x) = \int_{-\infty}^{\infty} f(\tau) g(x - \tau) \, d\tau
(f∗g)(x)=∫−∞∞f(τ)g(x−τ)dτ
1. 卷积运算过程
1
◯
\textcircled{1}
1◯: 置换变量:
x
→
τ
x\rightarrow\tau
x→τ
2
◯
\textcircled{2}
2◯: 反转:
τ
→
−
τ
\tau\rightarrow-\tau
τ→−τ
3
◯
\textcircled{3}
3◯: 右移x:
−
(
τ
−
x
)
→
x
−
τ
-(\tau-x)\rightarrow x-\tau
−(τ−x)→x−τ
4
◯
\textcircled{4}
4◯: 对应位置相乘相加:
∫
−
∞
∞
f
(
τ
)
g
(
x
−
τ
)
d
τ
\int_{-\infty}^{\infty} f(\tau) g(x - \tau) \, d\tau
∫−∞∞f(τ)g(x−τ)dτ
2.卷积运算性质
- 交换性: f ∗ g = g ∗ f f*g=g*f f∗g=g∗f
- 结合性: f ∗ g ∗ z = f ∗ ( g ∗ z ) f*g*z=f*(g*z) f∗g∗z=f∗(g∗z)
- 分配性: f ∗ ( g + h ) = f ∗ g + f ∗ h f*(g+h)=f*g+f*h f∗(g+h)=f∗g+f∗h
3. 卷积是线性移不变系统在空域/时域的数字模型:
若已知一个线性移不变数字系统对单位脉冲的响应,我们可以知道该系统对任何输入的输出响应,卷积就是获得输出索要采用的数字计算。
首先
z
[
t
]
=
x
[
t
]
∗
y
[
t
]
=
[
1
]
∗
[
2
,
0
,
−
2
]
=
[
2
,
0
,
−
2
]
z[t]=x[t]*y[t]=[1]*[2,0, -2]=[2,0, -2]
z[t]=x[t]∗y[t]=[1]∗[2,0,−2]=[2,0,−2],一般地当输入
x
[
t
]
=
[
1
]
,
z
[
t
]
=
x
[
t
]
∗
y
[
t
]
=
y
[
t
]
x[t]=[1],z[t]=x[t]*y[t]=y[t]
x[t]=[1],z[t]=x[t]∗y[t]=y[t]
序号 | 刺激信号 x [ t ] x[t] x[t] | 系统响应 z 0 z_0 z0 |
---|---|---|
1 ◯ \textcircled{1} 1◯ | 1 ⋅ [ 1 0 0 ] 1 \cdot [1 \quad 0 \quad 0] 1⋅[100] | 1 ⋅ 2 1 ⋅ 0 1 ⋅ ( − 2 ) 0 0 1 \cdot 2 \quad 1 \cdot 0 \quad 1 \cdot (-2) \quad \textcolor{red}{0} \quad \textcolor{red}{0} 1⋅21⋅01⋅(−2)00 |
2 ◯ \textcircled{2} 2◯ | 2 ⋅ [ 0 1 0 ] 2 \cdot [0 \quad 1 \quad 0] 2⋅[010] | 0 2 ⋅ 2 2 ⋅ 0 2 ⋅ ( − 2 ) 0 0 \quad 2 \cdot 2 \quad 2 \cdot 0 \quad 2 \cdot (-2) \quad \textcolor{red}{0} 02⋅22⋅02⋅(−2)0 |
3 ◯ \textcircled{3} 3◯ | 3 ⋅ [ 0 0 1 ] 3 \cdot [0 \quad 0 \quad 1] 3⋅[001] | 0 0 3 ⋅ 2 3 ⋅ 0 3 ⋅ ( − 2 ) \textcolor{red}{0} \quad \textcolor{red}{0} \quad 3 \cdot 2 \quad 3 \cdot 0 \quad 3 \cdot (-2) 003⋅23⋅03⋅(−2) |
现在首先输入
x
[
t
]
=
[
1
,
2
,
3
]
=
1
⋅
[
1
,
0
,
0
]
+
2
⋅
[
0
,
1
,
0
]
+
3
⋅
[
0
,
0
,
1
]
x[t]=[1,2,3]=1\cdot [1,0,0] +2\cdot[0,1,0]+3\cdot[0,0,1]
x[t]=[1,2,3]=1⋅[1,0,0]+2⋅[0,1,0]+3⋅[0,0,1],
y
[
t
]
=
[
2
,
0
,
−
2
]
y[t]=[2,0,-2]
y[t]=[2,0,−2]
1
◯
\textcircled{1}
1◯用信号
x
0
=
1
⋅
[
1
0
0
]
x_0=1\cdot[1\quad0\quad0]
x0=1⋅[100] 刺激系统时,有响应
z
0
=
[
1
∗
2
1
∗
0
1
∗
(
−
2
)
0
0
]
z_0=[1*2\quad1*0 \quad 1*(-2)\quad \textcolor{red}{0}\quad\textcolor{red}0]
z0=[1∗21∗01∗(−2)00]
2
◯
\textcircled{2}
2◯用信号
x
1
=
2
⋅
[
0
1
0
]
x_1=2\cdot[0\quad1\quad0]
x1=2⋅[010] 刺激系统时,有响应
z
0
=
[
0
2
∗
2
2
∗
0
2
∗
(
−
2
)
0
]
z_0=[\textcolor{red}0\quad2*2\quad2*0\quad2*(-2)\quad\textcolor{red}0]
z0=[02∗22∗02∗(−2)0](
伸缩性,移不变性
\textcolor{red}{伸缩性,移不变性}
伸缩性,移不变性)
3
◯
\textcircled{3}
3◯用信号
x
1
=
3
⋅
[
0
0
1
]
x_1=3\cdot[0\quad0\quad1]
x1=3⋅[001] 刺激系统时,有响应
z
0
=
[
0
0
3
∗
2
3
∗
0
3
∗
(
−
2
)
]
z_0=[\textcolor{red}0\quad\textcolor{red}0\quad3*2\qquad3*0\quad3*(-2)]
z0=[003∗23∗03∗(−2)]
当我们把用信号 x 0 x 1 x 2 x_0 \quad x_1\quad x_2 x0x1x2叠加起来刺激系统时,由响应变成对应的响应的叠加 z [ t ] = z 0 + z 1 + z 2 = [ 2 4 4 − 4 − 6 ] z[t]=z_0+z_1+z_2=[2\quad 4\quad4\quad -4 \quad -6] z[t]=z0+z1+z2=[244−4−6]( 叠加性 \textcolor{red}{叠加性} 叠加性)
三.空域滤波器
1.线性滤波器MATLAB实现
g
=
i
m
f
i
l
t
e
r
(
f
,
w
,
f
i
l
l
t
e
r
i
n
g
m
o
d
e
,
b
o
u
n
d
a
r
y
o
p
t
i
o
n
s
,
s
i
z
e
o
p
t
i
o
n
s
)
g=imfilter(f,w,filltering_mode,boundary_options,sizeoptions)
g=imfilter(f,w,fillteringmode,boundaryoptions,sizeoptions)
其中
b
o
u
n
d
a
y
o
p
t
i
o
n
s
bounday_options
boundayoptions有4个选项:“P”,“replicate”,“symetric”,“circular”
如
[
1
2
3
4
5
]
[1\quad2\quad3\quad4\quad5]
[12345],则填充
边界选项 | 填充后的数组 |
---|---|
‘P’ 或 ‘circular’ | 4 5 1 2 3 4 5 1 2 |
‘replicate’ | 1 1 1 2 3 4 5 5 5 |
‘symmetric’ | 2 1 1 2 3 4 5 5 4 |
f
i
l
l
t
e
r
i
n
g
−
m
o
d
e
filltering_-mode
filltering−mode:
c
o
r
r
,
c
o
n
v
corr,conv
corr,conv(当卷积核为中心对称时,相关和卷积等价)
注意:imfilter之前使用im2double: 在计算过滤后图像的每个像素时,系统都使用双精度浮点运算,最后imfilter会将输出图像转化为与输入图像相同的类。因此,如果输入时整数数组,那么超过整数类型范围的输出像素值将被截断,小数值将被四舍五入。如果希望结果更精确,那么应该在使用imfilter之前使用im2double或double转换为double类。
2.锐化空间滤波器
锐化通常是通过空间差分
来完成的。
-
一维函数f(x)一阶导数的一个基本定义就是差分:
∂ f ∂ x = f ( x + 1 ) − f ( x ) \frac{\partial f}{\partial x} = f(x+1)-f(x) ∂x∂f=f(x+1)−f(x) -
二阶导数
∂ 2 f ∂ x 2 = f ( x + 1 ) + f ( x − 1 ) − 2 f ( x ) \frac{\partial^2 f}{\partial x^2} =f(x+1)+f(x-1)-2f(x) ∂x2∂2f=f(x+1)+f(x−1)−2f(x)
∂ 2 f ∂ x 2 = ∂ ∂ x ( f ( x ) − f ( x − 1 ) ) = ∂ ∂ x f ( x ) − ∂ ∂ x f ( x − 1 ) = f ′ ( x ) − f ′ ( x − 1 ) = ( f ( x + 1 ) − f ( x ) ) − ( f ( x ) − f ( x − 1 ) ) = f ( x + 1 ) + f ( x − 1 ) − 2 f ( x ) \begin{align*} \frac{\partial^2 f}{\partial x^2} &= \frac{\partial}{\partial x}\left(f(x) - f(x-1)\right) \\ &= \frac{\partial}{\partial x} f(x) - \frac{\partial}{\partial x} f(x-1) \\ &= f'(x) - f'(x-1) \\ &= \left(f(x+1) - f(x)\right) - \left(f(x) - f(x-1)\right) \\ &= f(x+1)+f(x-1)-2f(x) \end{align*} ∂x2∂2f=∂x∂(f(x)−f(x−1))=∂x∂f(x)−∂x∂f(x−1)=f′(x)−f′(x−1)=(f(x+1)−f(x))−(f(x)−f(x−1))=f(x+1)+f(x−1)−2f(x) -
应用:拉普拉斯滤波器:
(1)拉普拉斯算子 Δ f = ∂ 2 f ∂ x 2 + ∂ 2 f ∂ y 2 = [ f ( x + 1 , y ) + f ( x − 1 , y ) + f ( x , y + 1 ) + f ( x , y − 1 ) ] − 4 f ( x , y ) \Delta f = \frac{\partial^2 f}{\partial x^2} + \frac{\partial^2 f}{\partial y^2} =[f(x+1,y)+f(x-1,y)+f(x,y+1)+f(x,y-1)]-4f(x,y) Δf=∂x2∂2f+∂y2∂2f=[f(x+1,y)+f(x−1,y)+f(x,y+1)+f(x,y−1)]−4f(x,y)
(2)图像增强: g ( x , y ) = f ( x , y ) − Δ 2 f ( x , y ) = 5 f ( x , y ) − [ f ( x + 1 , y ) + f ( x − 1 , y ) + f ( x , y + 1 ) + f ( x , y − 1 ) ] g(x,y)=f(x,y)-\Delta^2f(x,y)= 5f(x,y)-[f(x+1,y)+f(x-1,y)+f(x,y+ 1)+f(x,y-1)] g(x,y)=f(x,y)−Δ2f(x,y)=5f(x,y)−[f(x+1,y)+f(x−1,y)+f(x,y+1)+f(x,y−1)]