Image processing 如何在Matlab中分析方向性(如斐济工具)?梯度函数不起作用

Image processing 如何在Matlab中分析方向性(如斐济工具)?梯度函数不起作用,image-processing,matlab,Image Processing,Matlab,我刚刚开始使用Matlab,如果我的错误很愚蠢,请提前道歉。 我的目标是能够分析8比特灰度图像中管/纤维/条纹的方向。示例:请参见此图片: 当我使用斐济方向性工具时,返回信号的方向为:0º,这是一个预期值,仅取值范围为0º到180º 我尝试编写的脚本应该会产生与我在斐济得到的脚本类似的结果。 为此,我使用了Matlab图像处理工具箱2013中的imgradient函数 以下是脚本: 我从上一个柱状图脚本中得到的结果:像素数量与方向:未转换为正值的值是:大约90ºC。该值与我应该获得的值垂直,正如

我刚刚开始使用Matlab,如果我的错误很愚蠢,请提前道歉。 我的目标是能够分析8比特灰度图像中管/纤维/条纹的方向。示例:请参见此图片:

当我使用斐济方向性工具时,返回信号的方向为:0º,这是一个预期值,仅取值范围为0º到180º

我尝试编写的脚本应该会产生与我在斐济得到的脚本类似的结果。 为此,我使用了Matlab图像处理工具箱2013中的imgradient函数

以下是脚本: 我从上一个柱状图脚本中得到的结果:像素数量与方向:未转换为正值的值是:大约90ºC。该值与我应该获得的值垂直,正如我前面提到的,0ºC是方向性工具

然而,有了这个脚本,当我分析的图片很简单时,我可以得到正确的方向。 如以下链接所示:

在本例中,脚本返回我期望的方向斐济=Matlab脚本=90º。然而,当我将条纹或信号管对准某个方向时,根据我的解释,返回的值是信号条纹相对于背景变化最大的值,因此是垂直于条纹方向的值。这不是我需要的

我真正需要的是一个脚本,它返回信号条纹的方向

我希望我说得够清楚了。请随时联系我,询问更多问题

非常感谢

祝你一切顺利

胡安-

enter code here

clear all;
close all;
p = 0;

a = imread('image.tif');

%Apply the imgradient function

[M D] = imgradient(a);
[r c] = size(a);

%Given that I get directions in [-180 to 180] I transform the negatives in the      corresponding positives (e.g.: -45 = 135)

for x = 1 : c;
for y = 1 : r;
    if D(x,y) < 0;
        d_nonnegatives(x,y) = D(x,y) + 180;
    else
        d_nonnegatives(x,y) = D(x,y);
    end;
end;
end;

% Prepare the date to make the graphs

for x = 1 : c;
for y = 1 : r;
p = p + 1;
d_list(p) = d_nonnegatives(x,y);   
end;
end;

d_list_transposed = d_list';
d_list_sorted = sortrows(d_list_transposed);
binrange = [0:10:180];
[N bins] = histc(d_list_sorted,binrange);

%Make figures

figure, imshow(D), title('Image Direction Matrix')
figure, hist(d_list_sorted,binrange), title('Amount of Pixels vs Direction: Negative      values converted to positive');
figure, hist(D), title('Amount of Pixels vs Direction: Values non-converted to positive');