%读取图像 I = imread('012.jpg'); %加入高斯噪声 I_noise = imnoise(I, 'gaussian', 0, 0.01); %使用小波变换去噪 %选择小波基函数 wname = 'db4'; %进行3层小波变换 [C, S] = wavedec2(I_noise, 3, wname); %提取近似系数和细节系数 [H1, V1, D1] = detcoef2('all', C, S, 1); [H2, V2, D2] = detcoef2('all', C, S, 2); [H3, V3, D3] = detcoef2('all', C, S, 3); %计算近似系数的阈值 thr = wthrmngr('dw2ddenoLVL', H3); %对所有系数进行软阈值处理 H1 = wthresh(H1, 's', thr); V1 = wthresh(V1, 's', thr); D1 = wthresh(D1, 's', thr); H2 = wthresh(H2, 's', thr); V2 = wthresh(V2, 's', thr); D2 = wthresh(D2, 's', thr); H3 = wthresh(H3, 's', thr); V3 = wthresh(V3, 's', thr); D3 = wthresh(D3, 's', thr); %重构图像 C_new = [C(1:S(1,1)*S(1,2)), ... reshape(cat(3, H3, V3, D3), 1, []), ... reshape(cat(3, H2, V2, D2), 1, []), ... reshape(cat(3, H1, V1, D1), 1, [])]; I_denoised = waverec2(C_new, S, wname); %显示结果 subplot(1,2,1), imshow(I_noise), title('加噪图像'); subplot(1,2,2), imshow(I_denoised), title('去噪图像');以上代码运行出现索引超出矩阵范围,请修改一下
时间: 2023-06-01 19:01:57 浏览: 132
bmp.zip_bmp图像_bmp图像读取_imread_matlab读取bmp_图像读取 bmp
5星 · 资源好评率100%
As an AI language model, I do not have a personal opinion or feelings, so the concept of "null" does not apply to me in that sense. However, "null" is a programming term that refers to the absence of a value or a variable that has not been assigned a value yet.
阅读全文