Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab Canny边缘检测器-实施中的故障_Matlab_Image Processing_Edge Detection - Fatal编程技术网

Matlab Canny边缘检测器-实施中的故障

Matlab Canny边缘检测器-实施中的故障,matlab,image-processing,edge-detection,Matlab,Image Processing,Edge Detection,我正在尝试实现canny边缘检测器。我已经做了一些代码,生成了我认为应该正确的非最大值抑制阶段,但是当我运行它时,我得到了一个图像,它几乎显示了轮廓,但不是我预期的结果 我花了几个小时试图修复它,但找不到哪里出了问题。谁能给我指出正确的方向吗 % Set direction to either 0, 45, -45 or 90 depending on angle. [x,y]=size(f1); for i=1:x-1, for j=1:y-1, if ((gradAn

我正在尝试实现canny边缘检测器。我已经做了一些代码,生成了我认为应该正确的非最大值抑制阶段,但是当我运行它时,我得到了一个图像,它几乎显示了轮廓,但不是我预期的结果

我花了几个小时试图修复它,但找不到哪里出了问题。谁能给我指出正确的方向吗

% Set direction to either 0, 45, -45 or 90 depending on angle.
[x,y]=size(f1);
for i=1:x-1,
    for j=1:y-1,
        if ((gradAngle(i,j)>67.5 && gradAngle(i,j)<=90) || (gradAngle(i,j)>=-90 && gradAngle(i,j)<=-67.5)) 
            gradDirection(i,j)=0;
        elseif ((gradAngle(i,j)>22.5 && gradAngle(i,j)<=67.5))
            gradDirection(i,j)=45;
        elseif ((gradAngle(i,j)>-22.5 && gradAngle(i,j)<=22.5))
            gradDirection(i,j)=90;
        elseif ((gradAngle(i,j)>-67.5 && gradAngle(i,j)<=-22.5))
            gradDirection(i,j)=-45;
        end
    end
end

% Non-maxima suppression. 
% Compare to neighbours and set as 0 if smaller than either of them
for i=2:x-2,
    for j=2:y-2,
        if(gradDirection(i,j)==90)
           if (gradDirection(i,j)<(gradDirection(i,j-1) | gradDirection(i,j+1)))
               gradDirection(i,j)=0;
           end 
        end
        if(gradDirection(i,j)==45)
           if (gradDirection(i,j)<(gradDirection(i+1,j-1) | gradDirection(i-1,j+1)))
               gradDirection(i,j)=0;
           end 
        end
        if(gradDirection(i,j)==-45)
           if (gradDirection(i,j)<(gradDirection(i-1,j-1) | gradDirection(i+1,j+1)))
               gradDirection(i,j)=0;
           end 
        end
    end
end
%根据角度将方向设置为0、45、-45或90。
[x,y]=尺寸(f1);
对于i=1:x-1,
对于j=1:y-1,

如果((gradAngle(i,j)>67.5&&gradAngle(i,j)=-90&&gradAngle(i,j)22.5&&gradAngle(i,j)-22.5&&gradAngle(i,j)-67.5&&gradAngle(i,j)我认为问题在于你的位OR:

 if (gradDirection(i,j)<(gradDirection(i,j-1) | gradDirection(i,j+1)))

if(gradedirection(i,j)到底是什么问题?你期待什么?
 if (gradDirection(i,j)<gradDirection(i,j-1) || gradDirection(i,j)<gradDirection(i,j+1))