预览加载中,请您耐心等待几秒...
1/9
2/9
3/9
4/9
5/9
6/9
7/9
8/9
9/9

在线预览结束,喜欢就下载吧,查找使用更方便

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

实验四图像分割与边缘检测 一.实验目的及要求 1.利用MATLAB研究图像分割与边缘检测的常用算法原理; 2.掌握MATLAB图像域值分割与边缘检测函数的使用方法; 3.了解边缘检测的算法和用途,比较Sobel、Prewitt、Canny等算子边缘检测的差异。 二、实验内容 (一)研究以下程序,分析程序功能;输入执行各命令行,认真观察命令执行的结果。熟悉程序中所使用函数的调用方法,改变有关参数,观察试验结果。 1.图像阈值分割 clearall,closeall; I=imread('cameraman.tif'); figure(1),imshow(I) figure(2);imhist(I) T=120/255; Ibw1=im2bw(I,T); figure(3); subplot(1,2,1),imshow(Ibw1); T=graythresh(I); L=uint8(T*255) Ibw2=im2bw(I,T); subplot(1,2,2),imshow(Ibw2); helpim2bw; helpgraythresh; clearall,closeall; I=imread('cameraman.tif'); figure(1),imshow(I) figure(2);imhist(I) T=240/255; Ibw1=im2bw(I,T); figure(3); subplot(1,2,1),imshow(Ibw1); T=graythresh(I); L=uint8(T*255) Ibw2=im2bw(I,T); subplot(1,2,2),imshow(Ibw2); helpim2bw; helpgraythresh; clearall,closeall; I=imread('cameraman.tif'); figure(1),imshow(I) figure(2);imhist(I) T=120/255; Ibw1=im2bw(I,T); figure(3); subplot(1,2,1),imshow(Ibw1); T=graythresh(I); L=uint8(T*255) Ibw2=im2bw(I,T); subplot(1,2,2),imshow(Ibw2); helpim2bw; helpgraythresh; 2.边缘检测 clearall,closeall; I=imread('moon.tif'); BW1=edge(I,'sobel'); BW2=edge(I,'canny'); BW3=edge(I,'prewitt'); BW4=edge(I,'roberts'); BW5=edge(I,'log'); figure(1),imshow(I),title('OriginalImage'); figure(2),imshow(BW1),title('sobel'); figure(3),imshow(BW2),title('canny'); figure(4),imshow(BW3),title('prewitt'); figure(5),imshow(BW4),title('roberts'); figure(6),imshow(BW5),title('log'); helpedge edgedemo (二)利用MATLAB熟悉并验证其它图像分割方法 灰度阈值分割: I=imread('C:\Users\Administrator\Desktop\rice.jpg'); I=rgb2gray(I); I2=im2bw(I); figure,imshow(I2); I2=im2bw(I,140/255); figure,imshow(I2) 区域分割法: I=imread('eight.tif'); imshow(I) c=[222272300270221194]; r=[21 21 75 121121 75]; BW=roipoly(I,c,r); figure,imshow(BW) H=fspecial('unsharp'); J1=roifilt2(H,I,BW); figure,imshow(J1) J2=roifill(I,c,r); figure,imshow(J2) 分水岭分割法: f=imread('C:\Users\Administrator\Desktop\cell.jpg'); imshow(f); g=im2bw(f,graythresh(f)); figure,imshow(g); gc=~g; D=bwdist(gc); L=watershed(-D); w=L==0; g2=g&~w; figure,imshow(g2) (三)采用