小波去噪主程序

上传人:壹****1 文档编号:477546391 上传时间:2023-08-02 格式:DOCX 页数:13 大小:21.34KB
返回 下载 相关 举报
小波去噪主程序_第1页
第1页 / 共13页
小波去噪主程序_第2页
第2页 / 共13页
小波去噪主程序_第3页
第3页 / 共13页
小波去噪主程序_第4页
第4页 / 共13页
小波去噪主程序_第5页
第5页 / 共13页
点击查看更多>>
资源描述

《小波去噪主程序》由会员分享,可在线阅读,更多相关《小波去噪主程序(13页珍藏版)》请在金锄头文库上搜索。

1、%读入图像%转换成双精度%加入高斯噪声% R通道% G通道% B通道% R通道全局阈%G通道全局% B通道全局阈小波去噪主程序%xiaoboquzao.m%对彩色图像进行去噪I = imread(菊花.png,png);X = im2double(I);类型x_noise = imnoise(X, gaussian, 0.01);%提取三个通道信息xr = x_noise(:, :, 1);xg = x_noise(:, :, 2);xb = x_noise(:, :, 3);%估计三个通道的阈值Cr, Sr = wavedec2(xr, 2, sym4);Cg, Sg = wavedec2(

2、xg, 2, sym4);Cb, Sb = wavedec2(xb, 2, sym4);thr_r = Donoho(xr);值thr_g = Donoho(xg);阈值thr_b = Donoho(xb);值%对三个通道分别进行去噪% Donoho全局阈值 软阈值公式x_soft_r = wdenoise(xr, gbl, s, thr_r, sym4, 2);x_soft_g = wdenoise(xg, gbl, s, thr_g, sym4, 2);x_soft_b = wdenoise(xb, gbl, s, thr_b, sym4, 2);% Donoho全局阈值硬阈值公式x_ha

