《图像处理实验1234.doc》由会员分享,可在线阅读,更多相关《图像处理实验1234.doc(18页珍藏版)》请在金锄头文库上搜索。
1、图像处理实验1234实验一 Matlab基本运算1、 按水平和竖直方向分别合并下述两个矩阵: A=1 0 0;1 1 0;0 0 1A = 1 0 0 1 1 0 0 0 1 B=2 3 4;5 6 7;8 9 10B = 2 3 4 5 6 7 8 9 10 C=A BC = 1 0 0 2 3 4 1 1 0 5 6 7 0 0 1 8 9 10 D=A;BD = 1 0 0 1 1 0 0 0 1 2 3 4 5 6 7 8 9 10(1) 分别删除上述两个结果的第2行。 C(2,:)=C = 1 0 0 2 3 4 0 0 1 8 9 10 D(2,:)=D = 1 0 0 0 0 1
2、 2 3 4 5 6 7 8 9 10(2)分别将上述两个结果的第2行最后3列的数值 改为11 12 13。 C(2,4:6)=11 12 13C = 1 0 0 2 3 4 0 0 1 11 12 13 D(2,:)=11 12 13D = 1 0 0 11 12 13 2 3 4 5 6 7 8 9 10(3) 分别查看上述两个结果的各方向长度。 C_SIZE=size(C)C_SIZE = 2 6 D_SIZE=size(D)D_SIZE = 5 3(4) 分别计算上述矩阵A和B的A+B、A.* B、A./B和 AB,分析结果。 AB1=A+BAB1 = 3 3 4 6 7 7 8 9
3、11 AB2=A.*BAB2 = 2 0 0 5 6 0 0 0 10 AB3=A./BAB3 = 0.5000 0 0 0.2000 0.1667 0 0 0 0.1000 AB4=ABAB4 = 2 3 4 3 3 3 8 9 10(5) 计算矩阵A和B的A&B 、 A|B、 A和B,分析结果。 AB5=A&BAB5 = 1 0 0 1 1 0 0 0 1 AB6=A|BAB6 = 1 1 1 1 1 1 1 1 1 AB7=BAB7 = 0 0 0 0 0 0 0 0 0 AB8=AAB8 = 0 1 1 0 0 1 1 1 0(6) 判断上述矩阵A和B中哪些元素值不小于4。 A.*(A
4、=4)ans = 0 0 0 0 0 0 0 0 0 B.*(B=4)ans = 0 0 4 5 6 7 8 9 102、下面是Matlab中有关图像读出、显示和保存函数使用的一段代码:f = imread ( filename); M, N = size( f ); imshow ( f );imwrite (f, filename.jpg) f=imread(filename.jpg); M,N=size(f); imshow(f);Warning: Image is too big to fit on screen; displaying at 56% scale. In truesiz
5、eResize1 at 308 In truesize at 44 In imshow at 161 imwrite(f,filename.jpg)各函数的详细使用方法,请各位查看Matlab中的帮助,使用“help 函数名”即可以查看函数的使用方法。请完成以下内容:(1) 读取文件夹中的图像“pollen.tif.tif”,用imshow(f)和imshow(f, )显示,并将后一幅图存为”pollen1.tif”。思考:为什么图像变清楚了? f=imread(bubbles.tif); imshow(f);Warning: Image is too big to fit on screen
6、; displaying at 75% scale. In truesizeResize1 at 308 In truesize at 44 In imshow at 161 figure,imshow(f,);Warning: Image is too big to fit on screen; displaying at 75% scale. In truesizeResize1 at 308 In truesize at 44 In imshow at 161(2) 用不同的压缩参数(80,50,10)将bubbles.tif 保存为jpeg图像,比较压缩参数的作用, 并通过imfinf
7、o获取文件信息了解图像的压缩情况对图像质量的影响 imwrite(f,bubbles1.jpg,quality,80); g=imread(bubbles1.jpg); imshow(g);Warning: Image is too big to fit on screen; displaying at 75% scale. In truesizeResize1 at 308 In truesize at 44 In imshow at 161 imwrite(f,bubbles2.jpg,quality,50); g1=imread(bubbles2.jpg); figure,imshow(
8、g1);Warning: Image is too big to fit on screen; displaying at 75% scale. In truesizeResize1 at 308 In truesize at 44 In imshow at 161 imwrite(f,bubbles3.jpg,quality,10); g2=imread(bubbles3.jpg); figure,imshow(g2);Warning: Image is too big to fit on screen; displaying at 75% scale. In truesizeResize1
9、 at 308 In truesize at 44 In imshow at 161 imfinfo(bubbles1.jpg)ans = Filename: bubbles1.jpg FileModDate: 26-Sep-2014 00:01:44 FileSize: 39129 Format: jpg FormatVersion: Width: 720 Height: 688 BitDepth: 8 ColorType: grayscale FormatSignature: NumberOfSamples: 1 CodingMethod: Huffman CodingProcess: S
10、equential Comment: imfinfo(bubbles2.jpg)ans = Filename: bubbles2.jpg FileModDate: 26-Sep-2014 00:02:46 FileSize: 20068 Format: jpg FormatVersion: Width: 720 Height: 688 BitDepth: 8 ColorType: grayscale FormatSignature: NumberOfSamples: 1 CodingMethod: Huffman CodingProcess: Sequential Comment: imfinfo(bubbles3.jpg)ans = Filename: bubbles3.jpg FileModDate: 26-Sep-2014 00:03:29 FileSize: 9498 Format: jpg FormatVersion: Width: 720 Height: 688 BitDepth: 8 ColorType: grayscale FormatSignature: NumberOfSamples: 1