Get filter kernel from output signal?

Killertechno
Posts: 192
Joined: Wed Jan 02, 2013 8:28 am

Get filter kernel from output signal?

Hi to all, I was taking a look to this convolution example:

Code: Select all

``````import numpy as np
import scipy.signal
import matplotlib
import matplotlib.pyplot as plt
import sys
matplotlib.use('TkAgg')

# test convolve

kernel = [0.5, 0.45, 0.05,  0]
input_signal = [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0]
filtered_signal = np.convolve(kernel , input_signal)

plt.title("kernel")
plt.plot(kernel)
plt.show()

plt.subplot(211)
plt.title("input signal")
plt.plot(input_signal)
plt.subplot(212)
plt.title("output signal")
plt.plot(filtered_signal)
plt.show()``````

Now.... is there a way I can get kernel from input_signal and filtered_signal?
Thanks.

Posts: 2461
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Get filter kernel from output signal?

I think that it's possible because it acts linearly so 'just' a matter of solving simultaneous equations. Things that would make it difficult would be a) knowing the size of the kernel b) edge behavior, which is related to a. as the default edge behavior would tell you the size of the kernel. c) lack of info such as input and output being all zero.

You could re-arrange your signal, kernel and output as a system of equations and use https://docs.scipy.org/doc/numpy/refere ... solve.html Possibly working your way along the array until to got to a soluble section.

i.e. for you it might be something like

Code: Select all

``````k0*i8 + k1*i7 + k2*i6 + k3*i5 = o8
k0*i9 + k1*i8 + k2*i7 + k3*i6 = o9
k0*i10 + k1*i9 + k2*i8 + k3*i7 = o10
k0*i11 + k1*i10 + k2*i9 + k3*i8 = o11``````
where k0,k1 etc are the unknowns x in the example