wavelet denoising of signal

2 views (last 30 days)
MANINDER CHOUDHARY
MANINDER CHOUDHARY on 21 May 2022
Commented: Voss on 22 May 2022
for i=1:21;
j=1:21;
C(i) = wdenoise(C,j, ...
Wavelet='sym1', ...
DenoisingMethod='Bayes', ...
ThresholdRule='Hard', ...
NoiseEstimate='LevelIndependent');
I want to denoise my signal but before that I want to check multiple denoising methods for my data. Can you please suggest how can I change value of each wavelet & denoising method, threshold rule etc using loop. So that after each loop it store denoised signal in an array Thanks
end

Accepted Answer

Voss
Voss on 21 May 2022
Alternatively, something like this may be similar to what you had in mind:
C = randn(1,100);
methods = ["Bayes" "BlockJS" "FDR" "Minimax" "SURE" "UniversalThreshold"];
rules = ["James-Stein" "Soft" "Hard" "Median" "Mean"];
levels = 1:floor(log2(numel(C)));
n_methods = numel(methods);
n_rules = numel(rules);
n_levels = numel(levels);
result = cell(n_methods,n_rules,n_levels);
for jj = 1:n_methods
switch methods(jj)
case "Bayes"
valid_rules = ["Median" "Mean" "Soft" "Hard"];
case "BlockJS"
valid_rules = "James-Stein";
case "FDR"
valid_rules = "Hard";
otherwise
valid_rules = ["Soft" "Hard"];
end
[~,rules_idx] = ismember(valid_rules,rules);
for kk = 1:numel(rules_idx)
for ii = 1:n_levels
try
result{jj,rules_idx(kk),ii} = wdenoise(C,levels(ii), ...
Wavelet='sym1', ...
DenoisingMethod=methods(jj), ...
ThresholdRule=rules(rules_idx(kk)), ...
NoiseEstimate='LevelIndependent');
catch e
msg = sprintf('Unable to wdenoise with method %s, rule %s, level %d:\n%s', ...
methods(jj),rules(rules_idx(kk)),levels(ii),e.message);
disp(msg);
end
end
end
end
Unable to wdenoise with method BlockJS, rule James-Stein, level 6: For block thresholding, the level of the wavelet transform must be less than or equal to 5.
for jj = 1:n_methods
figure()
t = tiledlayout(n_levels,n_rules,'TileSpacing','none');
t.Title.String = sprintf('Method: %s',methods(jj));
t.YLabel.String = 'Level:';
t.Subtitle.String = 'ThresholdRule:';
for ii = 1:n_levels
for kk = 1:n_rules
nexttile();
box on
hold on
if ii == 1
title(rules(kk));
end
if kk == 1
ylabel(sprintf('%d',levels(ii)));
end
if ~isempty(result{jj,kk,ii})
plot(C)
plot(result{jj,kk,ii})
end
xticklabels([])
yticklabels([])
end
end
end
  2 Comments
MANINDER CHOUDHARY
MANINDER CHOUDHARY on 22 May 2022
Thank you very much. It works (Y)
Voss
Voss on 22 May 2022
You're welcome!

Sign in to comment.

More Answers (0)

Categories

Find more on Denoising and Compression in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!