问题
我想使用卷积定理对两个测量数据A和B进行反卷积。我知道在进行卷积时,应该对数据进行零填充以防止循环卷积。但是,我不确定在反卷积中是否也需要进行零填充。 问题
1.如何正确地根据卷积定理执行反卷积?
2.为什么以下示例无法正常工作? 方法
因为A和B是已测量的,所以我创建了一个示例来进一步研究。我的想法是使用
期望结果是:
我想使用卷积定理对两个测量数据A和B进行反卷积。我知道在进行卷积时,应该对数据进行零填充以防止循环卷积。但是,我不确定在反卷积中是否也需要进行零填充。 问题
1.如何正确地根据卷积定理执行反卷积?
2.为什么以下示例无法正常工作? 方法
因为A和B是已测量的,所以我创建了一个示例来进一步研究。我的想法是使用
scipy.signal.convolve
在模式same
下创建B。import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import convolve
from scipy.fftpack import next_fast_len
# A, in the description above
A = np.array([1, 1, 1, 2, 1, 1])
# The result, I want to get from the deconvolution
kernel = np.array([0, 1, 2, 1, 0, 0])
#B, in the description above
B = convolve(kernel, data, mode='same')
# Using the deconvolution theorem
f_A = np.fft.fft(A)
f_B = np.fft.fft(B)
# I know that you should use a regularization here
r = f_B / f_A
# dk should be equal to kernel
dk = np.fft.ifft(r)
dk
的结果为:
dk = array([ 2.28571429-9.25185854e-18j, 1.28571429+9.25185854e-18j,
-0.71428571-9.25185854e-18j, -0.71428571+9.25185854e-18j,
0.28571429-9.25185854e-18j, 1.28571429+9.25185854e-18j])
期望结果是:
dk = array([0, 1, 2, 1, 0, 0])
data
和con
是什么?你是不是指的是A
和B
? - undefined