- 1、本文档共33页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
matlab 图像分割算法源码图像读取及灰度变换
I=imread(cameraman.tif);%读取图像subplot(1,2,1),imshow(I) %输出图像title(原始图像) %在原始图像中加标题subplot(1,2,2),imhist(I) %输出原图直方图
title(原始图像直方图) %在原图直方图上加标题图像旋转
figure,imshow(I);theta = 30;
figure,imshow(I);
theta = 30;
K = imrotate(I,theta); % Try varying the angle, theta. figure, imshow(K)
边缘检测
I = imread(cameraman.tif); J1=edge(I,sobel); J2=edge(I,prewitt); J3=edge(I,log);
subplot(1,4,1),imshow(I);
subplot(1,4,2),imshow(J1);
subplot(1,4,3),imshow(J2);
subplot(1,4,4),imshow(J3);
1.图像反转
MATLAB 程序实现如下:
I=imread(xian.bmp);
J=double(I); J=-J+(256-1);
%图像反转线性变换
H=uint8(J);
subplot(1,2,1),imshow(I);
subplot(1,2,2),imshow(H);
2.灰度线性变换
MATLAB 程序实现如下: I=imread(xian.bmp); subplot(2,2,1),imshow(I); title(原始图像);
axis([50,250,50,200]);
axis on;
%显示坐标系
I1=rgb2gray(I);
subplot(2,2,2),imshow(I1); title( 灰 度 图 像 ); axis([50,250,50,200]);
axis on; %显示坐标系
J=imadjust(I1,[0.1 0.5],[]); %局部拉伸,把[0.1 0.5]内的灰度拉伸为[0 1] subplot(2,2,3),imshow(J);
title(线性变换图像[0.1 0.5]);
axis([50,250,50,200]);
grid on; %显示网格线
axis on; %显示坐标系
K=imadjust(I1,[0.3 0.7],[]); %局部拉伸,把[0.3 0.7]内的灰度拉伸为[0 1] subplot(2,2,4),imshow(K);
title(线性变换图像[0.3 0.7]);
axis([50,250,50,200]);
grid on; %显示网格线
axis on; %显示坐标系
非线性变换
MATLAB 程序实现如下: I=imread(xian.bmp); I1=rgb2gray(I); subplot(1,2,1),imshow(I1); title( 灰 度 图 像 ); axis([50,250,50,200]);
grid on; %显示网格线
axis on; %显示坐标系J=double(I1);
J=40*(log(J+1));
H=uint8(J); subplot(1,2,2),imshow(H); title(对数变换图像); axis([50,250,50,200]);
grid on; %显示网格线
axis on; %显示坐标系
直 方 图 均 衡 化 MATLAB 程序实现如下: I=imread(xian.bmp); I=rgb2gray(I);
figure; subplot(2,2,1); imshow(I); subplot(2,2,2); imhist(I); I1=histeq(I); figure; subplot(2,2,1); imshow(I1); subplot(2,2,2); imhist(I1);
线性平滑滤波器
用 MATLAB 实现领域平均法抑制噪声程序: I=imread(xian.bmp);
subplot(231) imshow(I) title(原始图像) I=rgb2gray(I);
I1=imnoise(I,salt pepper,0.02); subplot(232)
imshow(I1)
title(添加椒盐噪声的图像)
k1=filter2(fspecial(average,3),I1)/255; %进行 3*3 模板平滑滤波k2=filter2(fspecial(average,5),I1)/255; %进行 5*5 模板平滑滤波k3=filter2(fspecial(average,7),I
文档评论(0)