Coiflet小波

Coiflet小波是英格麗·多貝西應羅納德·科夫曼的要求所設計的一種離散小波。Coiflet小波的調整函式（scaling function）及小波函式（wavelet function）能同時擁有高消失動量，且其波形接近對稱，常被用於數位訊號處理。 定義 一個正交小波（orthogonal wavelet）系統若符合以下條件，則稱為Generalized Coiflet Wavelet(GOC)。 M ψ ~ ( 0 , l ] = 0 for  l  =0,1,...,L-1 M ϕ ~ ( t 0 , l ] = δ [ l ] for  l  =0,1,...,L-1 {\displaystyle {\begin{array}{lcl}\\{\mathcal {M_{\tilde {\psi }}}}(0,l]=0&{\mbox{for }}l{\mbox{ =0,1,...,L-1}}\\{\mathcal {M_{\tilde {\phi }}}}(t_{0},l]=\delta [l]&{\mbox{for }}l{\mbox{ =0,1,...,L-1}}\\\end{array}}} 其中 ψ {\displaystyle {\psi }} 為小波函式， ϕ {\displaystyle {\phi }} 為調整函式 濾波器長度與消失動量 若 N {\displaystyle N} 為濾波器長度，而 L {\displaystyle L} 為系統消失動量，則最小的 N {\displaystyle N} 為： N = { 3 L − 1 , if  L  is odd 3 L , if  L  is even {\displaystyle N={\begin{cases}3L-1,&{\mbox{if }}L{\mbox{ is odd}}\\3L,&{\mbox{if }}L{\mbox{ is even}}\\\end{cases}}} 近線性相位（Near-linear phase）濾波器 當 | w | {\displaystyle |w|} 夠小時，GOC的低通濾波器的頻率響應擁有漸進型態（asymptotic form）： ∠ H ( w ) = − t 0 w + C ⋅ w L ′ + O ( w L ′ + 2 ) {\displaystyle \angle {H(w)}=-t_{0}w+C\cdot {w^{L'}}+O(w^{L'+2})} 其中 L ′ = 2 ⌊ L / 2 ⌋ + 1 {\displaystyle L'=2\left\lfloor L/2\right\rfloor +1} ， C {\displaystyle C} 則為常數項。因此 h {\displaystyle h} 具有漸近線性相位（asymptotic linear phase）的特性： lim L → ∞ ∠ H ( w ) = − t 0 w {\displaystyle \lim _{L\to \infty }\angle {H(w)}=-t_{0}w} Coiflet小波除了被使用在影像壓縮外，目前也有被使用在電力系統訊號監測上 下表為coiflet小波調整函式C6~30的係數，小波函式的係數可以藉由每兩個係數變換一次符號來推導(例如C6 wavelet = {−0.022140543057, 0.102859456942, 0.544281086116, −1.205718913884, 0.477859456942, 0.102859456942}) 這邊列出6, 12 ,18點的filter消失點(vanish moment)也就是k/6。 這邊的g是低頻的濾波器，h是高頻的濾波器。 可以看出 h [ n ] = ( − 1 ) n g [ − n ] {\displaystyle h[n]=(-1)^{n}g[-n]} ，這邊採用python的語法，h會是g的反序，且n為奇數時要乘上-1 F = coifwavf(W)會回傳N=str2num(W)的coiflet小波的調整函式，其中N只能為1~5的整數。 這邊根據上面所提供的高頻和低頻的濾波器去實作出離散小波轉換並且應用到影像壓縮上面， 透過小波轉換良好的性質，嘗試實作出連續的影像壓縮。 這邊單純是在示範小波轉換進行多次壓縮和反壓縮的結果， 如果不想轉換這麼多次修改Jmax即可。 import numpy as np def subsampling(x, d): if d == 1: y = x[::2, :] elif d == 2: y = x[:, ::2] return y def upsampling(x, d): s = x.shape if d == 1: y = np.zeros((p * s[0], s[1])) y[::2, :] = x elif d == 2: y = np.zeros((s[0], p * s[1])) y[:, ::2] = x return y def cconv(x, h, d): if d == 2: return np.transpose(cconv(np.transpose(x), h, 1)) y = np.zeros(x.shape) p = len(h) pc = int(round( float((p - 1) / 2 ))) for i in range(0, p): y = y + h[i] * np.roll(x, i - pc, axis=0) return y def DWT_compression(image, h, g): # discrete wavelet transformation Jmin = 0 Jmax = log2(n)-1 fW = image.copy() j = int(np.log2(image.shape[0])-1) A = fW[:2**(j+1):,:2**(j+1):] for j in arange(Jmax,Jmin-1,-1): A = fW[:2**(j+1):,:2**(j+1):] for d in arange(1,3): Coarse = subsampling(cconv(A,h,d),d) Detail = subsampling(cconv(A,g,d),d) A = concatenate( (Coarse, Detail), axis=d-1 ) fW[:2**(j+1):,:2**(j+1):] = A j1 = Jmax-j return fW def iDWT_decompression(image, fW, h, g): #image is original, fW is after DWT of that. Jmin = 0 Jmax = int(np.log2(image.shape[0])-1) f1 = fW.copy() j = int(np.log2(image.shape[0])-1) A = f1[:2**(j+1):,:2**(j+1):] h1 = h[::-1] g1 = g[::-1] for j in arange(Jmin,Jmax+1): A = f1[:2**(j+1):,:2**(j+1):] for d in arange(1,3): if d==1: Coarse = A[:2**j:,:] Detail = A[2**j:2**(j+1):,:] else: Coarse = A[:,:2**j:] Detail = A[:,2**j:2**(j+1):] Coarse = cconv(upsampling(Coarse,d),h1,d) Detail = cconv(upsampling(Detail,d),g1,d) A = Coarse + Detail j1 = Jmax-j if j1>0 and j1<5: imageplot(A, 'j=' + str(int(j)), [2,2,j1]) f1[:2**(j+1):,:2**(j+1):] = A return f1 定義 一個order為 ( L , L ~ ) {\displaystyle (L,{\tilde {L}})} 的雙正交Coiflet小波需符合以下條件： M ϕ ~ ( 0 , l ] = δ [ l ] for  l  =0,1,...,L-1 M ψ ~ ( 0 , l ] = 0 for  l  =0,1,...,L-1 M ϕ ( 0 , l ] = δ [ l ] for  l  =0,1,...,L-1 M ψ ( 0 , l ] = 0 for  l  =0,1,..., L ~ -1 {\displaystyle {\begin{array}{lcl}\\{\mathcal {M_{\tilde {\phi }}}}(0,l]=\delta [l]&{\mbox{for }}l{\mbox{ =0,1,...,L-1}}\\{\mathcal {M_{\tilde {\psi }}}}(0,l]=0&{\mbox{for }}l{\mbox{ =0,1,...,L-1}}\\{\mathcal {M_{\phi }}}(0,l]=\delta [l]&{\mbox{for }}l{\mbox{ =0,1,...,L-1}}\\{\mathcal {M_{\psi }}}(0,l]=0&{\mbox{for }}l{\mbox{ =0,1,...,}}{\tilde {L}}{\mbox{-1}}\\\end{array}}} 性質 當 L {\displaystyle L} 為偶數時， h {\displaystyle h} 會對稱於原點： h [ n ] = h [ − n ] {\displaystyle h[n]=h[-n]} 。這讓雙正交coiflet在圖片壓縮方面能有較好的峰值信噪比（PSNR）。 COIFLET-TYPE WAVELETS: THEORY, DESIGN, AND APPLICATIONS (PDF). [2016-01-25]. （原始内容 (PDF)存档于2016-03-05）.  Coiflet wavelet transform applied to inspect power system disturbance-generated signals. Shyh-Jier Huang, and Cheng-Tao Hsieh. 2002.  缺少或|url=为空 (帮助) coifwavf. http://www.mathworks.com/. [22 January 2015]. （原始内容存档于2016-05-22）.