MATLAB图像处理的初步练习1

上传人:夏** 文档编号:557337092 上传时间:2024-01-08 格式:DOC 页数:21 大小:1.67MB
返回 下载 相关 举报
MATLAB图像处理的初步练习1_第1页
第1页 / 共21页
MATLAB图像处理的初步练习1_第2页
第2页 / 共21页
MATLAB图像处理的初步练习1_第3页
第3页 / 共21页
MATLAB图像处理的初步练习1_第4页
第4页 / 共21页
MATLAB图像处理的初步练习1_第5页
第5页 / 共21页
点击查看更多>>
资源描述

《MATLAB图像处理的初步练习1》由会员分享,可在线阅读,更多相关《MATLAB图像处理的初步练习1(21页珍藏版)》请在金锄头文库上搜索。

1、数字图象处理实验实验报告实验一 MATLAB图像处理的初步练习一实验目的1、熟悉图像处理的基本操作(读入、保存、显示图像);2、熟悉图像运算操作;3、掌握灰度直方图的概念及计算方法。二实验内容v 图像矩阵的读入和保存方法1、图像函数的读入:1) 原图像: A=imread(www.gif); 2) 原图像: B,X=imread(butterfly-0030.jpg);2、图像文件的写入: imwrite(A,weixingtu.jpg)重读后的图像:3、保存图像数据文件及调用: save A load A v 常用图像类型及类型转换1图像类型查看:1)2) isrgb(A)Warning:

2、isrgb is obsolete and may be removed in the future.See product release notes for more information. In isrgb at 29ans = 0 isind(A)Warning: isind is obsolete and may be removed in the future.See product release notes for more information. In isind at 32ans = 1 isgray(A)Warning: isgray is obsolete and

3、may be removed in the future.See product release notes for more information. In isgray at 27ans = 1 isbm(A)? Undefined function or method isbm for input arguments of type uint8. 2类型转换: A=imread(www.gif); B,X=gray2ind(A,64); C,Y=gray2ind(A,64); A=ind2gray(C,Y)图像矩阵的显示方法1) A=imread(lena.gif); subplot(2

4、,2,1);imshow(A) subplot(2,2,2);imshow(A,50,150) subplot(2,2,3);imshow(A,20,70) subplot(2,2,4);imshow(A,70,100) 原图:处理后:2) 同一窗口显示多幅图像 A=imread(building-0009.JPG); B=imread(chute-0042.jpg); C=imread(fruit-0052.jpg); D=imread(浪漫.jpg); subplot(2,2,1);imshow(A) subplot(2,2,2);imshow(B) subplot(2,2,3);imsh

5、ow(C) subplot(2,2,4);imshow(D)v 图像矩阵的基本运算1、图像的点运算:1) A=imread(lena.gif); B=A*0.5; imshow(A) title(原图) figure imshow(B) title(点运算后图) 2) A=imread(lena.gif); B=60+A; subplot(1,2,1);imshow(A);title(原图) subplot(1,2,2);imshow(B);title(处理后的图像) 2、图像的代数运算:1) A=imread(rice.png); B=imread(lena.gif); Y=imadd(A,

6、B); X=imsubtract(A,B); Z=immultiply(A,B); W=imdivide(A,B); figure(1) imshow(A) title(rice原图) figure imshow(B) title(lena原图) figure imshow(Y) title(lena与rice和图) figure imshow(X) title(lena与rice差图) figure imshow(Z) title(lena与rice乘图) figure imshow(W) title(lena与rice除图) 2) A=imread(lena.gif); B=A*0.5;

7、C=imread(lena.gif); D=C*0.5; M=immultiply(B,D); N=imdivide(B,D); subplot(2,2,1);imshow(A);title(rice原图) subplot(3,2,1);imshow(A);title(rice原图) subplot(3,2,2);imshow(C);title(rice原图) subplot(3,2,1);imshow(A);title(lena原图) subplot(3,2,2);imshow(C);title(rice原图) subplot(3,2,3);imshow(B);title(lena压幅图)

8、subplot(3,2,4);imshow(D);title(rice压幅图) subplot(3,2,5);imshow(M);title(B*D) subplot(3,2,6);imshow(N);title(B/D)3)图像数据与数相乘: I = imread(lena.gif); J = immultiply(I,2); subplot(1,2,1); imshow(I); subplot(1,2,2); imshow(J);4)图像数据与数相除: I1=double(I); J=I/2; J1=uint8(J); subplot(1,2,1); imshow(I); subplot(

9、1,2,2); imshow(J);v 图像几何运算:1图像的插值放大: I = imread(lena.gif); I2=imresize(I,2,bilinear); %双线性插值调整大小为原来的2倍 imshow(I) title(原图) figure;imshow(I2) title(放大图) I = imread(lena.gif); I2=imresize(I,0.5,bilinear); %双线性插值调整大小为原来的0.5倍 imshow(I) title(原图) figure;imshow(I2) title(缩小图) 2、图像旋转: I = imread(lena.gif);

10、 I1=imrotate(I,60,nearest); I2=imrotate(I,60,bilinear); I3=imrotate(I,60,bicubic); subplot(2,2,1);imshow(I);title(原图) subplot(2,2,2);imshow(I1);title(最近邻元法) subplot(2,2,3);imshow(I2);title(双线性法) subplot(2,2,4);imshow(I3);title(双三插值法) 3、图像切割: I = imread(lena.gif); I2=imcrop(I,50,100,150,150); imshow(

11、I);title(原图) figure;imshow(I2);title(切割后) I = imread(fruit-0052.jpg); I2=imcrop(I,50,80,150,150); imshow(I);title(原图) figure;imshow(I2);title(切割后) v 利用MATLAB编程实现下面图像的灰度直方图 I=0 1 3 2 1 3 2 1;0 5 7 6 2 5 6 7;1 6 0 6 1 6 3 4;2 6 7 5 3 5 6 5;3 2 2 7 2 6 1 6;2 6 5 0 2 7 5 01 2 3 2 1 2 1 2;3 1 2 3 1 2 2 1

12、; imshow(I) M,N=size(I); %测量图像尺寸参数 A=zeros(1,8); %创建存放灰度出现概率的向量 for k=0:7 A(k+1)=length(find(I=k)/(M*N); %计算每级灰度出现的概率,将其存入A中相应位置end figure,bar(0:7,A,g) %绘制直方图 title(图像直方图) xlabel(灰度值) ylabel(出现概率) 三、思考题:1、对图像进行描述的数据信息一般有哪些形式? 解答:对图像进行描述的数据信息一般有以下形式:logical(二进制图像)、uint8或double(灰度图像)。2、灰度图像有什么特点?解答:灰度

13、图像是每个像素只有一个采样颜色的图像,这类图像通常显示为从最暗黑色到最亮的白色的灰度,理论上这个采样可以表示颜色的不同深浅,甚至可以是不同亮度上的不同颜色。灰度图像与黑白图像不同,在计算机图像领域中黑白图像只有黑色与白色两种颜色;但是,灰度图像在黑色与白色之间还有许多级的颜色深度,嘿白图像是灰度图像的一种特殊形式。灰度图像的数据是一个mn的二维矩阵,其形式有uint8和logical两种,一般为256256的uint8形式的数据,量化范围一般为0255。3、简述灰度级分辨率变化对图像视觉效果影响。 解答:图像的分辨率越高,视觉上越清晰,连续性越强,而且细节也愈加丰富,图像的简便性越强;反之,图像的分辨率太低,则不能正确反映一个图像的状态

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 建筑/环境 > 施工组织

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号