我对图像处理非常陌生,我想知道如何在12种不同方向的图像上应用gabor滤波器,比如0,15,30,45到165。我想将这个gabor滤波器应用于12个方向,每个方向的输出必须是displayed.My,输入是视网膜图像,方向输出应该是经过filter.How调整后的视网膜图像。
%code for gabor filter
I = getimage();
I=I(:,:,2);
lambda = 8;
theta = 0;
psi = [0 pi/2];
gamma = 0.5;
bw = 1;
N = 12;
img_in = im2double(I);
%img_in(:,:,2:3) = []; % discard redundant channels, it's gray anyway
img_out = zeros(size(img_in,1), size(img_in,2), N);
for n=1:N
gb = gabor_fn(bw,gamma,psi(1),lambda,theta)...
+ 1i * gabor_fn(bw,gamma,psi(2),lambda,theta);
% gb is the n-th gabor filter
img_out(:,:,n) = imfilter(img_in, gb, 'symmetric');
% filter output to the n-th channel
%theta = theta + 2*pi/N;
theta = 15 * n; % i wrote this because my angles are multiples of 15
% next orientation
end
figure(1);
imshow(img_in);
title('input image');
figure(2);
img_out_disp = sum(abs(img_out).^2, 3).^0.5;
%default superposition method, L2-norm
img_out_disp = img_out_disp./max(img_out_disp(:));
% normalize
imshow(img_out_disp);
title('gabor output, L-2 super-imposed, normalized'); 我的输入图像是

我的输出图像是

如何应用gabor滤波器将图像定向到12个不同的方向
我应该得到一个输出的视网膜图像,但我得到我的输出图像为

发布于 2013-11-06 10:52:41
您应该添加这两行:
...
% gb is the n-th gabor filter
img_out(:,:,n) = imfilter(img_in, gb, 'symmetric');
figure;
imshow(img_out(:,:,n));
... 发布于 2015-10-28 20:55:25
我从你的问题中了解到,你想用gabor滤波器12次,每次用指定的方向(θ),对吗?要做到这一点-->在循环之前--写这个-->.
responses = {}; % to save each response from filter.在过滤你的图像之后,像这样旋转-->
..。
response = conv2(img_in,gb,'same'); ..。
然后让你的振幅像这样->.
realpart = real(response);
imagpart = imag(response);
response = sqrt(realpart.^2 + imagpart.^2);..。
将--> img_out(:,:,n)替换为->
..。
responses = cat(1,responses,response);此代码将将您的响应从每个过滤器保存到一个单元格中,如果您希望看到响应,只需执行以下操作.
X = responses{1}; % or 2 or 3...此链接将提供有关gabor过滤器params.html的更好信息。
希望这能帮到你。最好的尊重。
https://stackoverflow.com/questions/19809156
复制相似问题