我使用return ResponseEntity
.ok()
.contentType(MediaType.IMAGE_GIF);
小波对噪声信号进行了多级小波分解,并获得了近似系数和详细系数。对于使用db8
的阈值计算,我获得了硬阈值的阈值,并将此阈值应用于小波系数。最后,我使用universal threshold formula
使用新系数重建原始信号。
waverec
我收到一个错误,该错误期望clear all
close all
clc
[x,Fs] = audioread('audio8.wav'); %Read cough sound
sound(x,Fs)
figure
plot(x(1:end,1))
grid on
title('Original Cough Sound')
xlabel('Frequency (Hz)')
ylabel('Amplitude')
x = x/abs(max(x)); %Normalization of Cough Sound
normalized_snr = snr(x,Fs); %SNR of Normalized Cough Sound
figure
plot(x)
grid on
title('Normalized Cough Sound')
xlabel('Frequency (Hz)')
ylabel('Amplitude')
gauss_noise = awgn(x,20,'measured'); %Adding White Gaussian Noise
sound(gauss_noise,Fs)
noisy_snr = snr(gauss_noise,Fs); %SNR of Noisy Cough Sound
figure
plot(gauss_noise)
grid on
title('Noisy Cough Sound')
xlabel('Frequency (Hz)')
ylabel('Amplitude')
len = length(gauss_noise);
disp(len)
level = fix(log2(len));
disp(level)
wn = 'db8';
[c,l] = wavedec(gauss_noise,level,wn);
%calculate threshold
sigma = median(abs(c))/0.6745;
thresh = sqrt(2*log(length(gauss_noise)))*sigma;
disp(thresh)
for i = 1:level
det = detcoef(c,l,i);
y_det_hard = wthresh(det,'h',thresh);
figure
plot(y_det_hard)
grid on
end
for j = 1:level
app = appcoef(c,l,'db8',j);
% y_app_hard = wthresh(app,'h',thresh);
figure
plot(app)
grid on
end
app_last = appcoef(c,l,'db8',level);
app_last_hard = wthresh(app_last,'h',thresh);
disp(app_last_hard)
figure
plot(app_last_hard)
grid on
new_coeff = [app_last_hard + y_det_hard];
len2 = length(new_coeff);
y_rec = waverec(new_coeff,len2,'db8'); %Perform wavelet reconstruction on new coefficients after thresholding
figure
plot(y_rec)
grid on
是值为N
的标量。我是否以正确的方式将阈值应用于小波系数?为什么我无法重建信号?