3、rd_r = wdenoise(xr, gbl, h, thr_r, sym4, 2);x_hard_g = wdenoise(xg, gbl, h, thr_g, sym4, 2);x_hard_b = wdenoise(xb, gbl, h, thr_b, sym4, 2);% Birge-Massart策略 软阈值公式thrlvdr=thrrx_soft_lvd_r = wdenoise(xr, lvd, s, thr_lvd_r, sym4, 1);thr_lvd_g=thr_gx_soft_lvd_g = wdenoise(xg, lvd, s, thr_lvd_g, sym4, 1

4、);thrlvdb=thrbx_soft_lvd_b = wdenoise(xb, lvd, s, thr_lvd_b, sym4, 1);%半软阈值x1_r = den1(xr, sym4, 2, thr_r);x1_g = den1(xg, sym4, 2, thr_g);x1_b = den1(xb, sym4, 2, thr_b);%半软阈值+均值滤波x1_5_r = den1_5_1(xr, sym4, 2, thr_r, 0.5*thr_r);x1_5_g = den1_5_1(xg, sym4, 2, thr_g, 0.5*thr_g);x1_5_b = den1_5_1(xb,

5、 sym4, 2, thr_b, 0.5*thr_b);%自适应阈值x4_r = den4(xr, sym4, 2);x4_g = den4(xg, sym4, 2);x4_b = den4(xb, sym4, 2);%恢复去噪后的图像x_soft = cat(3, x_soft_r, x_soft_g, x_soft_b);x_hard = cat(3, x_hard_r, x_hard_g, x_hard_b);x1 = cat(3, x1_r, x1_g, x1_b);x4 = cat(3, x4_r, x4_g, x4_b);x1_5= cat(3,x1_5_r,x1_5_g,x1_5

6、_b);均值滤波%计算去噪图像与原图像峰值信噪比psnr_soft = PSNR_color(x_soft, X)% Donoho 软阈% Donoho 硬阈半软阈值自适应阈值半软阈值+psnr_hard = PSNR_color(x_hard, X)psnrl = PSNR_color(x1, X)psnr1_5 = PSNR_color(x1_5, X)psnr4 = PSNR_color(x4, X)%显示去噪后的图像figure; imshow(X);title(原图像);figure; imshow(x_noise);title(带噪声图像);figure; imshow(x_sof

7、t);title(Donoho 软阈值)figure; imshow(x_hard);title(Donoho 硬阈值);figure; imshow(x1);title(半软阈值);figure; imshow(x4);title(自适应阈值);figure; imshow(x1_5);title(半软阈值加均值滤波);半软阈值去噪方法%den1.mfunction X = den1(x, wname, n, thr)thr1 = 0.5 * thr;C, S = wavedec2(x, n, wname);%对图像进行小波分解dcoef = C( prod(S(1, :) + 1 : en

8、d);%高频部分系数ind = find( abs(dcoef) = thr1 & abs(dcoef) = thr ) + prod(S(1, :);% C(ind) = sign(C(ind) .* ( abs(C(ind) - alpha * thr );X = waverec2(C, S, wname);改进的半软阈值去噪方法%den1_5_1.mfunction X = den1_5_1(x, wname, n, thr, thrl)%对一层的重构图像进行均值值滤波% thr1 = 0.6 * thr;C, S = wavedec2(x, n, wname);%对图像进行小波分解dc

9、oef = C( prod(S(1, :) + 1 : end);% 高频部分系数ind = find( abs(dcoef) = thr1 & abs(dcoef) = thr ) + prod(S(1, :);% 大于 thr 的系数% C(ind) = sign(C(ind) .* ( abs(C(ind) - alpha * thr );%重构至第1层A1 = wrcoef2(a, C, S, wname, 1);H1 = wrcoef2(h, C, S, wname, 1);V1 = wrcoef2(v, C, S, wname, 1);D1 = wrcoef2(d, C, S, w

10、name, 1);%对三个子图像进行均值滤波h_fir = 1 1 1 1 1 / 5;% 水平方%垂直方向滤波器v_fir = 1 1 1 1 1 / 5;向滤波器d_fir = 0 0 1 0 0; 0 0 1 0 0; 1 1 1 1 1; 0 0 1 0 0; 0 0 1 0 0 / 9;% 对角线方向滤波器H1 = filter2(h_fir, H1);V1 = filter2(v_fir, V1);D1 = filter2(d_fir, D1);%中值% H1 = medfilt2(H1, 3 3);% V1 = medfilt2(V1, 3 3);% D1 = medfilt2(

11、D1, 3 3);%重构图像X = A1 + H1 + V1 + D1;自适应阈值去噪方法%den4.mfunction X = den4(x, wname, n)% Feature Adaptive Wavelet Shrinkage for Image Denoising%初始化参数值R = 5;%窗口大小alpha= 0.1;%控制小波系数缩减的程度beta= 0.3;delta= DELTA(x);% 噪方差alambda2 = 4 * deltaA2 * log(R);%局部阈值入a2C, S = wavedec2(x, n, wname);% 对图像进行小波分解%提取每层系数并进行

12、处理for i = n : -1 : 1%水平细cH = detcoef2(h, C, S, i);节系数cV = detcoef2(v, C, S, i);% 垂直细节系数cD = detcoef2(d, C, S, i);% 对角线细节系数dim = size(cH);%分别处理三个方向的系数for j = 1 : dim(1)for k = 1 : dim(2)S_jk2 = energy(cH, j, k, R);cH(j, k) = shrink(cH(j, k), S_jk2, alpha, beta, lambda2);S_jk2 = energy(cV, j, k, R);cV(j, k) = shrink(cV(j, k), S_jk2, alpha, beta, lambda2);S_jk2 = energy(cD, j, k, R);cD(j, k) = shrink(cD(j, k), S_jk2, alpha, beta, lambda2);endend%再把系数放回去k = size(S,1) - i;first = S(1,1)*S(1,2) + 3 *

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 学术论文 > 其它学术论文

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号