第4章 Python 数字图像处理(DIP) - 频率域滤波3 - 取样和取样函数的傅里叶变换、混叠

取样和取样函数的傅里叶变换

取样

f ˉ ( t ) = f ( t ) s Δ T ( t ) = ∑ n = − ∞ ∞ f ( t ) δ ( t − n Δ T ) (4.27) \bar f(t) = f(t)s_{\Delta T}(t) = \sum_{n=-\infty}^{\infty}f(t) \delta(t - n\Delta T) \tag{4.27} fˉ(t)=f(t)sΔT(t)=n=f(t)δ(tnΔT)(4.27)
f k = ∫ − ∞ ∞ f ( t ) δ ( t − k Δ T ) d t = f ( k Δ T ) (4.28) f_k = \int_{-\infty}^{\infty} f(t)\delta(t - k\Delta T) dt = f(k\Delta T) \tag{4.28} fk=f(t)δ(tkΔT)dt=f(kΔT)(4.28)

# 取样
x = np.arange(-10, 10, 0.01)
y_1 = 1.5 - np.sin(x)

fig = plt.figure(figsize=(9, 6))
ax_1 = setup_axes(fig, 211)
ax_1.plot(x, y_1), ax_1.set_title('f(t)', loc='center', y=1.05), ax_1.set_ylim([0, 4]), ax_1.set_yticks([]), ax_1.set_xticks([])

x_2 = x[::50]
y_2 = y_1[::50]
ax_2 = setup_axes(fig, 212)
ax_2.scatter(x_2, y_2), ax_2.set_title('f_k', loc='center', y=1.05), ax_2.set_ylim([0, 4]), ax_2.set_yticks([]), ax_2.set_xticks([])

plt.tight_layout()
plt.show()

在这里插入图片描述

取样后的函数的傅里叶变换

取样后的函数 f ˉ ( t ) \bar f(t) fˉ(t)的傅里叶变换 F ˉ ( μ ) \bar F(\mu) Fˉ(μ)
F ˉ ( μ ) = J { f ˉ ( t ) } = J { f ( t ) s Δ T ( t ) } = ( F ⋆ S ) ( μ ) (4.29) \bar F(\mu) = \mathfrak{J} \{ \bar f(t) \} = \mathfrak{J} \{ f(t) s_{\Delta T}(t)\} = (F \star S)(\mu) \tag{4.29} Fˉ(μ)=J{fˉ(t)}=J{f(t)sΔT(t)}=(FS)(μ)(4.29)

S ( μ ) = 1 Δ T ∑ n = − ∞ ∞ δ ( μ − n Δ T ) (4.30) S(\mu) = \frac{1}{\Delta T} \sum_{n=-\infty}^{\infty} \delta(\mu - \frac{n}{\Delta T}) \tag{4.30} S(μ)=ΔT1n=δ(μΔTn)(4.30)

所以有
KaTeX parse error: No such environment: align at position 7: \begin{̲a̲l̲i̲g̲n̲}̲ \bar F(\mu) & …

# 过取样、临界取样和欠取样
x = np.arange(0, 6, 0.01)
y = 2 - x
y = np.where(x <= 2, y, 0)
x_1 = np.concatenate((-x[::-1], x), axis=0)
y_1 = np.pad(y, (y.shape[0], 0), mode='reflect')

fig = plt.figure(figsize=(10, 8))
# 带限函数的傅里叶变换
ax_1 = setup_axes(fig, 411)
ax_1.plot(x_1, y_1), ax_1.set_title('F(u)', loc='center', y=1.05), ax_1.set_ylim([0, 3]), ax_1.set_yticks([]), ax_1.set_xticks([])

# 过取样
y_2 = y_1[600-250:600+250]
y_2 = np.tile(y_2, 5)
x_2 = np.linspace(-6, 6, y_2.shape[0])

ax_2 = setup_axes(fig, 412)
ax_2.plot(x_2, y_2), ax_2.set_title('F(u)', loc='center', y=1.05), ax_2.set_ylim([0, 3]), ax_2.set_yticks([]), ax_2.set_xticks([])

# 临界取样
y_3 = y_1[600-200:600+200]
y_3 = np.tile(y_3, 5)
x_3 = np.linspace(-6, 6, y_3.shape[0])

ax_3 = setup_axes(fig, 413)
ax_3.plot(x_3, y_3), ax_3.set_title('F(u)', loc='center', y=1.05), ax_3.set_ylim([0, 3]), ax_3.set_yticks([]), ax_3.set_xticks([])

# 欠取样
y_4 = y_1[600-200:600+200]
y_4 = np.where(y_4 > 1, y_4, 1)
y_4 = np.where(y_4 > -1, y_4, 1)
y_4 = np.tile(y_4, 5)
x_4 = np.linspace(-6, 6, y_4.shape[0])

ax_4 = setup_axes(fig, 414)
ax_4.plot(x_4, y_4), ax_4.set_title('F(u)', loc='center', y=1.05), ax_4.set_ylim([0, 3]), ax_4.set_yticks([]), ax_4.set_xticks([])

plt.tight_layout()
plt.show()

在这里插入图片描述

取样定理

  • 带限函数

    • 对于以原点为中心的有限区间(带宽) [ − μ m a x , μ m a x ] [-\mu_{max}, \mu_{max}] [μmax,μmax]外的频率值,傅里叶变换为零的函数
  • 奈奎斯特定理

    • 如果以超过函数最高频率2倍的取样率来得到样本,那么连续带限函数就能够完全由其样本集复原

