Hello Mat

 找回密码
 立即注册
查看: 4053|回复: 1

Gabor滤波器

[复制链接]

1294

主题

1520

帖子

110

金钱

管理员

Rank: 9Rank: 9Rank: 9

积分
22633
发表于 2016-12-25 20:57:30 | 显示全部楼层 |阅读模式
  1. close all;clear all;clc;
  2. G = cell(5,8);
  3. for s = 1:5
  4.     for j = 1:8
  5.         G{s,j}=zeros(32,32);
  6.     end
  7. end
  8. for s = 1:5
  9.     for j = 1:8
  10.         G{s,9-j} = gabor([32 32],(s-1),j-1,pi,sqrt(2),pi);
  11.     end
  12. end

  13. figure;
  14. for s = 1:5
  15.     for j = 1:8        
  16.         subplot(5,8,(s-1)*8+j);        
  17.         imshow(real(G{s,j}),[]);
  18.     end
  19. end

  20. for s = 1:5
  21.     for j = 1:8        
  22.         G{s,j}=fft2(G{s,j});
  23.     end
  24. end
  25. save gabor G

  26. function Psi = gabor (w,nu,mu,Kmax,f,sig)
  27. % w  : Window [128 128]
  28. % nu : Scale [0 ...4];
  29. % mu : Orientation [0...7]
  30. % kmax = pi/2
  31. % f = sqrt(2)
  32. % sig = 2*pi

  33. m = w(1);
  34. n = w(2);
  35. K = Kmax/f^nu * exp(i*mu*pi/8);
  36. Kreal = real(K);
  37. Kimag = imag(K);
  38. NK = Kreal^2+Kimag^2;
  39. Psi = zeros(m,n);
  40. for x = 1:m
  41.     for y = 1:n
  42.         Z = [x-m/2;y-n/2];
  43.         Psi(x,y) = (sig^(-2))*exp((-.5)*NK*(Z(1)^2+Z(2)^2)/(sig^2))*...
  44.                    (exp(i*[Kreal Kimag]*Z)-exp(-(sig^2)/2));
  45.     end
  46. end
复制代码


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
算法QQ  3283892722
群智能算法链接http://halcom.cn/forum.php?mod=forumdisplay&fid=73
回复

使用道具 举报

1294

主题

1520

帖子

110

金钱

管理员

Rank: 9Rank: 9Rank: 9

积分
22633
 楼主| 发表于 2016-12-25 21:22:43 | 显示全部楼层
Gabor图像滤波器设计如下:
  1. function [G,gabout] = gabor_filter(I,Sx,Sy,U,V)
  2. % 函数输入:
  3. %          I : 输入的二维图像
  4. %          Sx & Sy : 方差 along x and y-axes respectively
  5. %          U & V : 中心频率  along x and y-axes respectively
  6. % 函数输出:
  7. %          G : G(x,y)
  8. %          gabout : Gabor滤波图像
  9. % G(x,y)表达式如下:
  10. %               1                -1     x  ^    y  ^
  11. %%% G(x,y) = ---------- * exp ([----{(----) 2+(----) 2}+2*pi*i*(Ux+Vy)])
  12. %            2*pi*sx*sy           2    sx       sy

  13. if isa(I,'double')~=1
  14.     I = double(I);
  15. end

  16. for x = -fix(Sx):fix(Sx)
  17.     for y = -fix(Sy):fix(Sy)
  18.         G(fix(Sx)+x+1,fix(Sy)+y+1) = (1/(2*pi*Sx*Sy))*exp(-.5*((x/Sx)^2+(y/Sy)^2)+2*pi*i*(U*x+V*y));
  19.     end
  20. end

  21. Imgabout = conv2(I,double(imag(G)),'same');  % 卷积
  22. Regabout = conv2(I,double(real(G)),'same');  % 卷积

  23. gabout = uint8(sqrt(Imgabout.*Imgabout + Regabout.*Regabout)); % 输出滤波图像
复制代码
具体参考书籍:
余胜威,丁建明,吴婷,魏健蓝 . MATLAB图像滤波去噪分析及其应用. 北京:北京航空航天大学出版社,2015.
算法QQ  3283892722
群智能算法链接http://halcom.cn/forum.php?mod=forumdisplay&fid=73
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Python|Opencv|MATLAB|Halcom.cn ( 蜀ICP备16027072号 )

GMT+8, 2024-4-29 02:14 , Processed in 0.244317 second(s), 22 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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