我想比较使用不同小波和分解级别的图像去噪方法的性能,但我似乎无法合并分解级别。这是我当前的代码(有效):
% Load dataset
original = imread('brain_mri_transversal_t2_001.jpg'); % original image filename
noisy = imread('mri_image_noisy.jpg'); % Load noisy image
% Apply wavelet transform
[LL, LH, HL, HH] = dwt2(noisy, 'db4');
% Define the threshold value
t = 200; % Adjust the threshold value as needed
%t = rbe*sqrt(2*log(1000)); % tuni VisuShrink
% Define the function for adaptive thresholding
function coeff_thresh = adaptive_thresholding(coeff, threshold, rbe)
if threshold == rbe
% Adaptive Hard Thresholding for t = rbe
coeff_thresh = zeros(size(coeff));
coeff_thresh(coeff < -threshold) = coeff(coeff < -threshold);
coeff_thresh(abs(coeff) <= threshold) = ...
rbe*(exp((-coeff(abs(coeff) <= threshold).^2)/(2*(rbe^2))-1/2)) - rbe*(exp((-0)/(2*(rbe^2))-1/2));
coeff_thresh(coeff > threshold) = coeff(coeff > threshold);
elseif threshold > rbe
% IMPROVED AGGD for t > rbe
coeff_thresh = zeros(size(coeff));
coeff_thresh(coeff < -threshold) = coeff(coeff < -threshold).*(1./(1+exp(coeff(coeff < -threshold)+threshold))-threshold/2);
coeff_thresh(abs(coeff) <= threshold) = ...
rbe*(exp((-coeff(abs(coeff) <= threshold).^2)/(2*(rbe^2))-1/2)) - rbe*(exp((-0)/(2*(rbe^2))-1/2));
coeff_thresh(coeff > threshold) = coeff(coeff > threshold).*(1./(1+exp(coeff(coeff > threshold)+threshold))+threshold/2);
end
end
% Robust median estimator
rbe = median(abs(HH(:)))/0.6745;
% Threshold the wavelet coefficients
HH_thresh = adaptive_thresholding(HH, t, rbe);
LH_thresh = adaptive_thresholding(LH, t, rbe);
HL_thresh = adaptive_thresholding(HL, t, rbe);
% Inverse wavelet transform
reconstructed = idwt2(LL, LH_thresh, HL_thresh, HH_thresh, 'db4');
我尝试使用wavedec2和waverec2,但我总是收到一些关于输入/输出参数太多、输入参数不足等错误。