小编Bac*_*con的帖子

检测图像的边缘在Matlab中不起作用

我正在研究检测图像边缘的脚本.

这是脚本:

clear all; close all; clc;

c = rgb2gray(imread('image_S004_I0004.jpg'));
c = double(c);
k = imnoise(c, 'salt & pepper', 0.01); 

gg = [-1 0 1;-2 0 2; -1 0 1];
gh = gg';

grad_g = conv2(k, gg);
grad_h = conv2(k, gh);
grad = sqrt(grad_g.^2 + grad_h.^2);

[r s] = size(grad);
T = 80;
for ii = 1:r
    for jj = 1:s

        if grad(ii, jj) < T
            thresh_grad(ii, jj) = 0;
        else 
            thresh_grad(ii, jj) = 1;
        end
    end
end

figure()
subplot(121); …
Run Code Online (Sandbox Code Playgroud)

matlab image-processing noise edge-detection sobel

2
推荐指数
1
解决办法
72
查看次数

标签 统计

edge-detection ×1

image-processing ×1

matlab ×1

noise ×1

sobel ×1