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. 【bzoj2002】[Hnoi2010]Bounce 弹飞绵羊 link-cut-tree

    2016-05-30 11:51:59 用一个next数组,记录点x的下一个点是哪个 查询时,moveroot(n+1),access(x),splay(x) ,输出size[ch[x][0]]即为答 ...

  2. 20145330《Java程序设计》第一次实验报告

    20145330<Java程序设计>第一次实验报告 实验一Java开发环境的熟悉 实验内容 1.使用JDK编译.运行简单的Java程序: 2.使用Eclipse 编辑.编译.运行.调试Ja ...

  3. 用脚本来简化iOS美术同学的工作

    用脚本来简化iOS美术同学的工作 问题 我们知道,在 iOS 开发中,为了使我们的 app 能够同时支持 iPhone 的 Retina 屏幕和普通屏幕,美术同学需要对 UI 设计稿中的每个元素进行 ...

  4. java输入一个字符串,打印出该字符串中字符的所有排列,随机打乱排序

    import java.util.ArrayList;import java.util.Collections;import java.util.List; public class Test7{   ...

  5. 导出excel时,以form方式提交json数据

    今天在写项目时写到一个excel的导出,开始想用ajax请求后台后导出,但发现ajax会有返回值,而且ajax无法直接输出文件,而后台的excel导出方法已经封装好,不方便修改. 就改用了提交的方式f ...

  6. Codeforces Beta Round #78 Div. 1 A

    题目链接:http://codeforces.com/contest/98/problem/A 题意大意:给你6种颜色,这6种颜色可能相同也可能不同,把这几种颜色全涂在一个正方体表面,问有多少种涂法( ...

  7. 为什么使用ConcurrentHashMap

    ConcurrentHashMap是有Segment数组结构和HashEntry数组结构组成. Segment是一种可重入锁(ReentrantLock),在ConcurrentHashMap里扮演锁 ...

  8. Chrome浏览器插件推荐大全

    如何下载:http://www.cnplugins.com/devtool/ 提示:下载可能版本过旧,推荐搜索喜爱的插件之后前往官网或者github(编译的时候确保node和npm都是最新的版本).或 ...

  9. 【iCore3 双核心板_FPGA】例程八:触发器实验——触发器的使用

    实验指导书及代码包下载: http://pan.baidu.com/s/1bswW3c iCore3 购买链接: https://item.taobao.com/item.htm?id=5242294 ...

  10. 新广告法,极限词剔除,替换掉的mysql语句

    国家级,世界级,最高级, 最佳,最大,第一, 唯一,首个,首选, 最好,最大,精确, 顶级,最高,最低, 最,最具,最便宜, 最新,最先进,最大程度, 最新技术,最先进科学,国家级产品, 填补国内空白 ...