Matlab影像處理(五)邊緣偵測Sobel濾波
%% sobel邊緣濾波 close all; clear; clc; img = double(rgb2gray(imread('Color_lena512.bmp'))); [row, col] = size(img); Hck = [-1 -2 -1; 0 0 0; 1 2 1;]; Vck = [-1 0 1; -2 0 2; -1 0 1;]; Hfeature = zeros(row, col); Vfeature = zeros(row, col); addfeature = zeros(row, col); H=0; V=0; s=zeros(1, row.*col); for i=1:row-2 for j=1:col-2 for ii=1:3 for jj=1:3 H = H + img(i+ii-1, j+jj-1).*Hck(ii, jj); V = V + img(i+ii-1, j+jj-1).*Vck(ii, jj); end end Hfeature(i+1, j+1) = H; Vfeature(i+1, j+1) = V; H=0; V=0; end end count = 0; for i=1:row for j=1:col count = count + 1; ad...