在Matlab中实现Canny边缘检测算法 [英] implement canny edge detection algorithm in matlab

查看:1500
本文介绍了在Matlab中实现Canny边缘检测算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在Matlab中实现Canny边缘检测算法.当我在内置的图像cameraman.tif中使用matlab时,它工作正常,但是当我使用不同的图像和命令窗口显示时,它给出了错误:

索引超出了矩阵尺寸.

canny_edge错误(第45行)

            sum = sum + (ID(u+i, v+j) * filter(i+3, j+3));

错误

整个Matlab代码托管在链接 我是Matlab的新手.我尝试实现大学分配算法

解决方案

%figure,imshow(filter);
for u = 3 : r
    for v = 3 : c
        sum = 0;
        for i = -2 : 2
            for j = -2 : 2
                sum = sum + (ID(u+i, v+j) * filter(i+3, j+3));
            end
        end
        IDx(u,v) = sum;
    end
end

i try to implement canny edge detection algorithm in matlab. it work fine when i use matlab in built image cameraman.tif but it give error when i use different image and command window show:

Index exceeds matrix dimensions.

Error in canny_edge (line 45)

            sum = sum + (ID(u+i, v+j) * filter(i+3, j+3));

error

whole matlab code is hosted at link i am novice in matlab. i try to implement algorithm for college assignment

解决方案

%figure,imshow(filter);
for u = 3 : r
    for v = 3 : c
        sum = 0;
        for i = -2 : 2
            for j = -2 : 2
                sum = sum + (ID(u+i, v+j) * filter(i+3, j+3));
            end
        end
        IDx(u,v) = sum;
    end
end

这篇关于在Matlab中实现Canny边缘检测算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