1 Δ T > 2 μ m a x (4.32) \frac{1}{\Delta T} > 2 \mu_{max} \tag{4.32} ΔT1>2μmax(4.32)

  • 低通滤波器
    H μ = { Δ T , − μ m a x ≤ μ ≤ μ m a x 0 , others (4.33) H{\mu} = \begin{cases} \Delta T, & -\mu_{max} \leq \mu \leq \mu_{max} \\0, & \text{others} \end{cases} \tag{4.33} Hμ={ΔT,0,μmaxμμmaxothers(4.33)

  • 滤波器乘以傅里叶变换后的函数
    F ( μ ) = H ( μ ) F ~ ( μ ) (4.34) F(\mu) = H(\mu)\tilde F(\mu) \tag{4.34} F(μ)=H(μ)F~(μ)(4.34)

  • 傅里叶反变换复原 f ( t ) f(t) f(t):
    f ( t ) = ∫ − ∞ ∞ F ( μ ) e j 2 π μ t d μ (4.35) f(t) = \int_{-\infty}^{\infty} F(\mu) e^{j2\pi\mu t} d\mu \tag{4.35} f(t)=F(μ)ej2πμtdμ(4.35)

# 采样、滤波
x = np.arange(0, 6, 0.01)
y = 2 - x
y = np.where(x <= 2, y, 0)
x_1 = np.concatenate((-x[::-1], x), axis=0)
y_1 = np.pad(y, (y.shape[0], 0), mode='reflect')

fig = plt.figure(figsize=(10, 8))

# 取样
y_2 = y_1[600-250:600+250]
y_2 = np.tile(y_2, 5)
x_2 = np.linspace(-6, 6, y_2.shape[0])

# 带限函数的傅里叶变换
ax_1 = setup_axes(fig, 311)
ax_1.plot(x_2, y_2), ax_1.set_title(r'\tilde F(u)', loc='center', y=1.05), ax_1.set_ylim([0, 3]), ax_1.set_yticks([]), ax_1.set_xticks([])

x_1 = np.linspace(-6, 6, y_2.shape[0])
y_3 = np.where(x_1, x_1 >= -1, 0)
y_3 = np.where(x_1 <= 1, y_3, 0)

ax_3 = setup_axes(fig, 312)
ax_3.plot(x_1, y_3), ax_3.set_title('H(u)', loc='center', y=1.05), ax_3.set_ylim([0, 3]), ax_3.set_yticks([]), ax_3.set_xticks([])

# 滤波
y_4 = y_2 * y_3

ax_4 = setup_axes(fig, 313)
ax_4.plot(x_1, y_4), ax_4.set_title(r'F(u) = H(u)\tilde F(u)', loc='center', y=1.05), ax_4.set_ylim([0, 3]), ax_4.set_yticks([]), ax_4.set_xticks([])

plt.tight_layout()
plt.show()

在这里插入图片描述

混叠

在信号处理领域,混叠是指取样后不同信号变得彼此无法区分的取样现象,或者一个信号“伪装”成另一个信号的现象。

这种称为混叠对, 这种混叠对在取样后是无法区分的。出现这种函数混叠的原因是我们所用的取样率太粗,也就是说欠取样

带限函数的取样率小于奈奎斯特率的话,不管使用何种滤波器器,都不可能分离出来一个周期。也就不可能完美的复原函数。

# 混叠
x = np.arange(0, 6*np.pi, 0.1)

y_1 = 2 - np.sin(4 * x)
y_2 = 2 - np.sin(x)

sample_1_f = 21
sample_2_f = 21
sample_1 = y_1[::sample_1_f]
sample_2 = y_2[::sample_2_f]
fig = plt.figure(figsize=(14, 8))
plt.subplot(2, 2, 1), plt.plot(x, y_1), plt.xticks([]), plt.yticks([])
plt.subplot(2, 2, 3), plt.plot(x, y_2), plt.xticks([]), plt.yticks([])

plt.subplot(2, 2, 2), plt.stem(x[::sample_1_f], sample_1, linefmt='--', markerfmt='o', basefmt='C0-')
plt.xticks([]), plt.yticks([])
plt.subplot(2, 2, 4), plt.stem(x[::sample_2_f], sample_2, linefmt='--', markerfmt='o', basefmt='C0-')
plt.xticks([]), plt.yticks([])
plt.tight_layout()
plt.show()

在这里插入图片描述

由取样后的数据重建(复原)函数

f ( t ) = J { F ( μ ) } = J { H ( μ ) F ~ ( μ ) } = h ( t ) ⋆ f ~ ( t ) (4.37) f(t) = \mathfrak{J} \{ F(\mu) \} = \mathfrak{J} \{ H(\mu) \tilde F(\mu) \} = h(t) \star\tilde f(t)\tag{4.37} f(t)=J{F(μ)}=J{H(μ)F~(μ)}=h(t)f~(t)(4.37)

得到空间域表达式:
f ( t ) = ∑ − ∞ ∞ f ( n Δ T ) s i n c [ ( t − n Δ T ) / Δ T ] (4.38) f(t) = \sum_{-\infty}^{\infty} f(n\Delta T) sinc[(t - n \Delta T) / \Delta T]\tag{4.38} f(t)=f(nΔT)sinc[(tnΔT)/ΔT](4.38)

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

jasneik

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值