denoise0615.m
上传用户:lcj80317
上传日期:2007-01-26
资源大小:625k
文件大小:4k
源码类别:

波变换

开发平台:

Matlab

  1. % 所有实验结果汇总
  2. I = imread('lena.png');                                             % 读入图像
  3. X = im2double(I);                                                   % 转为双精度类型
  4. % x = noise(X, 'gaussian', 0.005);                                    % 添加噪声 高斯噪声 方差 0.005
  5. x = noise(X, 'gaussian', 0.01);                                     % 添加噪声 高斯噪声 方差 0.01
  6. % x = noise(X, 'guassian', 0.02);                                     % 高斯噪声 方差 0.02
  7. % x = noise(X, 'salt & pepper', 0.02);                                % 椒盐噪声 密度 0.02
  8. % x = noise(X, 'salt & pepper', 0.05);                                % 椒盐噪声 密度 0.05
  9. [C, S]      = wavedec2(x, 2, 'sym4');
  10. thr         = Donoho(x);                                            % 计算Donoho全局阈值
  11. thr_lvd     = Birge_Massart(C, S);                                  % 计算Bige-Massa策略阈值
  12. alpha       = 0.5;
  13. % 去噪 2层分解 sym4 小波--------------------------------------------------------
  14. x_soft      = wdenoise(x, 'gbl', 's', thr, 'sym4', 2);              % 软阈值方法 Donoho 全局阈值
  15. x_hard      = wdenoise(x, 'gbl', 'h', thr, 'sym4', 2);              % 硬阈值方法 Donoho 全局阈值
  16. x_soft_lvd  = wdenoise(x, 'lvd', 's', thr_lvd, 'sym4', 2);          % 软阈值方法 Birge-Massart策略 计算的阈值 
  17. x_hard_lvd  = wdenoise(x, 'lvd', 'h', thr_lvd, 'sym4', 2);          % 硬阈值方法 Birge-Massart策略 计算的阈值 
  18. x1          = den1(x, 'sym4', 2, thr);                              % 半软阈值 原始方法
  19. x1_5        = den1_5_1(x, 'sym4', 2, thr, 0.5*thr);                 % 半软阈值 + 均值滤波 
  20. x1_9        = den1_9(x, 'sym4', 2, thr, 0.5*thr);                   % 半软阈值 + 指数衰减
  21. x1_10       = den1_10(x, 'sym4', 2, thr, 0.5*thr);                  % 半软阈值 + 再次进行小波阈值去噪
  22. x2          = den2(x, 'sym4', 2, thr, 0.4);                         % 软硬阈值的改进方法
  23. x3          = den3(x, 'sym4', 2, thr, 5);                           % 广义小波阈值函数
  24. x4          = den4(x, 'sym4', 2);                                   % 自适应特征阈值
  25. % 计算峰值信噪比--------------------------------------------------------------
  26. psnr_soft = PSNR(x_soft, X)                                         % Donoho公式 软阈值
  27. psnr_hard = PSNR(x_hard, X)                                         % Donoho公式 硬阈值
  28. psnr_soft_lvd = PSNR(x_soft_lvd, X)                                 % Birge-Massart策略 软阈值
  29. psnr_hard_lvd = PSNR(x_hard_lvd, X)                                 % Birge-Massart策略 硬阈值
  30. psnr1 = PSNR(x1, X)                                                 % 半软阈值
  31. psnr1_5 = PSNR(x1_5, X)                                             % 半软阈值 + 均值滤波
  32. psnr1_9 = PSNR(x1_9, X)                                             % 半软阈值  指数衰减
  33. psnr1_10 = PSNR(x1_10, X)                                           % 半软阈值 再次进行小波阈值去噪
  34. psnr2 = PSNR(x2, X)                                                 % 软硬阈值的改进方法
  35. psnr3 = PSNR(x3, X)                                                 % 广义小波阈值函数
  36. psnr4 = PSNR(x4, X)                                                 % 自适应特征阈值
  37. % 显示图像---------------------------------------------------------------------
  38. figure; imshow(x_soft);     title('软阈值方法 Donoho 全局阈值');
  39. figure; imshow(x_hard);     title('硬阈值方法 Donoho 全局阈值');
  40. figure; imshow(x_soft_lvd); title('软阈值方法 Birge-Massart策略');
  41. figure; imshow(x_hard_lvd); title('硬阈值方法 Birge-Massart策略');
  42. figure; imshow(x1);         title('半软阈值方法');
  43. figure; imshow(x1_5);       title('半软阈值方法 线性衰减');
  44. figure; imshow(x1_9);       title('半软阈值方法 指数衰减');
  45. figure; imshow(x1_10);      title('半软阈值方法 再次进行小波去噪');
  46. figure; imshow(x2);         title('软硬阈值函数的改进方法');
  47. figure; imshow(x3);         title('广义小波阈值函数');
  48. figure; imshow(x4);         title('自适应特征阈值');
  49. % 非小波方法去噪------------------------------------------------------------------
  50. f = ones(3);
  51. x_mean1 = meanfilter(x,f);                                          % 均值滤波
  52. x_med1  = medfilter(x, f);                                          % 中值滤波
  53. % 计算峰值信噪比
  54. psnr_mean1 = PSNR(x_mean1, X)                   
  55. psnr_med1 = PSNR(x_med1, X)
  56. figure; imshow(x_mean1);title('均值滤波1');
  57. figure; imshow(x_med1); title('中值滤波1');