繁体   English   中英

将gabor滤镜应用于图像

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM