function[]=main(jpg)
close all
clc
tic %测定算法执行的时间
[fn,pn]=uigetfile('timg1,jpg','选择图片') %读入图片
I=imread([pn,fn]);
figure,imshow(I);title('原始图像'); %显示原始图像
Im1=rgb2gray(I);
figure(2),
subplot(1,2,1),
imshow(Im1);
title('灰度图');
figure(2),
subplot(1,2,2),
imhist(Im1);
title('灰度图的直方图'); %显示图像的直方图
Tiao=imadjust(Im1,[0.19,0.78],[0,1]); %调整图片
figure(3),
subplot(1,2,1),
imshow(Tiao);title('增强灰度图');
figure(3),
subplot(1,2,2),
imhist(Tiao);
title('增强灰度图的直方图');
Im2=edge(Tiao,'Roberts','both'); %使用sobel算子进行边缘检测figure(4),
imshow(Im2);
title('sobel算子实现边缘检测')
se=[1;1;1];
Im3=imerode(Im2,se);
figure(5),
imshow(Im3);