日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

离散小波变换 python_CDF 9/7离散小波变换(卷积)

發布時間:2025/3/20 python 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 离散小波变换 python_CDF 9/7离散小波变换(卷积) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

實際上,我自己解決了這個問題,通過比較系數,然后重建,與這個提升實現的代碼:

基本上,我

1) 使邊界條件對稱,而不是周期性的

2) 必須以一定的方式抵消卷積(和上采樣)以使其對齊。在

下面是代碼,以防其他人遇到問題。我覺得這仍然過于復雜化了,特別是因為它在任何地方都沒有真正的文檔記錄,但至少它是有效的。這也包括我用來對照那個參考進行測試的“開關”,我必須修改Haar小波使其工作。在import random

import math

length = int()

array = list()

row = list()

scaleCoefficients = list()

waveletCoefficients = list()

reconstruction = list()

switch = False

def upsample1(lst, index):

if (index % 2 == 0):

return lst[index/2]

else:

return 0.0

def upsample2(lst, index):

if (index % 2 == 0):

return 0.0

else:

return lst[index/2]

## Generate a random list of floating point numbers

if (not switch):

length = 128

for i in range(length):

array.append(random.random())

else:

length = 32

for i in range(32):

array.append(5.0+i+.4*i*i-.02*i*i*i)

## First Part Just Calculates the Filters

## CDF 9/7 Wavelet

DWTAnalysisLowpass = [.026749, -.016864, -.078223, .266864, .602949, .266864, -.078223, -.016864, .026749]

for i in range(len(DWTAnalysisLowpass)):

DWTAnalysisLowpass[i] = math.sqrt(2.0) * DWTAnalysisLowpass[i]

DWTAnalysisHighpass = [.091272, -.057544, -0.591272, 1.115087, -.591272, -.057544, .091272]

for i in range(len(DWTAnalysisHighpass)):

DWTAnalysisHighpass[i] = DWTAnalysisHighpass[i]/math.sqrt(2.0)

DWTSynthesisLowpass = [-.091272, -.057544, 0.591272, 1.115087, .591272, -.057544, -.091272]

for i in range(len(DWTSynthesisLowpass)):

DWTSynthesisLowpass[i] = DWTSynthesisLowpass[i]/math.sqrt(2.0)

DWTSynthesisHighpass = [.026749, .016864, -.078223, -.266864, .602949, -.266864, -.078223, .016864, .026749]

for i in range(len(DWTSynthesisHighpass)):

DWTSynthesisHighpass[i] = math.sqrt(2.0) * DWTSynthesisHighpass[i]

## Haar Wavelet

## c = 1.0/math.sqrt(2)

## DWTAnalysisLowpass = [c,c]

## DWTAnalysisHighpass = [c, -c]

## DWTSynthesisLowpass = [-c, c]

## DWTSynthesisHighpass = [c, c]

# Do the forward transform. We can skip every other sample since they would

# be removed in the downsampling anyway

for i in range(0,length,2):

newVal = 0.0

## Convolve the next j elements by the low-pass analysis filter

for j in range(len(DWTAnalysisLowpass)):

index = i + j - len(DWTAnalysisLowpass)/2

if(index >= length):

index = 2*length - index - 2

elif (index < 0):

index = -index

newVal = newVal + array[index]*DWTAnalysisLowpass[j]

# append the new value to the list of scale coefficients

scaleCoefficients.append(newVal)

newVal = 0.0

# Convolve the next j elements by the high-pass analysis filter

for j in range(len(DWTAnalysisHighpass)):

index = i + j - len(DWTAnalysisHighpass)/2 + 1

if(index >= length):

index = 2*length - index - 2

elif (index < 0):

index = -index

newVal = newVal + array[index]*DWTAnalysisHighpass[j]

# append the new value to the list of wavelet coefficients

waveletCoefficients.append(newVal)

# Do the inverse transform

for i in range(length):

newVal = 0.0

# convolve the upsampled wavelet coefficients with the high-pass synthesis filter

for j in range(len(DWTSynthesisHighpass)):

index = i + j - len(DWTSynthesisHighpass)/2

if(index >= length):

index = 2*length - index - 2

elif (index < 0):

index = -index

newVal = newVal + upsample2(waveletCoefficients, index)*DWTSynthesisHighpass[j]

# convolve the upsampled scale coefficients with the low-pass synthesis filter, and

# add it to the previous convolution

for j in range(len(DWTSynthesisLowpass)):

index = i + j - len(DWTSynthesisLowpass)/2

if(index >= length):

index = 2*length - index - 2

elif (index < 0):

index = -index

newVal = newVal + upsample1(scaleCoefficients, index)*DWTSynthesisLowpass[j]

reconstruction.append(newVal)

print ("Sums: ")

print sum(reconstruction)

print sum(array)

print ("Original Signal: ")

print array

if (not switch):

print ("Wavelet Coefficients: ")

for i in range(len(scaleCoefficients)):

print ("sc[" + str(i) + "]: " + str(scaleCoefficients[i]))

for i in range(len(waveletCoefficients)):

print ("wc[" + str(i) + "]: " + str(waveletCoefficients[i]))

print ("Reconstruction: ")

print reconstruction

總結

以上是生活随笔為你收集整理的离散小波变换 python_CDF 9/7离散小波变换(卷积)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。