gabor matlab 实现,求在matlab上实现gabor滤波器对图像处理的程序

求在matlab上实现gabor滤波器对图像处理的程序

关注:159  答案:2  手机版

解决时间 2021-01-31 08:43

提问者懷念那年夏天

2021-01-30 15:51

求在matlab上实现gabor滤波器对图像处理的程序

最佳答案

二级知识专家el孤酒el

2021-01-30 16:40

这是别人写的一个gabor滤波器的程序,你看看吧!

% GABORFILTER Bi-dimensional Gabor filter with DC component compensation.

% [G,GABOUT]=GABORFILTER(I,S,F,W,P) filters the input image I with the 2D

% Gabor filter G described by the parameters S, F, W and P to create the

% output filtered image GABOUT.

% This version of the 2D Gabor filter is basically a bi-dimensional

% Gaussian function centered at origin (0,0) with variance S modulated by

% a complex sinusoid with polar frequency (F,W) and phase P described by

% the following equation:

%

% G(x,y,S,F,W,P)=k*Gaussian(x,y,S)*(Sinusoid(x,y,F,W,P)-DC(F,S,P)),

% where:

% Gaussian(x,y,S)=exp(-pi*S^2*(x^2+y^2))

% Sinusoid(x,y,F,W,P)=exp(j*(2*pi*F*(x*cos(W)+y*sin(W))+P)))

% DC(F,S,P)=exp(-pi*(F/S)^2+j*P)

%

% PS: The term DC(F,S,P) compensates the inherent DC component produced

% by the Gaussian envelop as shown by Movellan in [1].

%

% Tips:

% 1) To get the real part and the imaginary part of the complex

% filter output use real(gabout) and imag(gabout), respectively;

%

% 2) To get the magnitude and the phase of the complex filter output

% use abs(gabout) and angle(gabout), respectively.

% Author: Stiven Schwanz Dias e-mail: stivendias@gmail.com

% Cognition Science Group, Informatic Department,

% University of Esp韗ito Santo, Brazil, January 2007.

%

% References:

% [1] Movellan, J. R. - Tutorial on Gabor Filters. Tech. rep., 2002.

function [G,GABOUT]=gaborfilter(I,S,F,W,P);

if isa(I,'double')~=1

I=double(I);

end

size=fix(1.5/S); % exp(-1.5^2*pi) < 0.1%

%k=2*pi*S^2;

%F=S^2/sqrt(2*pi);

k=1;

for x=-size:size

for y=-size:size

G(size+x+1,size+y+1)=k*exp(-pi*S^2*(x*x+y*y))*...

(exp(j*(2*pi*F*(x*cos(W)+y*sin(W))+P))-exp(-pi*(F/S)^2+j*P));

end

end

GABOUT=conv2(I,double(G),'same');

全部回答

1楼抚弦思华年

2021-01-30 18:17

matlab中有spatialgabor函数,利用这个函数可以实现多个方向和尺度的gabor滤波

实例:

clear,clc,close all

angle = 0:18:90; % direction

image = rgb2gray(imread('lena.bmp'));

k = [0.6,1.2]; % scale

figure(1)

suptitle('lena')

for ik=1:2

for iangle=1:6

subplot(4, 6, (ik-1)*6+iangle)

[evenfiltout, oddfiltout, ampfiltout] = spatialgabor(image, 3, angle(iangle), k(ik), k(ik), 1);

subplot(4, 6, (ik-1)*6+iangle+12)

imshow(uint8(ampfiltout))

end

end

image = imread('camman.bmp');

k = [1,1.5]; % scale

figure(2)

suptitle('camera man')

for ik=1:2

for iangle=1:6

subplot(4, 6, (ik-1)*6+iangle)

[evenfiltout, oddfiltout, ampfiltout] = spatialgabor(image, 2, angle(iangle), k(ik), k(ik), 1);

subplot(4, 6, (ik-1)*6+iangle+12)

imshow(uint8(ampfiltout))

end

end

我要举报

如以上信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!

推荐资讯

大家都在看

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值