1.spatialgabor.m描述gabor函数

% SPATIALGABOR - applies single oriented gabor filter to an image
%
% Usage:
%  [Eim, Oim, Aim] =  spatialgabor(im, wavelength, angle, kx, ky, showfilter)
%
% Arguments:
%         im         - Image to be processed.
%         wavelength - Wavelength in pixels of Gabor filter to construct
%         angle      - Angle of filter in degrees.  An angle of 0 gives a
%                      filter that responds to vertical features.
%         kx, ky     - Scale factors specifying the filter sigma relative
%                      to the wavelength of the filter.  This is done so
%                      that the shapes of the filters are invariant to the
%                      scale.  kx controls the sigma in the x direction
%                      which is along the filter, and hence controls the
%                      bandwidth of the filter.  ky controls the sigma
%                      across the filter and hence controls the
%                      orientational selectivity of the filter. A value of
%                      0.5 for both kx and ky is a good starting point.
%         showfilter - An optional flag 0/1.  When set an image of the
%                      even filter is displayed for inspection.

% Returns:
%         Eim - Result from filtering with the even (cosine) Gabor filter
%         Oim - Result from filtering with the odd (sine) Gabor filter
%         Aim - Amplitude image = sqrt(Eim.^2 + Oim.^2)
%

% Peter Kovesi  
% School of Computer Science & Software Engineering
% The University of Western Australia
% pk at csse uwa edu au
% http://www.csse.uwa.edu.au/~pk
%
% October 2006

function [Eim, Oim, Aim] = spatialgabor(im, wavelength, angle, kx, ky, showfilter)

if nargin == 5
        showfilter = 0;
    end
    
    im = double(im);
    [rows, cols] = size(im);
    newim = zeros(rows,cols);
    
    % Construct even and odd Gabor filters
    sigmax = wavelength*kx;
    sigmay = wavelength*ky;
    
    sze = round(3*max(sigmax,sigmay));
    [x,y] = meshgrid(-sze:sze);
    evenFilter = exp(-(x.^2/sigmax^2 + y.^2/sigmay^2)/2)...
    .*cos(2*pi*(1/wavelength)*x);
    
    oddFilter = exp(-(x.^2/sigmax^2 + y.^2/sigmay^2)/2)...
    .*sin(2*pi*(1/wavelength)*x);

evenFilter = imrotate(evenFilter, angle, 'bilinear');
    oddFilter = imrotate(oddFilter, angle, 'bilinear');

% Do the filtering
    Eim = filter2(evenFilter,im); % Even filter result
    Oim = filter2(oddFilter,im);  % Odd filter result
    Aim = sqrt(Eim.^2 + Oim.^2);  % Amplitude 
    
    if showfilter % Display filter for inspection
        figure(1), imshow(evenFilter,[]); title('filter'); 
    end
    
    2.main.m

ori=imread('D:\Images\New\Cars\image_0001.jpg');
 grayimg=rgb2gray(ori);
 gim=im2double(grayimg);
 
 [Eim,Oim,Aim]=spatialgabor(gim,3,90,0.5,0.5,1);%90-vertical===0-horizontal
 imshow(Aim);

from: http://blog.csdn.net/abcjennifer/article/details/7360436

