资源简介
总变差去噪(Total Variation Denoising,TVD)算法,可以对振动信号进行消噪,提高信号的信噪比,是个不错的去噪方法,值得研究
代码片段和文件信息
%% Example: TV Denoising using MM
% TV denoising using an algorithm derived using majorization-minimization (MM)
% and solvers for sparse banded systems.
% See accompanying notes.
%
% Ivan Selesnick selesi@nyu.edu 2011.
% Revised 2017
%% Start
clear
printme = @(filename) print(‘-dpdf‘ sprintf(‘Example1_%s‘ filename));
%% Create data
s = load(‘blocks.txt‘); % blocks signal
y = load(‘blocks_noisy.txt‘); % noisy blocks signal
N = 256; % N : signal length
sigma = 0.5; % sigma : standard deviation of noise
figure(1)
clf
subplot(211)
plot(s)
ax = [0 N -3 6];
axis(ax)
title(‘Clean signal‘)
subplot(212)
plot(y)
axis(ax)
title(‘Noisy signal‘)
printme(‘fig1‘)
%% TV Denoising
% Run TV denoising algorithm (MM algorithm)
lam = 1.5; % lam: regularization parameter
Nit = 50; % Nit: number of iterations
[x cost] = tvd_mm(y lam Nit); % Run MM TV denoising algorithm
figure(2)
clf
subplot(211)
plot(1:Nit cost ‘.-‘)
title(‘Cost function history‘)
xlabel(‘Iteration‘)
subplot(212)
plot(x)
axis(ax)
title(‘TV denoising‘)
printme(‘fig2‘)
%% Compare two algorithms
% Compare convergence behavour of two algorithms:
% Iterative clipping and MM
[x cost] = tvd_mm(y lam Nit);
[x2cost2] = tvd_ic(y 2*lam Nit);
figure(1)
clf
plot(1:Nit cost2/2‘--‘ 1:Nit cost‘-‘)
legend(‘Iterative Clipping Algorithm‘‘Majorization-Minimization Algorithm‘)
xlabel(‘Iteration‘)
title(‘Cost function history‘)
printme(‘fig3‘)
%% Optimality condition
% Illustrate optimality condition: abs(cumsum(x-y)) <= lambda
z = cumsum(x-y) / lam;
figure(1)
clf
subplot(211)
plot(z)
xlim([0 N])
line([0 N] [1 1] ‘linestyle‘ ‘--‘)
line([0 N] -[1 1] ‘linestyle‘ ‘--‘)
ylabel(‘s(n) / \lambda‘)
title(‘s(n) = cumsum(y-x)‘);
printme(‘optim‘)
%% Optimality scatter plot
% Illustrate optimality conidition using scatter plot diagram
z = cumsum(x-y);
m = 1.2*max(abs(diff(x)));
figure(1)
clf
plot([-m 0 0 m] [-1 -1 1 1] ‘k‘ diff(x) z(1:end-1)/lam ‘or‘)
ylabel(‘cumsum(y-x) / \lambda‘)
xlabel(‘diff(x)‘)
xlim([-m m])
printme(‘optim_scatter‘)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-01-23 15:18 TVD_software\
文件 15364 2017-01-23 15:24 TVD_software\.DS_Store
目录 0 2017-01-23 15:24 __MACOSX\
目录 0 2017-01-23 15:24 __MACOSX\TVD_software\
文件 120 2017-01-23 15:24 __MACOSX\TVD_software\._.DS_Store
文件 4352 2017-01-23 14:49 TVD_software\blocks.txt
文件 4352 2017-01-23 14:49 TVD_software\blocks_noisy.txt
目录 0 2017-01-23 14:49 TVD_software\data\
文件 4352 2017-01-23 14:49 TVD_software\data\blocks.txt
文件 4352 2017-01-23 14:49 TVD_software\data\blocks_noisy.txt
文件 8768 2007-08-02 00:11 TVD_software\data\MakeSignal.m
文件 469 2017-01-23 14:49 TVD_software\data\save_blocks_signal.m
目录 0 2017-01-23 15:24 __MACOSX\TVD_software\data\
文件 171 2017-01-23 14:49 __MACOSX\TVD_software\data\._save_blocks_signal.m
文件 2161 2017-01-23 15:19 TVD_software\Example1.m
文件 171 2017-01-23 15:19 __MACOSX\TVD_software\._Example1.m
文件 5264 2017-01-23 15:19 TVD_software\Example1_fig1.pdf
文件 412 2017-01-23 15:19 __MACOSX\TVD_software\._Example1_fig1.pdf
文件 6850 2017-01-23 15:19 TVD_software\Example1_fig2.pdf
文件 412 2017-01-23 15:19 __MACOSX\TVD_software\._Example1_fig2.pdf
文件 4165 2017-01-23 15:19 TVD_software\Example1_fig3.pdf
文件 412 2017-01-23 15:19 __MACOSX\TVD_software\._Example1_fig3.pdf
文件 5080 2017-01-23 15:19 TVD_software\Example1_optim.pdf
文件 14642 2017-01-23 15:19 TVD_software\Example1_optim_scatter.pdf
目录 0 2017-01-23 15:24 TVD_software\html\
文件 6148 2017-01-23 15:24 TVD_software\html\.DS_Store
目录 0 2017-01-23 15:24 __MACOSX\TVD_software\html\
文件 120 2017-01-23 15:24 __MACOSX\TVD_software\html\._.DS_Store
文件 7981 2017-01-23 15:19 TVD_software\html\Example1.html
文件 4870 2017-01-23 15:19 TVD_software\html\Example1_01.png
文件 4024 2017-01-23 15:19 TVD_software\html\Example1_02.png
............此处省略7个文件信息
- 上一篇:三菱伺服控制案例
- 下一篇:Vehicle spy3使用教程
评论
共有 条评论