您好,欢迎访问三七文档
深圳大学实验报告课程名称:数字图像处理实验项目名称:数字图像的基本操作与代数运算学院:信息工程学院专业:电子信息工程指导教师:李斌报告人:许儒满学号:2013130056班级:1实验时间:2016/3/7实验报告提交时间:教务部制实验目的与要求:1、了解MATLAB语言的基本用法;2、掌握MATLAB语言中图像数据与信息的读写方法;3、熟悉在MATLAB中对图像的类型、图像文件的格式进行转换的方法;4、理解数字图像处理中代数运算的基本作用;掌握在MTLAB中对图像进行代数运算的方法。实验内容:1对各RGB图像、索引图像、灰度图像,用imread读出图像文件,并用imshow将图像显示出来,并用iminfo给出图像信息。观察一下图像数据的特点,理解数字图像在MATLAB中的处理就是处理一个矩阵,根据图像文件信息和图像数据矩阵的特点,确定图像的类型,体会各自数据的特点。程序2选择一幅RGB彩色图像(图像RGBimageA),分别显示出原图像和R、G、B三个分量图像(用subplot函数显示在同一窗口中),观察对比它们的特点,体会不同颜色所对应的R、G、B分量的不同之处。3.将图像A中心部分选取出来,显示中心部分,并保存为与图像A相同格式的图像文件。4选择一幅RGB图像(图像RGBimageB),使用imread和imwrite进行图像文件格式的相互转换(TIFF与JPG相互转换)5、给灰度图像加入高斯噪声,并显示。运用for循环,分别将5幅、50幅和500幅加有随机高斯噪声的图像进行相加并求其平均值。将几种求平均后的图像显示在同一图像对话框中,比较其结果。6、自行下载两幅的图像,进行相加、相减、相乘的代数运算(注意运算时候图像的尺寸、类型等,如果不同,应使将尺寸较大的图像裁剪或缩放),显示运算之前和运算之后的图像。7、选择一幅索引图像,将图像文件读出,并将这个图像显示出来。尝试修改MAP颜色矩阵的值,再将图像显示出来,观察图像颜色的变化。(选做)实验代码及结果:%实验一clc;clearall;closeall;X1=imread('eight.tif');subplot(2,2,1);imshow(X1);title('eight');c1=imfinfo('eight.tif')X2=imread('D:\matleb\bin\exp1_img\flowers.tif');subplot(2,2,2);imshow(X2);title('flowers');c2=imfinfo('D:\matleb\bin\exp1_img\flowers.tif')X3=imread('D:\matleb\bin\exp1_img\RGBimageA.tiff');subplot(2,2,3);imshow(X3);title('RGBimageA');c3=imfinfo('D:\matleb\bin\exp1_img\RGBimageA.tiff')与原图对比可知,X1、X3与原图一致,而X2则由原来的色彩图像变为灰白图。c1=Filename:[1x42char]FileModDate:'04-十二月-200013:57:56'FileSize:59640Format:'tif'FormatVersion:[]Width:308Height:242BitDepth:8ColorType:'grayscale'FormatSignature:[7373420]ByteOrder:'little-endian'NewSubFileType:0BitsPerSample:8Compression:'PackBits'PhotometricInterpretation:'BlackIsZero'StripOffsets:[10x1double]SamplesPerPixel:1RowsPerStrip:26StripByteCounts:[10x1double]XResolution:72YResolution:72ResolutionUnit:'None'Colormap:[]PlanarConfiguration:'Chunky'TileWidth:[]TileLength:[]TileOffsets:[]TileByteCounts:[]Orientation:1FillOrder:1GrayResponseUnit:0.0100MaxSampleValue:255MinSampleValue:0Thresholding:1Offset:59318ImageDescription:[1x50char]c2=Filename:'D:\matleb\bin\exp1_img\flowers.tif'FileModDate:'17-九月-201310:34:34'FileSize:157460Format:'tif'FormatVersion:[]Width:500Height:362BitDepth:8ColorType:'indexed'FormatSignature:[7373420]ByteOrder:'little-endian'NewSubFileType:0BitsPerSample:8Compression:'PackBits'PhotometricInterpretation:'RGBPalette'StripOffsets:[23x1double]SamplesPerPixel:1RowsPerStrip:16StripByteCounts:[23x1double]XResolution:72YResolution:72ResolutionUnit:'Inch'Colormap:[256x3double]PlanarConfiguration:'Chunky'TileWidth:[]TileLength:[]TileOffsets:[]TileByteCounts:[]Orientation:1FillOrder:1GrayResponseUnit:0.0100MaxSampleValue:255MinSampleValue:0Thresholding:1Offset:155538c3=Filename:'D:\matleb\bin\exp1_img\RGBimageA.tiff'FileModDate:'03-十一月-201112:39:12'FileSize:786572Format:'tif'FormatVersion:[]Width:512Height:512BitDepth:24ColorType:'truecolor'FormatSignature:[7777042]ByteOrder:'big-endian'NewSubFileType:0BitsPerSample:[888]Compression:'Uncompressed'PhotometricInterpretation:'RGB'StripOffsets:8SamplesPerPixel:3RowsPerStrip:4.2950e+09StripByteCounts:786432XResolution:[]YResolution:[]ResolutionUnit:'None'Colormap:[]PlanarConfiguration:'Chunky'TileWidth:[]TileLength:[]TileOffsets:[]TileByteCounts:[]Orientation:1FillOrder:1GrayResponseUnit:0.0100MaxSampleValue:[255255255]MinSampleValue:[000]Thresholding:1Offset:786440有结果可知eight.peng为灰度图像、flowers.tiff为索引图像、RGBimageA.tiff为RGB真彩色图像。2%实验二clc;clearall;closeall;X=imread('D:\matleb\bin\exp1_img\RGBimageA.tiff');subplot(2,2,1);imshow(X);title('Ôͼ');subplot(2,2,2)imshow(X(:,:,1));title('Rͼ');subplot(2,2,3)imshow(X(:,:,2));title('Gͼ');subplot(2,2,4)imshow(X(:,:,3));title('Bͼ');3%实验三clc;clearall;closeall;X=imread('D:\matleb\bin\exp1_img\RGBimageA.tiff');X2=imcrop(X,[100,100,400,425]);imwrite(X2,'RGBimageA2.tiff')subplot(1,2,1)imshow(X);title('Ôͼ');subplot(1,2,2)imshow(X2);title('¼ô²Ãͼ');4%实验四clc;clearall;closeall;X=imread('D:\matleb\bin\exp1_img\RGBimageB.tiff');imwrite(X,'RGBimageB.jpg','jpg');5%实验五clc;clearall;closeall;X=imread('D:\matleb\bin\exp1_img\eight.png');J=imnoise(X,'gaussian',0,0.02);subplot(2,2,1);imshow(X);title('原图像');subplot(2,2,2);imshow(J);title('加高斯噪声');[m,n]=size(X);K=zeros(m,n);K1=K;K2=K;K3=K;fori=1:5J=imnoise(X,'gaussian',0,0.02);J1=im2double(J);K1=K1+J1;endK1=K1/5;fori=1:50J=imnoise(X,'gaussian',0,0.02);J2=im2double(J);K2=K2+J2;endK2=K2/50;fori=1:500J=imnoise(X,'gaussian',0,0.02);J3=im2double(J);K3=K3+J3;endK3=K3/5;%求图像的平均figure;subplot(2,2,1)imshow(K1)title('5副相加求平均的图像');subplot(2,2,2)imshow(K2)title('50副相加求平均的图像');subplot(2,2,3)imshow(K3)title('500副相加求平均的图像');由图可知,50副加随机噪声的图相加求平均结果最佳。6%实验六clc;clearall;closeall;X=imread('D:\matleb\bin\exp1_img\cat1.jpg');J=imread('D:\matleb\bin\exp1_img\cat2.jpg');J1=imresize(J,[240,220]);K1=imadd(X,J1);K2=imsubtract(X,J1);K3=immultiply(X,J1);subplot(2,3,1)imshow(X)title('cat1原图');subplot(2,3,2)imshow(J)title('cat2原图');subplot(2,3,3)imshow(J1)title('cat2缩放');subplot(2,3,4)imshow(K1)title('相加');subplot(2,3,5)imshow(K2)title('相减');subplot(2,3,6)imshow(K3)title('相乘');指导教师批阅意见:成绩评定:实验态度20分实验设计与操作50分实验报告30分指导教师签字:年月日备注:
本文标题:数字图象处理实验一
链接地址:https://www.777doc.com/doc-2388017 .html