离散小波变换 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离散小波变换(卷积)相关推荐
- 小波滤波器与其他滤波器的区别_小波变换(六):小波变换在机器学习中的应用(上)...
本文讲解一篇关于小波变换在机器学习中的应用的博客:<A guide for using the Wavelet Transform in Machine Learning>,极力推荐!!目 ...
- MATLAB离散傅里叶变换实验结果分析,Matlab离散傅里叶变换实验报告
Matlab离散傅里叶变换实验报告 班级 信工082 学号 16 姓名 刘刚 实验组别 实验日期 室温 报告日期 成绩 报告内容:(目的和要求,原理,步骤,数据,计算,小结等) 实验三 离散傅立叶变换 ...
- MATLAB离散傅里叶变换实验结果分析,Matlab离散傅里叶变换实验报告.doc
班级 信工082 学号 16 姓名 刘刚 实验组别 实验日期 室温 报告日期 成绩 报告内容:(目的和要求,原理,步骤,数据,计算,小结等) 实验三 离散傅立叶变换(DFT) 1.离散傅立叶级数 给定 ...
- 小波变换网文精粹:小波变换教程(五)
小波变换网文精粹:小波变换教程(五) 原文:ROBI POLIKAR. THE ENGINEER'S ULTIMATE GUIDE TO WAVELET ANALYSIS:The Wavelet Tu ...
- Java 离散小波变换公式_一维离散小波变换函数使用总结
前言 matlab自带的小波分析工具非常全!实际工作中直接用即可.但是刚开始使用会遇到挫折:它的函数太多,并且它们的"名称.功能.配套使用"等要求都有些"相近" ...
- matlab小波变换数据少,一维离散数据小波变换实用案例
前言 小波变换专业处理时变信号!其重要用途包含:突变点检测.时频分析.信号降噪等.本文将详细介绍小波变换的这3种主要用途,借助具体例子来说明并总结相关函数的使用. 间断点检测 现实信号中的间断点是较为 ...
- 机器学习中val_小波变换(七):小波变换在机器学习中的应用(下)
本文继续讲解一篇关于小波变换在机器学习中的应用的博客:<A guide for using the Wavelet Transform in Machine Learning>,极力推荐! ...
- 小波变换c语言程序包,小波变换VC6.0程序实现
摘要:随着小波研究的深入,小波变换的应用范围越来越广泛,但是一般的研究.工作中只是使用Matlab的小波工具包来编程.该文使用VC++6.0设计实现基于小波变换的数字图像处理软件模块,编写具体实现程序 ...
- 小波变换的matlab实现,维小波变换MATLAB实现
<维小波变换MATLAB实现>由会员分享,可在线阅读,更多相关<维小波变换MATLAB实现(15页珍藏版)>请在人人文库网上搜索. 1.二维小波变换MATLAB实现,dwt2函 ...
最新文章
- Altium Designer飞线(未连接线)不显示的解决方法
- redis springmvc mysql_SpringMVC + MyBatis + Mysql + Redis(作为二级缓存) 配置
- Python练习题:如何将多个小字符串拼接成一个大的字符串
- UOJ #164 【清华集训2015】V (线段树)
- 某电力企业数据备份方案解析
- 文件上传优化CommonsMultipartResolver
- 为什么大公司一定要使用DevOps
- vue的Prop属性
- hdu 2007 - 平方和与立方和
- Spring学习总结(2)- AOP
- 向上传递 java_Java向上转型向下转型
- 获取网页html内容
- 光立方,动手搭——原理简述
- 国外调查问卷怎么做?
- 玩转opencv之有趣的调色板
- 树形DP(Simple Tree,玲珑杯 Round#8 B lonlife 1080)
- HDUOJ 5651 xiaoxin juju needs help
- HCIP考试-华为证书安全方向已取得
- 【毕业设计_课程设计】基于协同过滤算法的个性化推荐系统(源码+论文)
- org.hibernate.SessionException: Session was already closed
热门文章
- zTree菜单的排序
- easyUI的引用顺序
- swift 组件化_打造完备的iOS组件化方案:如何面向接口进行模块解耦?
- python两数相加代码_一边学编程,一边学语数外,用python编程全排列10以内两数加法...
- 有了这篇你还说你不会redis性能优化、内存分析及优化
- Java如何实现二维码?【附源码】
- Java异常类(Throwable)
- linux 关闭权限验证,Linux 账户安全与控制
- java78条注意事项
- 于计算机交朋友教案,三年级上册信息技术教案-2与计算机交朋友|人教版 (2)