Python Pywavelet 小波阈值实例
小波应用比较广泛,近期想使用其去噪。由于网上都是matlib实现,故记下一下Python的使用
Pywavelet Denoising小波去噪
#-*-coding:utf-8-*- importnumpyasnp importpywt data=np.linspace(1,4,7) #pywt.threshold方法讲解: #pywt.threshold(data,value,mode='soft',substitute=0) #data:数据集,value:阈值,mode:比较模式默认soft,substitute:替代值,默认0,float类型 #data:[1.1.52.2.53.3.54.] #output:[6.6.0.0.51.1.52.] #soft因为data中1小于2,所以使用6替换,因为data中第二个1.5小于2也被替换,2不小于2所以使用当前值减去2,,2.5大于2,所以2.5-2=0.5..... print"---------------------soft:绝对值-------------------------" printpywt.threshold(data,2,'soft',6) print"---------------------hard:绝对值-------------------------" #data:[1.1.52.2.53.3.54.] #harddata中绝对值小于阈值2的替换为6,大于2的不替换 printpywt.threshold(data,2,'hard',6) print"---------------------greater-------------------------" #data:[1.1.52.2.53.3.54.] #data中数值小于阈值的替换为6,大于等于的不替换 printpywt.threshold(data,2,'greater',6) print"---------------------less-------------------------" printdata #data:[1.1.52.2.53.3.54.] #data中数值大于阈值的,替换为6 printpywt.threshold(data,2,'less',6)
参考官方文档地址:https://pywavelets.readthedocs.io/en/latest/ref/thresholding-functions.html#pywt.threshold
以上这篇PythonPywavelet小波阈值实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。