【问题标题】:Gabor based Texture Segmentation基于 Gabor 的纹理分割
【发布时间】:2014-04-20 07:06:07
【问题描述】:

我正在尝试实现一个用于纹理图像分割的 gabor 滤波器。我在 MATLAB 中执行此操作,并咨询了来自 paper - A level set and Gabor-based Active Contour Algorithm for Segmenting Textured Images

的概念

我在下面突出显示相关部分:2D gabor 函数为

在哪里

跨度限制正弦光栅的频率F给出,其方向由Theta指定。 Sigma 是尺度参数。该过滤器将用于图像,并且由于 gabor 过滤器由虚部组成,因此得到 Gabor 变换,如下所示。

其中,GR 和 GI 是通过将其与图像 u0 进行卷积得到的实部和虚部。我需要在 MATLAB 中编写这部分代码,并为 theta、F 和 sigma 的不同值生成 Gabor 转换 图像

我的代码

clc;clear all;close all;
sigma=.0075;
m_size=7;
theta=pi/4;
F=60;
[real_g,im_g]=gabor(m_size,sigma,F,theta);

//My Gabor function
function [real_g,im_g] = gabor(m_size,sigma,F,theta)
[x,y]=meshgrid(1:m_size,1:m_size);
real_g = zeros(m_size);
im_g = zeros(m_size);
g_sigma = zeros(m_size);
for i=1:size(x,1)
    for j=1:size(y,1)
        g_sigma(i,j) = (1./(2*pi*sigma^2)).*exp(((-1).*(i^2+j^2))./(2*sigma^2));
        real_g(i,j) = g_sigma(i,j).*cos((2*pi*F).*(i.*cos(theta)+j.*sin(theta)));
        im_g(i,j) = g_sigma(i,j).*sin((2*pi*F).*(i.*cos(theta)+j.*sin(theta)));
    end
end

我的输出

>> real_g

real_g =

     0     0     0     0     0     0     0
     0     0     0     0     0     0     0
     0     0     0     0     0     0     0
     0     0     0     0     0     0     0
     0     0     0     0     0     0     0
     0     0     0     0     0     0     0
     0     0     0     0     0     0     0

>> im_g

im_g =

     0     0     0     0     0     0     0
     0     0     0     0     0     0     0
     0     0     0     0     0     0     0
     0     0     0     0     0     0     0
     0     0     0     0     0     0     0
     0     0     0     0     0     0     0
     0     0     0     0     0     0     0

我的 gabor 过滤器完全错误。请你们帮我构建正确的 gabor 过滤器?请注意,参数和公式的数据来自我已经提到的论文。

任何帮助将不胜感激。 PS 如果有人需要论文,我也可以邮寄。谢谢。

【问题讨论】:

  • 所以我的帮助是使用不同类型的纹理特征,例如Haralick 纹理特征:stackoverflow.com/questions/22113684/…。我在 python 的 scikit-image 中使用了 Gabor 功能,它当然可以工作,但结果证明它不是直接使用的功能。如果您在实施方面遇到问题,可以查看此处:github.com/scikit-image/scikit-image/blob/master/skimage/filter/…
  • 我使用 Gabor 特征来确定木制吸管的方向,但它们似乎不是有用的特征。如果您在 matlab 中的实现有问题,请查看我引用的 scikit-image 源代码。
  • 高斯内核通常从 -x:x 开始,而不是 1:x。加上 sigma 相当小,因此 'real_g' 和 'im_g' 大多为 0。
  • @teng 感谢兄弟提供的信息
  • @roni,由于您尚未接受提供的解决方案,我猜您仍然遇到此问题。请让我们知道更多信息,以便我们帮助您回答您的问题。 :)

标签: image matlab image-processing


【解决方案1】:

希望以下代码对您的工作有所帮助。 它演示了如何使用具有不同 thetas 的 Gabor 过滤器转换图像(如图所示)。干杯。

% get image
u0=double(imread('cameraman.tif'));

% initialize parameters
sigma = 3;
m_size = 7;
F = 1;
m_size_halfed = round((m_size-1)/2);

% make up some thetas
thetas=0:pi/5:pi;

% loop through all thetas
for i = 1:numel(thetas)    
theta = thetas(i);

% setup the "gabor transform"
[x,y]=meshgrid(-m_size_halfed:m_size_halfed,-m_size_halfed:m_size_halfed);
g_sigma = (1./(2*pi*sigma^2)).*exp(((-1).*(x.^2+y.^2))./(2*sigma.^2));
real_g = g_sigma.*cos((2*pi*F).*(x.*cos(theta)+y.*sin(theta)));
im_g = g_sigma.*sin((2*pi*F).*(x.*cos(theta)+y.*sin(theta)));

% perform Gabor transform
u_0sft=sqrt(conv2(u0,real_g,'same').^2+conv2(u0,im_g,'same').^2);

subplot(1,numel(thetas)+1,i+1)
imagesc(u_0sft);
colormap('gray'); axis image; axis off;
title(sprintf('theta:%1.1f',theta));

end

% visualize image
subplot(1,numel(thetas)+1,1)
imagesc(u0);
colormap('gray'); axis image; axis off;
title('original');

【讨论】:

  • +1 以获得明确的答案。顺便说一句,我读过chan-vese的论文。我真的使用你的代码。但是在 chan-vese 论文中,他设置了 F=60:30:120 和 sigma=[0.0075 0.005 0.0025]。与您的代码相比,它非常小。因此,我混淆了 F 和 sigma 的值。您能否阅读 chan-vese 论文并告​​诉我与您的代码等效的 F 和 sigma 的值是什么。谢谢citeseerx.ist.psu.edu/viewdoc/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-12-26
  • 2013-03-02
  • 2014-10-30
  • 2011-04-13
  • 2013-11-07
  • 2018-12-30
  • 2013-04-17
相关资源
最近更新 更多