Fuse_DWB.m
上传用户:htdzkj
上传日期:2013-07-02
资源大小:346k
文件大小:2k
源码类别:

波变换

开发平台:

Matlab

  1. clear
  2. [imA,map1] = imread('A.tif');
  3. M1 = double(imA) / 256;
  4. [imB,map2] = imread('B.tif');
  5. M2 = double(imB) / 256;
  6. zt= 4; 
  7. wtype = 'haar';
  8. %    M1 - input image A
  9. %    M2 - input image B
  10. %    wtype使用的小波类型
  11. %    Y  - fused image   
  12. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  13. %%
  14. %%  小波变换图像融合
  15. %%
  16. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  17. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  18. %%   小波变换的绝对值大的小波系数,对应着显著的亮度变化,也就是图像中的显著特征。所以,选择绝对值大
  19. %%   的小波系数作为我们需要的小波系数。【注意,前面取的是绝对值大小,而不是实际数值大小】
  20. %%
  21. %%   低频部分系数采用二者求平均的方法
  22. %%
  23. %%
  24. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  25. [c0,s0] = wavedec2(M1, zt, wtype);%多尺度二维小波分解
  26. [c1,s1] = wavedec2(M2, zt, wtype);%多尺度二维小波分解
  27. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  28. %%  后面就可以进行取大进行处理。然后进行重构,得到一个图像
  29. %%  的小波系数,然后重构出总的图像效果。
  30. %%  取绝对值大的小波系数,作为融合后的小波系数
  31. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  32. KK = size(c1);
  33. Coef_Fusion = zeros(1,KK(2));
  34. Temp = zeros(1,2);
  35. Coef_Fusion(1:s1(1,1)) = (c0(1:s1(1,1))+c1(1:s1(1,1)))/2;  %低频系数的处理
  36.                      %这儿,连高频系数一起处理了,但是后面处理高频系数的时候,会将结果覆盖,所以没有关系
  37.    %处理高频系数
  38.     MM1 = c0(s1(1,1)+1:KK(2));
  39.     MM2 = c1(s1(1,1)+1:KK(2));
  40.     mm = (abs(MM1)) > (abs(MM2));
  41.    Y  = (mm.*MM1) + ((~mm).*MM2);
  42.     Coef_Fusion(s1(1,1)+1:KK(2)) = Y;
  43.     %处理高频系数end
  44.  
  45.  %重构
  46.  Y = waverec2(Coef_Fusion,s0,wtype);
  47. %显示图像  
  48. subplot(2,2,1);imshow(M1);
  49. colormap(gray);
  50. title('input2');
  51. axis square  
  52.  
  53. subplot(2,2,2);imshow(M2);
  54. colormap(gray);
  55. title('input2');
  56. axis square  
  57. subplot(223);imshow(Y,[]);
  58. colormap(gray);
  59. title('融合图像');
  60. axis square;
  61. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  62.