[英]applying gabor filter to an images
我是一個非常新的圖像處理。我想知道如何在12個不同方向的圖像上應用gabor濾鏡,比如0,15,30,45到165.I我想將這個gabor濾鏡用於12個方向和輸出必須顯示每個方向。我的輸入是視網膜的圖像,應用gabor過濾器后,視網膜的輸出應該是微調圖像。我該怎么做?
%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個不同的方向上定位我的圖像
我應該得到一個視網膜圖像的輸出,但我得到我的輸出圖像
你應該添加這兩行:
...
% gb is the n-th gabor filter
img_out(:,:,n) = imfilter(img_in, gb, 'symmetric');
figure;
imshow(img_out(:,:,n));
...
我從你的問題中了解到你想要使用gabor過濾器12次,每次都用指定的方向(theta)吧? 這樣做 - > for for循環寫這個----> ...
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過濾器的更好信息http://matlabserver.cs.rug.nl/edgedetectionweb/web/edgedetection_params.html
希望這會幫助你。 最良好的問候。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.