matlab经典案例之图像处理(4种边缘算子)
程序分析,需要自取
% Project Title:边缘算子图像特征分析
%%by peter%%
clc
close all
clear all
%%%%%%%%%%%%%%图像输入选择模块%%%%%%%%%%
[filename, pathname] = uigetfile(’*.jpg’,‘Pick a Image’ );
image = imread([pathname,filename]);
image = imresize(image,[256,256]);
figure, imshow(image);title(’ Selected Image ');
I = rgb2gray(image);
%%%%%%%%%%%%%%调用工具箱计算求解%%%%%%%%%%%%%%%%%%
% Sobel filter
Filt_Sobel = edge(I,‘sobel’,0.1);
Filt_Sobel = imcomplement(Filt_Sobel);
figure, imshow(Filt_Sobel);title(’ Sobel Filtered ‘);
saveas(gcf,‘myfig1.jpg’)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Canny Edge
Filt_Canny = edge(I,‘canny’,0.2);
Filt_Canny = imcomplement(Filt_Canny);
figure, imshow(Filt_Canny); title(’ Canny Filtered’);
saveas(gcf,‘myfig2.jpg’)
%%%%%%%%%%%%%%%%%%%%%%