深 圳 大 学 实 验 报 告
课程名称: 数字图像处理
实验项目名称: 数字图像的基本操作与代数运算
学院: 信息工程学院
专业: 电子信息工程
指导教师: **
报告人: 许儒满 学号: ********** 班级: 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; clear all; close all; 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: [1x42 char] FileModDate: '04-十二月-2000 13:57:56' FileSize: 59640 Format: 'tif' FormatVersion: [] Width: 308 Height: 242 BitDepth: 8 ColorType: 'grayscale' FormatSignature: [73 73 42 0] ByteOrder: 'little-endian' NewSubFileType: 0 BitsPerSample: 8 Compression: 'PackBits' PhotometricInterpretation: 'BlackIsZero' StripOffsets: [10x1 double] SamplesPerPixel: 1 RowsPerStrip: 26 StripByteCounts: [10x1 double] XResolution: 72 YResolution: 72 ResolutionUnit: 'None' Colormap: [] PlanarConfiguration: 'Chunky' TileWidth: [] TileLength: [] TileOffsets: [] TileByteCounts: [] Orientation: 1 FillOrder: 1 GrayResponseUnit: 0.0100 MaxSampleValue: 255 MinSampleValue: 0 Thresholding: 1 Offset: 59318 ImageDescription: [1x50 char] c2 = Filename: 'D:\\matleb\\bin\\exp1_img\\flowers.tif' FileModDate: '17-九月-2013 10:34:34' FileSize: 157460 Format: 'tif' FormatVersion: [] Width: 500 Height: 362 BitDepth: 8 ColorType: 'indexed' FormatSignature: [73 73 42 0] ByteOrder: 'little-endian' NewSubFileType: 0 BitsPerSample: 8 Compression: 'PackBits' PhotometricInterpretation: 'RGB Palette' StripOffsets: [23x1 double] SamplesPerPixel: 1 RowsPerStrip: 16 StripByteCounts: [23x1 double] XResolution: 72 YResolution: 72 ResolutionUnit: 'Inch' Colormap: [256x3 double] PlanarConfiguration: 'Chunky' TileWidth: [] TileLength: [] TileOffsets: [] TileByteCounts: [] Orientation: 1 FillOrder: 1 GrayResponseUnit: 0.0100 MaxSampleValue: 255 MinSampleValue: 0 Thresholding: 1 Offset: 155538 c3 = Filename: 'D:\\matleb\\bin\\exp1_img\\RGBimageA.tiff' FileModDate: '03-十一月-2011 12:39:12' FileSize: 786572 Format: 'tif' FormatVersion: [] Width: 512 Height: 512 BitDepth: 24 ColorType: 'truecolor' FormatSignature: [77 77 0 42] ByteOrder: 'big-endian' NewSubFileType: 0 BitsPerSample: [8 8 8] Compression: 'Uncompressed' PhotometricInterpretation: 'RGB' StripOffsets: 8 SamplesPerPixel: 3 RowsPerStrip: 4.2950e+09 StripByteCounts: 786432 XResolution: [] YResolution: [] ResolutionUnit: 'None' Colormap: [] PlanarConfiguration: 'Chunky' TileWidth: [] TileLength: [] TileOffsets: [] TileByteCounts: [] Orientation: 1 FillOrder: 1 GrayResponseUnit: 0.0100 MaxSampleValue: [255 255 255] MinSampleValue: [0 0 0] Thresholding: 1 Offset: 786440 有结果可知eight.peng为灰度图像、flowers.tiff为索引图像、RGBimageA.tiff为RGB真彩色图像。 2 %实验二 clc; clear all; close all; 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; clear all; close all; 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; clear all; close all; X=imread('D:\\matleb\\bin\\exp1_img\\RGBimageB.tiff'); imwrite(X,'RGBimageB.jpg','jpg'); 5 %实验五 clc; clear all; close all; 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; for i = 1 : 5 J = imnoise(X, 'gaussian', 0, 0.02); J1 = im2double(J); K1 = K1 + J1; end K1= K1/5 ; for i = 1 : 50 J = imnoise(X, 'gaussian', 0, 0.02); J2 = im2double(J); K2 = K2 + J2; end K2= K2/50 ; for i = 1 : 500 J = imnoise(X, 'gaussian', 0, 0.02); J3 = im2double(J); K3= K3 + J3; end K3= 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; clear all; close all; 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分 指导教师签字: 年 月 日 备注:
因篇幅问题不能全部显示,请点此查看更多更全内容