# 希尔伯特变换

Hilbert 变换能在振幅保持不变的情况下将输入信号的相角偏移 90 度，简单地说就是能够将正弦波形转换为余弦波形：

Hilbert 转换函数在 scipy.fftpack 函数库中，它的调用格式如下：
``````form scipy import fftpack
fftpack.hilbert(x)
``````

# 包络检波

Hilbert 变换可以用作包络检波。具体算法如下：

``````# original singal
sampling_rate = 51200
fft_size = 51200
t = np.arange(0,1.0,1.0/sampling_rate)
ts = np.array(map(lambda x : x*1000, t))
x = np.sin(2*np.pi*1e3*t) + 0.1 * np.sin(2*np.pi*980*t) + 0.10 * np.sin(2*np.pi*1020*t)+ 0.01 * np.sin(2*np.pi*960*t) + 0.01 * np.sin(2*np.pi*1040*t)
xn = x + 0.005*np.random.normal(0.0,1.0,len(x))
# envelop detecting
hx = fftpack.hilbert(x)
hy = np.sqrt(x**2+hx**2)
``````

# 检波性能分析

``````# parameters of filter
a = np.array([1.0, -1.947463016918843, 0.9555873701383931])
b = np.array([0.9833716591860479, -1.947463016918843, 0.9722157109523452])
# chirp signal
t = np.arange(0, 0.5, 1/44100.0)
x= signal.chirp(t, f0=10, t1 = 0.5, f1=1000.0)
# the chirp signal through the filter
y = signal.lfilter(b, a, x)
# hilbert transform
hy = fftpack.hilbert(y)
``````

# 去包络算法

``````y = (2*x-hy)/hy*0.5 + 0.5
``````

# 去包络算法性能分析

Stay hungry, Stay foolish.