Convolution & Deconvolution using Scipy

为君一笑 提交于 2019-12-11 14:37:07

问题


I am trying to compute Deconvolution using Python. I have a signal let say f(t) which is the convoluted by the window function say g(t). Is there some direct way to compute the deconvolution so I can get back the original signal?

For instance f(t) = exp(-t**2/3); Gaussian function and g(t) = Trapezoidal function

Thanks in advance for your kind suggestion.


回答1:


Is this an analytical or numerical problem?

If it's numerical, use scipy.signal.devconvolve: http://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.deconvolve.html

From the docs:

>>> from scipy import signal
>>> sig = np.array([0, 0, 0, 0, 0, 1, 1, 1, 1,])
>>> filter = np.array([1,1,0])
>>> res = signal.convolve(sig, filter)
>>> signal.deconvolve(res, filter)
(array([ 0.,  0.,  0.,  0.,  0.,  1.,  1.,  1.,  1.]),
 array([ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.]))

Otherwise, if you want an analytic solution, you might be using the wrong tool.

Additionally, just a tip for future google-ing, when you're talking about convolution, the action is usually/often "convolved" not "convoluted", see https://english.stackexchange.com/questions/64046/convolve-vs-convolute



来源:https://stackoverflow.com/questions/21990327/convolution-deconvolution-using-scipy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!