Edge detection using matlab

5 次查看(过去 30 天)
Ihsan Ayyach
Ihsan Ayyach 2019-5-22
编辑: Matt J 2019-5-22
close all;
clc;
img=imread('download.jpg');
B=rgb2gray(img);
subplot(2,2,1)
imshow(B)
pause(2)
I=double(B);
for i=1:size(I,1)-2
for j=1:size(I,2)-2
%Sobel mask for x-direction:
mx=((2*I(i+2,j+1)+I(i+2,j)+I(i+2,j+2))-(2*I(i,j+1)+I(i,j)+I(i,j+2)));
%Sobel mask for y-direction:
my=((2*I(i+1,j+2)+I(i,j+2)+I(i+2,j+2))-(2*I(i+1,j)+I(i,j)+I(i+2,j)));
B(i,j)=sqrt(mx.^2+my.^2);
end
end
subplot(2,2,2)
imshow(B); title('Sobel gradient');
pause(2)
%Define a threshold value
Thresh=100;
B=max(B,Thresh);
B(B==round(Thresh))=0;
B=uint8(B);
subplot(2,2,3)
imshow(~B);title('Edge detected Image');
Im using this code for detect the edges in my image and it works fine ...
My question how to plot outpot line on the input image using least squares fitting ???

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Object Programming 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by