文档介绍:
Experiment 3:Edge Detection
Class: 电子1203班 Student ID: Name: 王影
Ⅰ. Aim
The aim of this laboratory session is to learn to deal with image data by Matlab. By the end of this session, you should be able to perform image preprocessing of edge detection in spatial domain and frequency domain.
Ⅱ. Knowledge required in the Experiment
ⅰ.You are supposed to have learned the basic skills of using Matlab;
ⅱ.You need to review Matlab programming language and M-file format.
ⅲ. You should have studied edge detection methods.
Ⅲ. Experiment Contents
Demand: Please show the figure on the left and list the codes on the right respectively bellow each question.(请将运行结果(图片)和程序代码贴在每题下方)
ⅰ.Read “car.jpg” file (to do this by imread function), convert the color image into grayscale image, and then perform edge detection using Roterts, Prewitt, Sobel operator separately in spatial domain and display the results in a Matlab window.
程序:
clear;
im=imread('car.jpg');
I=rgb2gray(im);
subplot(3,2,1);imshow(I);
title('Gray image');
[Y,X]=size(I);
im_edge=zeros(Y,X);
T=30;
for k=2:Y-1
for kk=2:X-1
im_edge(k,kk)=abs(I(k+1,kk+1)-I(k,kk))+abs(I(k,kk+1)-I(k+1,kk));
if (im_edge(k,kk)>T)
im_edge(k,kk)=1;
else
im_edge(k,kk)=0;
end
end
end
subplot(3,2,2)
内容来自淘豆网www.taodocs.com转载请标明出处.