matlab中实现Gabor滤波器的更多相关文章

  1. Gabor变换、Gabor滤波器

    D.Gabor 1946年提出 窗口Fourier变换,为了由信号的Fourier变换提取局部信息,引入了时间局部化的窗函数. 由于窗口Fourier变换只依赖于部分时间的信号,所以,现在窗口Four ...

  2. Gabor滤波器学习

    本文的目的是用C实现生成Gabor模版,并对图像卷积.并简单提一下,Gabor滤波器在纹理特征提取上的应用. 一.什么是Gabor函数(以下内容含部分翻译自维基百科) 在图像处理中,Gabor函数是一 ...

  3. Gabor滤波器的理解

    搬以前写的博客[2014-02-28 20:03] 关于Gabor滤波器是如何提取出特征点,这个过程真是煎熬.看各种文章,结合百度.文章内部的分析才有一点点明白. Gabor滤波器究竟是什么?   很 ...

  4. 图像算法五:【图像小波变换】多分辨率重构、Gabor滤波器、Haar小波

    原 https://blog.csdn.net/alwaystry/article/details/52756051 图像算法五:[图像小波变换]多分辨率重构.Gabor滤波器.Haar小波 2018 ...

  5. Matlab 高斯_拉普拉斯滤波器处理医学图像

    前言:本程序是我去年实现论文算法时所做.主要功能为标记切割肝脏区域.时间有点久,很多细节已经模糊加上代码做了很多注释,因此在博客中不再详述. NOTE: 程序分几大段功能模块,仔细阅读,对解决医学图像 ...

  6. matlab中的卷积——filter,conv之间的区别

    %Matlab提供了计算线性卷积和两个多项式相乘的函数conv,语法格式w=conv(u,v),其中u和v分别是有限长度序列向量,w是u和v的卷积结果序列向量. %如果向量u和v的长度分别为N和M,则 ...

  7. 图像卷积、相关以及在MATLAB中的操作

    图像卷积.相关以及在MATLAB中的操作 2016年7月11日 20:34:35, By ChrisZZ 区分卷积和相关 图像处理中常常需要用一个滤波器做空间滤波操作.空间滤波操作有时候也被叫做卷积滤 ...

  8. python实现gabor滤波器提取纹理特征 提取指静脉纹理特征 指静脉切割代码

    参考博客:https://blog.csdn.net/xue_wenyuan/article/details/51533953 https://blog.csdn.net/jinshengtao/ar ...

  9. Matlab中imfilter()函数的用法

    Matlab中imfilter()函数的用法 功能:对任意类型数组或多维图像进行滤波.用法:B = imfilter(A,H) B = imfilter(A,H,option1,option2,... ...

随机推荐

  1. git两种合并方法 比较merge和rebase

    18:01 2015/11/18git两种合并方法 比较merge和rebase其实很简单,就是合并后每个commit提交的id记录的顺序而已注意:重要的是如果公司用了grrit,grrit不允许用m ...

  2. Java中UIManager的几种外观的详细讲解

    Java'中的几种Look and Feel 1.Metal风格 (默认) String lookAndFeel = "javax.swing.plaf.metal.MetalLookAnd ...

  3. java画图程序_图片用字母画出来

    最近在研究怎样将图片用字母在文本编辑工具中“画”出来. 你看了这个可能还不知道我想说什么? 我想直接上图,大家一定就知道了 第一张:小猫 原图:http://www.cnblogs.com/hongt ...

  4. winform学习之-----小知识(20160624)

    一.//判断是否按下回车键if(e.KeyCode == Keys.Enter){   pictureBoxKeyDownLogin_Click(sender,e);}或是e.KeyCode == K ...

  5. iOS Notification 的使用

    Notification post notification,notification,notification,notification,notification,n otification ,no ...

  6. MRP运算生成采购单时间的逻辑

    由MRP运算产生的采购单日期,由生产单指定的安排计划日期.公司设置里的采购提前期和隐藏的供应商供货提前期三个字段共同决定. 可以很容易的在系统中找到,供应商供货提前期,需要在产品视图中将字段selle ...

  7. java web重定向与转发

    首先定义一下这两个词: 重定向是将用户从当前页面或servlet定向到另外一个jsp页面或者servlet 转发是将用户对当前jsp页面或者servlet对象的请求转发给另外一个jsp页面或者serv ...

  8. C#_项目做成安装包

    首先打开项目-->点开解决方案右键单击添加-->新建项目-->找到其他项目类型(如下图)--> 点击确定-->单击应用程序文件夹-->在名称下的空白处单击--> ...

  9. 解决在web项目使用log4j中无法将log信息写入文件

    这是log4j.properties中关于的配置 log4j.appender.appender2.File=F:/myeclipseworkspace2/SecondBook2/log/second ...

  10. C遇到的问题

    1. stdout-------printf输出到stdout,并在终端打印 stderr--------perror错误输出到stderr,并在终端打印 2. usleep(1)//代表一微妙 sl ...