




已阅读5页,还剩23页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
计算机图像处理实验报告学院:信息学院班级:电子信息工程姓名:学号:实验内容:数字图像处理1、应用MATLAB语言编写显示一幅灰度图像、二值图像、索引图像及彩色图像的程序,并进行相互之间的转换;(1)、显示一副真彩RGB图像代码:I=imread(cartoon.jpg); %读取彩色图像imshow(I);效果:(2)、RGB转灰度图像代码:graycartoon=rgb2gray(I); %彩色图像转换为灰度图像 subplot(1,2,1); subimage(I); subplot(1,2,2); subimage(graycartoon);效果:(3)、RGB转索引图像代码:indcartoon,map=rgb2ind(I,0.7);%彩色图像转换为索引图像 subplot(1,2,1); subimage(I); subplot(1,2,2); subimage(indcartoon,map);效果:(4)、索引图像转RGB代码:I1=ind2rgb(indcartoon,map);%索引图像转换为彩色图像subplot(1,2,1);subimage(indcartoon,map);subplot(1,2,2);subimage(I1);效果:(5)、索引转灰度图像代码:i2gcartoon=ind2gray(indcartoon,map);%索引图像转换为灰度图像subplot(1,2,1);subimage(indcartoon,map);subplot(1,2,2);subimage(i2gcartoon);效果:(6)、灰度转索引图像代码:g2icartoon,map=gray2ind(graycartoon,64);%灰度转索引图像subplot(1,2,1);subimage(graycartoon);subplot(1,2,2);subimage(g2icartoon,map);效果:(7)、RGB转二值图像代码:r2bwcartoon=im2bw(I,0.5);subplot(1,2,1);subimage(I);subplot(1,2,2);subimage(r2bwcartoon);效果:(8)灰度转二值图像代码:g2bwcartoon=im2bw(graycartoon,0.5);subplot(1,2,1);subimage(graycartoon);subplot(1,2,2);subimage(g2bwcartoon);效果:(9)、索引转二值图像代码:indcartoon,map=rgb2ind(I,0.7); subplot(1,2,1); subimage(I); subplot(1,2,2); subimage(indcartoon,map); i2bwcartoon=im2bw(indcartoon,map,0.7);subplot(1,2,1);subimage(indcartoon,map);subplot(1,2,2);subimage(i2bwcartoon);效果:2、应用MATLAB工具箱演示一幅图像的傅里叶变换、离散余弦变换,观察其频谱图。然后将它们进行逆变换,观察逆变换后的图像;(1)傅里叶正变换代码:F=fft2(graycartoon);subplot(1,2,1);subimage(graycartoon);subplot(1,2,2);subimage(log(abs(F),3,10);效果:(2)傅里叶反变换代码:IF=ifft2(F);subplot(1,2,1);subimage(log(abs(F),3,10);subplot(1,2,2);subimage(uint8(IF);效果:(3)DCT变换代码:B=dct2(graycartoon);subplot(1,2,1);subimage(graycartoon);subplot(1,2,2);subimage(log(abs(B),3,5);效果:(4)iDCT变换代码:iB=idct2(B);subplot(1,2,1);subimage(log(abs(B),3,5);subplot(1,2,2);subimage(uint8(iB);效果:3.应用MATLAB语言编程来实现一幅图像的增强。(1)取一幅灰度图像,对其进行线性点运算,即(,)分别取(1.5,1.2)、(0.7,1.2),分析变化后图像,并分析直方图。代码:graycartoon=double(graycartoon); graycartoon1=1.5*graycartoon+1.2;subplot(2,2,1);subimage(uint8(graycartoon);subplot(2,2,2);imhist(uint8(graycartoon);subplot(2,2,3);subimage(uint8(graycartoon1);subplot(2,2,4);imhist(uint8(graycartoon1);效果:代码2:graycartoon=double(graycartoon); graycartoon1=0.7*graycartoon+1.2;subplot(2,2,1);subimage(uint8(graycartoon);subplot(2,2,2);imhist(uint8(graycartoon);subplot(2,2,3);subimage(uint8(graycartoon1);subplot(2,2,4);imhist(uint8(graycartoon1);效果:分析:a=0.7的时候由于图像对比度的下降所以导致灰度值范围的减小;a=1.5的时候图像对比度增大,故使输出的灰度值范围增大。(2)取一幅灰度图像,对其进行直方图均衡化处理,再对其进行规定化处理,并对结果进行分析。代码:graycartoon=uint8(graycartoon);eqcartoon=histeq(graycartoon);subplot(2,2,1);subimage(graycartoon);subplot(2,2,2);imhist(graycartoon);subplot(2,2,3);subimage(eqcartoon);subplot(2,2,4);imhist(eqcartoon);效果:规定化代码:hgram=50:2:250;speciacartoon=histeq(graycartoon,hgram); subplot(2,2,1);subimage(graycartoon); subplot(2,2,2); imhist(graycartoon); subplot(2,2,3); subimage(speciacartoon); subplot(2,2,4); imhist(speciacartoon);效果:分析: 直方图规定化的优点是能够自动增强整个图像的对比度,缺点是它的具体增强效果不容易控制处理的结果是得到的全局的均衡化直方图。相比这些图像均衡化就有其优势所在:图像均衡化是把一个已知灰度概率密度分布的图像经过某种变化,使其成为一个具有均匀灰度概率密度的分布新图像。其结果的扩展了像元取值的动态范围,从而达到了增强图像整体的对比度。思考题:如果将一幅图像进行一次直方图均衡化处理后,再进行一次直方图均衡化处理,结果会发生变化吗?观察两次均衡化的直方图是否一样。答:代码:A=imread(cartoon.jpg); B=rgb2gray(A); I=histeq(B); %第一次均衡化 I1=histeq(I); %第二次均衡化 subplot(121); imshow(I1); subplot(122); imhist(I1)通过实验分析两次均衡化的直方图一样,不会发生变化,(3)取一幅灰度图像,加入噪声后对其进行平滑滤波(均值滤波、中值滤波),并观察不同滤波方式下的效果。代码:noisecartoon=imnoise(graycartoon,salt & pepper); avecartoon=filter2(fspecial(average,3),noisecartoon)/255;medcartoon=medfilt2(noisecartoon,3,3); subplot(2,2,1);subimage(graycartoon);title(原图); subplot(2,2,2);subimage(noisecartoon);title(加噪声图); subplot(2,2,3);subimage(avecartoon);title(均值平滑图); subplot(2,2,4);subimage(medcartoon);title(中值滤波图);效果:分析:中值滤波是一种非线性滤波所以可以克服线型滤波器所带来的图像细节模糊问题,对滤波脉冲干扰及颗粒噪声效果最好。均值滤波的效果与所使用领域半径的大小有关,半径越大像素点越多,则信噪比提高的越大,平滑效果越好,缺点是平滑图像的模糊程度越大。(4)取一幅灰度图像,采用不同的算子对其进行边缘锐化,并分析结果。代码:sobelcartoon=filter2(fspecial(sobel),graycartoon);prewittcartoon=filter2(fspecial(prewitt),graycartoon);laplaciancartoon=filter2(fspecial(laplacian),graycartoon);subplot(2,2,1);subimage(graycartoon);title(原图);subplot(2,2,2);subimage(sobelcartoon);title(sobel警察);subplot(2,2,3);subimage(prewittcartoon);title(prewitt警察);subplot(2,2,4);subimage(laplaciancartoon);title(laplacian警察);效果:分析:Prewitt算子:一种一阶微分算子的边缘检测,利用像素点上下,左右邻点的灰度差,在边缘处达到极值检测边缘,去掉部分伪边缘,对噪声具有平滑作用。sobel算子:对称的一阶差分,对中心加权具有一定的平滑作用。Laplacian算子:二次微分算子,满足不同走向的图像边缘锐化要求,对噪声的增强作用较弱,一半用它进行边缘增强时,有必要将图像先进行平滑处理。思考题:为了达到边缘锐化的反差增强效果,实际应用中将高频增强和直方图均衡化结合起来使用,这两个操作的次序能互换吗?效果一样吗?I=imread(cartoon.jpg); I=rgb2gray(I); subplot(241),imshow(I);title(原始图像); I1=0,-1,0;-1,5,-1;0,-1,0; I3=imfilter(I,I1); subplot(242),imshow(uint8(I3);title(拉普拉斯算子锐化图像); h=ones(size(I3); f1,f2=freqspace(size(I3),meshgrid); r=sqrt(f1.2+f2.2); h(r0.3)=0; Y=fft2(double(I3); Y=fftshift(Y); y=Y.*h; y=ifftshift(y); I4=ifft2(y); subplot(243),imshow(uint8(I4);title(高频增强图像); I5=histeq(I4); subplot(244),imshow(I5);title(均衡化图像); P=imread(cartoon.jpg); P=rgb2gray(P); subplot(245),imshow(P),title(原始图像); ii=0,-1,0;-1,5,-1;0,-1,0; P1=imfilter(P,I1); subplot(246),imshow(uint8(P1);title(拉普拉斯算子锐化图像); P2=histeq(P1); subplot(248),imshow(P2);title(均衡化图像); J=ones(size(P2); f3,f4=freqspace(size(P2),meshgrid); r1=sqrt(f3.2+f4.2); J(r1blurcartoon=imfilter(graycartoon,PSF,circular,conv); subplot(1,2,1);subimage(graycartoon);title(原图); subplot(1,2,2);subimage(blurcartoon);title(运动糊化的图);效果:逆滤波代码:noise=0.1*randn(size(graycartoon);blurnoicartoon=imadd(blurcartoon,im2uint8(noise);subplot(1,3,3);subimage(blurnoicartoon);wnr1cartoon=deconvwnr(blurcartoon,PSF);%逆滤波wnr1cartoon1=deconvwnr(blurnoicartoon,PSF);%逆滤波figure(2);subplot(1,2,2);subimage(wnr1cartoon);subplot(1,2,1);subimage(wnr1cartoon1);效果:维纳滤波代码:noise=0.1*randn(size(graycartoon);blurnoicartoon=imadd(blurcartoon,im2uint8(noise); wnr2cartoon=deconvwnr(blurnoicartoon,PSF); NSR=sum(noise(:).2)/sum(im2double(graycartoon(:).2); wnr3cartoon=deconvwnr(blurnoicartoon,PSF,NSR); subplot(1,3,1);subimage(blurnoicartoon);title(运动加噪声警察); subplot(1,3,2);subimage(wnr2cartoon);title(维纳滤波警察); subplot(1,3,3);subimage(wnr3cartoon);title(真实信噪比维纳恢复警察);效果:5、应用MATLAB语言编写实现一幅图像的旋转、剪切和缩放;旋转代码:rotatcartoon=imrotate(graycartoon,45,nearest); rotatcartoon1=imrotate(graycartoon,45,bilinear); rotatcartoon2=imrotate(graycartoon,45,bicubic);subplot(2,2,1);subimage(graycartoon);title(原警察);subplot(2,2,2);subimage(rotatcartoon);title(最邻域旋转警察); subplot(2,2,3);subimage(rotatcartoon1);title(双线性旋转警察); subplot(2,2,4);subimage(rotatcartoon2);title(双立方旋转警察);效果:剪切代码:imshow(graycartoon);cro
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025能源集团所属铁法能源公司招聘45人笔试参考题库附带答案详解
- 2025湖南高速养护工程有限公司招聘劳务派遣员工55人(长期)笔试参考题库附带答案详解
- 卸车人员安全培训记录课件
- 2025广东韶关市曲江区国有资产投资经营有限公司招聘驾驶员1人笔试参考题库附带答案详解
- 2025年江西省水投江河信息技术有限公司社会招聘2人笔试参考题库附带答案详解
- 2025年山西大地环境投资控股有限公司所属企业社会招聘79人笔试参考题库附带答案详解
- 2025年中国石油集团昆仑资本有限公司公开招聘正式启动笔试参考题库附带答案详解
- 2025年中国出口信用保险公司浙江分公司校园招聘1人笔试参考题库附带答案详解
- 2025国家电投福建公司招聘1人(总经理)笔试参考题库附带答案详解
- 2025四川华芯鼎泰精密电子有限公司招聘产品设计工程师等岗位34人笔试参考题库附带答案详解
- YC/Z 550-2016卷烟制造过程质量风险评估指南
- 工程水文第3章课件
- GB/T 4032-2013具有摆轮游丝振荡系统的精密手表
- GB/T 34875-2017离心泵和转子泵用轴封系统
- GB/T 21063.4-2007政务信息资源目录体系第4部分:政务信息资源分类
- GA/T 1081-2020安全防范系统维护保养规范
- 02药物不良反应adr课件
- 施工项目成本管理课件
- 文物建筑保护修缮专项方案
- 营销与2008欧锦赛ktv渠道方案
- 故障录波器课件
评论
0/150
提交评论