




免费预览已结束,剩余3页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
MATLAB图像增强程序举例1.灰度变换增强程序:% GRAY TRANSFORMclc;I=imread(pout.tif);imshow(I);J=imadjust(I,0.3 0.7,0 1,1);%transforms the walues in the %intensity image I to values in J by linealy mapping %values between 0.3 and 0.7 to values between 0 and 1.figure;imshow(J);J=imadjust(I,0.3 0.7,0 1,0.5);% if GAMMA is less than 1,the mapping si weighted toward higher (brighter)%output values.figure;imshow(J);J=imadjust(I,0.3 0.7,0 1,1.5);% if GAMMA is greater than 1,the mapping si weighted toward lower (darker)%output values.figure;imshow(J)J=imadjust(I,0.3 0.7,0 1,1);% If TOPBOTTOM,the output image is reversed,as in a photographic negative.figure;imshow(J);2.直方图灰度变换%直方图灰度变换X,map=imread(forest.tif);I=ind2gray(X,map);%把索引图像转换为灰度图像imshow(I);title(原图像);improfile%用鼠标选择一条对角线,显示线段的灰度值figure;subplot(121)plot(0:0.01:1,sqrt(0:0.01:1)axis squaretitle(平方根灰度变换函数)subplot(122)maxnum=double(max(max(I);%取得二维数组最大值J=sqrt(double(I)/maxnum);%把数据类型转换成double,然后进行平方根变换%sqrt函数不支持uint8类型J=uint8(J*maxnum);%把数据类型转换成uint8类型imshow(J)title(平方根变换后的图像)3.直方图均衡化程序举例% HISTGRAM EAQUALIZATIONclc;% Clear command windowI=imread(tire.tif);% reads the image in tire.tif into Iimshow(I);% displays the intensity image I with 256 gray levelsfigure;%creates a new figure windowimhist(I);% displays a histogram for the intensity image IJ=histeq(I,64);% transforms the intensity image I,returning J an intensityfigure;%image with 64 discrete levelsimshow(J);figure;imhist(J);J=histeq(I,32);%transforms the intensity image ,returning in % J an intensityfigure;%image with 32 discrete levelsimshow(J);figure;imhist(J);4.直方图规定化程序举例% HISTGRAM REGULIZATIONclc;%Clear command windowI=imread(tire.tif);%reads the image in tire.tif into IJ=histeq(I,32);%transforms the intensity image I,returning in%J an intensity image with 32 discrete levelscounts,x=imhist(J);%displays a histogram for the intensity image IQ=imread(pout.tif);%reads the image in tire.tif into Ifigure;imshow(Q);figure;imhist(Q);M=histeq(Q,counts);%transforms the intensity image Q so that the%histogram of the output image M approximately matches countsfigure;imshow(M);figure;imhist(M);空域滤波增强部分程序1.线性平滑滤波I=imread(eight.tif);J=imnoise(I,salt & pepper,0.02);subplot(221),imshow(I)title(原图像)subplot(222),imshow(J)title(添加椒盐噪声图像)K1=filter2(fspecial(average,3),J)/255;%应用3*3邻域窗口法subplot(223),imshow(K1)title(3x3窗的邻域平均滤波图像)K2=filter2(fspecial(average,7),J)/255;%应用7*7邻域窗口法subplot(224),imshow(K2)title(7x7窗的邻域平均滤波图像)2.中值滤波器MATLAB中的二维中值滤波函数medfit2来进行图像中椒盐躁声的去除%IMAGE NOISE REDUCTION WITH MEDIAN FILTERclc;hood=3;%滤波窗口I,map=imread(eight.tif);imshow(I,map);noisy=imnoise(I,salt & pepper,0.05);figure;imshow(noisy,map);filtered1=medfilt2(noisy,hood hood);figure;imshow(filtered1,map);hood=5;filtered2=medfilt2(noisy,hood hood);figure;imshow(filtered2,map);hood=7;filtered3=medfilt2(noisy,hood hood);figure;imshow(filtered3,map);3. 4邻域8邻域平均滤波算法% IMAGE NOISE REDUCTION WITH MEAN ALGORITHMclc;I,map=imread(eight.tif);noisy=imnoise(I,salt & pepper,0.05);myfilt1=0 1 0;1 1 1;0 1 0;%4邻域平均滤波模版myfilt1=myfilt1/9;%对模版归一化filtered1=filter2(myfilt1,noisy);imshow(filtered1,map);myfilt2=1 1 1;1 1 1;1 1 1;myfilt2=myfilt2/9;filtered2=filter2(myfilt2,noisy);figure;imshow(filtered2,map);频域增强程序举例1.低通滤波器% LOWPASS FILTERclc;I,map=imread(eight.tif);noisy=imnoise(I,gaussian,0.05);imshow(noisy,map);myfilt1=1 1 1;1 1 1;1 1 1;myfilt1=myfilt1/9;filtered1=filter2(myfilt1,noisy);figure;imshow(filtered1,map);myfilt2=1 1 1;1 2 1;1 1 1;myfilt2=myfilt2/10;filtered2=filter2(myfilt2,noisy);figure;imshow(filtered2,map);myfilt3=1 2 1;2 4 2; 1 2 1;myfilt3=filter2(myfilt3,noisy);figure;imshow(filtered3,map);2.布特沃斯低通滤波器图像实例I=imread(saturn.png);J=imnoise(I,salt & pepper,0.02);subplot(121),imshow(J)title(含噪声的原图像)J=double(J);f=fft2(J);g=fftshift(f);M,N=size(f);n=3;d0=20;n1=fl
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 屋面抗震伸缩缝施工方案
- 保洁拖把池施工方案设计
- 2025包装物品买卖合同
- 高速公路告示牌施工方案
- 改装项目收购方案范本
- 2025租赁合同参考范本
- 展览会吊点施工方案
- 教育药师考试试题及答案
- 模具温度控制器施工方案
- 吴忠篮球场地坪施工方案
- 高血压的中医食疗与养生
- 中医体质量表
- 明清传奇小说
- 荐五年级上册第三单元习作猎人海力布故事缩写两个基本方法
- 初中生物学教材解读人教八年级上册生物圈中的其他生物江艾佳细菌八年级上册生物
- GA 1809-2022城市供水系统反恐怖防范要求
- 2022年全国工会财务知识大赛参考题库精简600题(含各题型)
- GB/T 2072-2007镍及镍合金带材
- GB/T 13460-2016再生橡胶通用规范
- 基础观感验收自评报告
- 班级管理(第3版)教学课件汇总全套电子教案(完整版)
评论
0/150
提交评论