用matlab实现基于边缘检测的图象小波阈值去噪方法

用matlab实现基于边缘检测的图象小波阈值去噪方法,第1张

Press the "Start" button to see a demonstration of

denoising tools in the Wavelet Toolbox

This demo uses Wavelet Toolbox functions

% Set signal to noise ratio and set rand seed

sqrt_snr = 3; init = 2055615866;

% Generate original signal and a noisy version adding

% a standard Gaussian white noise

[xref,x] = wnoise(3,11,sqrt_snr,init);

% Denoise noisy signal using soft heuristic SURE thresholding

% and scaled noise option, on detail coefficients obtained

% from the decomposition of x, at level 5 by sym8 wavelet

% Generate original signal and a noisy version adding

% a standard Gaussian white noise

lev = 5;

xd = wden(x,'heursure','s','one',lev,'sym8');

% Denoise noisy signal using soft SURE thresholding

xd = wden(x,'rigrsure','s','one',lev,'sym8');

% Denoise noisy signal using fixed form threshold with

% a single level estimation of noise standard deviation

xd = wden(x,'sqtwolog','s','sln',lev,'sym8');

% Denoise noisy signal using fixed minimax threshold with

% a multiple level estimation of noise standard deviation

xd = wden(x,'minimaxi','s','sln',lev,'sym8');

% If many trials are necessary, it is better to perform

% decomposition one time and threshold it many times :

% decomposition

[c,l] = wavedec(x,lev,'sym8');

% threshold the decomposition structure [c,l]

xd = wden(c,l,'minimaxi','s','sln',lev,'sym8');

% Load electrical signal and select a part

load leleccum; indx = 2600:3100;

x = leleccum(indx);

% Use wdencmp for signal de-noising

% find default values (see ddencmp)

[thr,sorh,keepapp] = ddencmp('den','wv',x);

% denoise signal using global thresholding option

xd = wdencmp('gbl',x,'db3',2,thr,sorh,keepapp);

% Some trial examples without commands counterpart

% Rand initialization: init = 2055615866;

% Square root of signal to noise ratio: sqrt_snr = 5;

% [xref,x] = wnoise(1,11,sqrt_snr,init);

% Some trial examples without commands counterpart (more)

% Rand initialization: init = 2055615866;

% Square root of signal to noise ratio: sqrt_snr = 4;

% [xref,x] = wnoise(2,11,sqrt_snr,init);

% Some trial examples without commands counterpart (more)

% Rand initialization: init = 2055615866;

% Square root of signal to noise ratio: sqrt_snr = 3;

% [xref,x] = wnoise(3,11,sqrt_snr,init);

% Some trial examples without commands counterpart (more)

% Rand initialization: init = 2055615866;

% Square root of signal to noise ratio: sqrt_snr = 3;

% [xref,x] = wnoise(3,11,sqrt_snr,init);

% Some trial examples without commands counterpart (more)

% Rand initialization: init = 2055615866;

% Square root of signal to noise ratio: sqrt_snr = 3;

% [xref,x] = wnoise(3,11,sqrt_snr,init);

% Some trial examples without commands counterpart (more)

% Rand initialization: init = 2055615866;

% Square root of signal to noise ratio: sqrt_snr = 3;

% [xref,x] = wnoise(3,11,sqrt_snr,init);

[thr,sorh,keepapp] = ddencmp('den','wv',x)

自动生成小波消噪阈值选取方案,

x为信号向量,'wv'表示使用小波分解,'den'表示去噪声

返回参数 thr: 阀值, sorth: 硬阀值还是软阀值

keepapp: 是否对近似分量进行阈值处理

xd = wdencmp('gbl',x,'sym4',2,thr,sorh,keepapp);

去噪,使用sym4小波, 全局门限值

其余参数来自上一句

wname = 'sym6'; lev = 5;

[c,l] = wavedec(x,lev,wname);

% Example 2: Image de-noising

% Load original image

load noiswom;

nbc = size(map,1);

% Perform a wavelet decomposition of the image

% at level 3 using coif2

wname = 'coif2'; lev = 3;

[c,s] = wavedec2(X,lev,wname);

% Estimate the noise standard deviation from the

% detail coefficients at level 1

det1 = detcoef2('compact',c,s,1);

sigma = median(abs(det1))/06745;

% Use wbmpen for selecting global threshold

% for image de-noising

alpha = 12;

thr = wbmpen(c,l,sigma,alpha)

% Use wdencmp for de-noising the image using the above

% thresholds with soft thresholding and approximation kept

keepapp = 1;

xd = wdencmp('gbl',c,s,wname,lev,thr,'s',keepapp);

% Plot original and de-noised images

figure(2)

colormap(pink(nbc));

subplot(221), image(wcodemat(X,nbc))

title('Original image')

subplot(222), image(wcodemat(xd,nbc))

title('De-noised image')

s %自己定义

%画出原始信号

subplot(221);

plot(s);

title('原始信号');

ylabel('幅值A');

%用db3小波对信号进行3层分解并提取系数

[c,l]=wavedec(s,3,'db3');

a3=appcoef(c,l,'db3',3);

d3=detcoef(c,l,3);

d2=detcoef(c,l,2);

d1=detcoef(c,l,1);

%强制消噪处理

dd3=zeros(1,length(d3));

dd2=zeros(1,length(d2));

dd1=zeros(1,length(d1));

c1=[a3 dd3 dd2 dd1];

s1=waverec(c1,l,'db3');

subplot(222);

plot(s1);

title('强制消噪信号');

%默认阈值进行消噪

%用ddencmp函数获得信号的默认阈值

[thr,sorh,keepapp]=ddencmp('den','wv',s);

s2=wdencmp('gbl',c,l,'db3',3,thr,sorh,keepapp);

subplot(223);

plot(s2);

title('默认阈值消噪');

xlabel('样本序号n');

ylabel('幅值A');

%用给定的软阈值进行消噪

softd1=wthresh(d1,'s',1465);

softd2=wthresh(d2,'s',1823);

softd3=wthresh(d3,'s',2768);

c2=[a3 softd3 softd2 softd1];

s3=waverec(c2,l,'db3');

subplot(224);

plot(s3);

title('给定软阈值消噪');

一般情况下,如果想要写到txt文本的话,你使用fprint就行;如果写到二进制文件的话,使用fwrite。当然还有个最简单的办法就是在matlab运行后,在workspace中会有相应的矩阵,你双击,之间将要的数据另存为或者是复制就行。

望采纳

以上就是关于用matlab实现基于边缘检测的图象小波阈值去噪方法全部的内容,包括:用matlab实现基于边缘检测的图象小波阈值去噪方法、急求!!!!!这个程序的完整解释,毕业答辩了,对matlab完全不懂,求帮助、matlab里面有现成的小波去噪的工具 但是我的方法是软硬阈值一起做等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zz/9282229.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-26
下一篇 2023-04-26

发表评论

登录后才能评论

评论列表(0条)

保存