File: ef230-2023-08/www/examples/image_edge_detect.m Download
%! Image processing edge detection example
%! Compares different algorithms
% University of Tennessee : EF 230 Fall, 2018

clear all; close all; clc;
options = weboptions('CertificateFilename','');  % required for https
tmpfile = websave('scan0001.jpg','https://ef.engr.utk.edu/ef230-2018-08/examples/data/scan0001.jpg', options);
rgb_img=imread('scan0001.jpg');
% scaling down makes things go faster and seems to produce better results
scaled_img = imresize(rgb_img,.25);
gray_img = rgb2gray(imrotate(scaled_img,90));

% the original image
figure
imshow(gray_img);

% show results of each of the different algorithms
methods = {'sobel','prewitt','roberts','log','zerocross','canny'};
for i=1:length(methods);
    figure(i+1);
    set(gcf,'name',methods{i}); % window title
    i2=edge(gray_img,methods{i});
    imshow(i2);
end