声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1400|回复: 4

[共享资源] matlab实现s小波变换代码

[复制链接]
发表于 2006-10-10 09:59 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
输入图像矩阵,输出一幅图像,分为四块;

  1. function wvlet=waveup1(x)
  2. %function [ll,hl,lh,hh]=waveup1(x)
  3. x=double(x);
  4. wvlet=x;
  5. [hp,lp]=size(x);
  6. hc=hp/2;
  7. lc=lp/2;
  8. %奇偶列重排
  9. for n=1:lc
  10.         j=n*2-1;
  11.         wvlet(:,n)=x(:,j);
  12.         wvlet(:,lc+n)=x(:,j+1);
  13. end
  14. %行变换开始
  15. for n=1:lc-1       
  16.         k=floor((wvlet(:,n)+wvlet(:,n+1))/2);
  17.         wvlet(:,lc+n)=wvlet(:,lc+n)-k;
  18. end
  19.         k=floor((wvlet(:,lc)+wvlet(:,lc-1))/2);   
  20.         wvlet(:,lp)=wvlet(:,lp)-k;

  21.         k=floor((wvlet(:,lc+2)+wvlet(:,lc+1))/4+0.5);
  22.         wvlet(:,1)=wvlet(:,1)+k;
  23. for n=2:lc
  24.         k=floor((wvlet(:,lc+n)+wvlet(:,lc+n-1))/4+0.5);
  25.         wvlet(:,n)=wvlet(:,n)+k;
  26. end
  27. %行变换结束
  28. x=wvlet;
  29. %奇偶行重排
  30. for n=1:hc
  31.         j=n*2-1;
  32.         wvlet(n,:)=x(j,:);
  33.         wvlet(hc+n,:)=x(j+1,:);
  34. end
  35. %列重排开始       
  36. for n=1:hc-1       
  37.         k=floor((wvlet(n,:)+wvlet(n+1,:))/2);
  38.         wvlet(hc+n,:)=wvlet(hc+n,:)-k;
  39. end
  40.         k=floor((wvlet(hc,:)+wvlet(hc-1,:))/2);
  41.         wvlet(hp,:)=wvlet(hp,:)-k;

  42.         k=floor((wvlet(hc+2,:)+wvlet(hc+1,:))/4+0.5);
  43.         wvlet(1,:)=wvlet(1,:)+k;
  44. for n=2:hc
  45.         k=floor((wvlet(hc+n,:)+wvlet(hc+n-1,:))/4+0.5);
  46.         wvlet(n,:)=wvlet(n,:)+k;
  47. end
  48. %列重排结束
  49. wvlet=uint8(wvlet);
  50. ll=wvlet(1:hc,1:lc);
  51. hl=wvlet(1:hc,lc+1:lp);
  52. lh=wvlet(hc+1:hp,1:lc);
  53. hh=wvlet(hc+1:hp,lc+1:lp);
复制代码
回复
分享到:

使用道具 举报

 楼主| 发表于 2006-10-10 09:59 | 显示全部楼层
  1. %function wvlet=waveup2(x)
  2. function [ll,hl,lh,hh]=waveup2(x)
  3. x=double(x);
  4. wvlet=x;
  5. [hp,lp]=size(x);
  6. hc=hp/2;
  7. lc=lp/2;
  8. %奇偶列重排
  9. for n=1:lc
  10.         j=n*2-1;
  11.         wvlet(:,n)=x(:,j);
  12.         wvlet(:,lc+n)=x(:,j+1);
  13. end
  14. %行变换开始
  15. for n=1:lc-1       
  16.         k=(wvlet(:,n)+wvlet(:,n+1))/2;
  17.         wvlet(:,lc+n)=wvlet(:,lc+n)-k;
  18. end
  19.         k=(wvlet(:,lc)+wvlet(:,lc-1))/2;   
  20.         wvlet(:,lp)=wvlet(:,lp)-k;

  21.         k=(wvlet(:,lc+2)+wvlet(:,lc+1))/4;
  22.         wvlet(:,1)=wvlet(:,1)+k;
  23. for n=2:lc
  24.         k=(wvlet(:,lc+n)+wvlet(:,lc+n-1))/4;
  25.         wvlet(:,n)=wvlet(:,n)+k;
  26. end
  27. %行变换结束
  28. x=wvlet;
  29. %奇偶行重排
  30. for n=1:hc
  31.         j=n*2-1;
  32.         wvlet(n,:)=x(j,:);
  33.         wvlet(hc+n,:)=x(j+1,:);
  34. end
  35. %列重排开始       
  36. for n=1:hc-1       
  37.         k=(wvlet(n,:)+wvlet(n+1,:))/2;
  38.         wvlet(hc+n,:)=wvlet(hc+n,:)-k;
  39. end
  40.         k=(wvlet(hc,:)+wvlet(hc-1,:))/2;
  41.         wvlet(hp,:)=wvlet(hp,:)-k;

  42.         k=(wvlet(hc+2,:)+wvlet(hc+1,:))/4;
  43.         wvlet(1,:)=wvlet(1,:)+k;
  44. for n=2:hc
  45.         k=(wvlet(hc+n,:)+wvlet(hc+n-1,:))/4;
  46.         wvlet(n,:)=wvlet(n,:)+k;
  47. end
  48. %列重排结束
  49. %wvlet=uint8(wvlet);
  50. ll=wvlet(1:hc,1:lc);
  51. hl=wvlet(1:hc,lc+1:lp);
  52. lh=wvlet(hc+1:hp,1:lc);
  53. hh=wvlet(hc+1:hp,lc+1:lp);
复制代码
 楼主| 发表于 2006-10-10 10:00 | 显示全部楼层
  1. function wvlet=waveup3(x)
  2. %function [ll,hl,lh,hh]=waveup3(x)
  3. x=double(x);
  4. wvlet=x;
  5. [hp,lp]=size(x);
  6. hc=hp/2;
  7. lc=lp/2;
  8. %奇偶列重排
  9. for n=1:lc
  10.         j=n*2-1;
  11.         wvlet(:,n)=x(:,j);
  12.         wvlet(:,lc+n)=x(:,j+1);
  13. end
  14. %行变换开始
  15. for n=1:lc       
  16.         wvlet(:,lc+n)=wvlet(:,lc+n)-wvlet(:,n);
  17. end
  18. for n=1:lc
  19.     k=wvlet(:,lc+n)/2-mod(wvlet(:,lc+n)/2,1);
  20.         wvlet(:,n)=wvlet(:,n)+k;
  21. end
  22. %行变换结束
  23. x=wvlet;
  24. %奇偶行重排
  25. for n=1:hc
  26.         j=n*2-1;
  27.         wvlet(n,:)=x(j,:);
  28.         wvlet(hc+n,:)=x(j+1,:);
  29. end
  30. %列重排开始       
  31. for n=1:hc       
  32.         wvlet(hc+n,:)=wvlet(hc+n,:)-wvlet(n,:);
  33. end
  34. for n=1:hc
  35.         k=wvlet(hc+n,:)/2-mod(wvlet(hc+n,:)/2,1);
  36.         wvlet(n,:)=wvlet(n,:)+k;
  37. end
  38. %列重排结束
  39. %wvlet=uint8(wvlet);
  40. ll=wvlet(1:hc,1:lc);
  41. hl=wvlet(1:hc,lc+1:lp);
  42. lh=wvlet(hc+1:hp,1:lc);
  43. hh=wvlet(hc+1:hp,lc+1:lp);
复制代码
发表于 2006-10-19 12:55 | 显示全部楼层
s小波是哪个小波啊,能不能详细描述一下这个程序的功能啊
 楼主| 发表于 2006-10-20 15:23 | 显示全部楼层
该函数的功能:输入图像矩阵,输出一幅图像,分为四块

上面已经有相关说明了
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-19 22:54 , Processed in 0.053244 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表