Matlab圖像处理实验指导书(1-6).doc
文本预览下载声明
河南工业大学
《 数字图像处理 》课程
实 验 指 导 书
信息科学与工程学院
2011年3月
实验一 Matlab图像显示方法
一、实验目的
了解Matlab的基本功能及操作方法
练习图像读写和显示函数的使用方法
掌握Matlab支持的五类图像的显示方法
二、实验内容
图像的读写 %matlab自带图像在安装路径下 \toolbox\images\imdemosRGB = imread(ngc6543a.jpg);
图像写
先从一个.mat 文件中载入一幅图像,然后利用图像写函数imwrite,创建一个.bmp文件,并将图像存入其中。
load clown
whos
imwrite(X,map,clown.bmp)
图像文件格式转换
bitmap = imread(clown.bmp,bmp);
imwrite(bitmap,clown.png,png);
图像显示
二进制图像的显示
BW1=zeros(20,20); %创建仅包含0/1的双精度图像
BW1(2:2:18,2:2:18)=1;
imshow(BW1,notruesize); %double类型[0,1]
whos
BW2=uint8(BW1);
figure,imshow(BW2,notruesize)
figure,imshow(BW2,[],notruesize) %uint8类型[0,255]
BW3=BW2~=0; %逻辑标志置为on
figure,imshow(BW3,notruesize)
whos
灰度图像的显示
I=imread(spine.tif);
J=filter2([1 2;-1 -2],I);
imshow(I,[])
figure,imshow(J,[])
索引图像的显示
load clown %装载一幅图像
imwrite(X,map,clown.bmp); %保存为bmp文件
imshow(X)
imshow(X,map)
RGB图像的显示
I=imread(trees.tif);
imshow(I)
RGB=imread(ngc6543a.jpg);
figure,imshow(RGB)
imshow(RGB(:,:,3)) % 显示第3个颜色分量
多帧图像的显示
mri=uint8(zeros(128,128,1,27)); % 27帧文件mri.tif初始化
for frame=1:27
[mri(:,:,:,frame),map]=imread(mri.tif,frame); % 读入每一帧
end
figure;imshow(mri(:,:,:,3),map); % 显示第3帧
figure,imshow(mri(:,:,:,6),map); % 显示第6帧
figure,imshow(mri(:,:,:,10),map); % 显示第10帧
figure,imshow(mri(:,:,:,20),map); % 显示第20帧
figure;
hold on;
for frame=1:27
hold on;imshow(mri(:,:,:,frame),map); % 读入每一帧
pause(0.1)
end
显示多幅图像
[X1,map1]=imread(forest.tif);
[X2,map2]=imread(trees.tif);
figure;
subplot(1,2,1),imshow(X1,map1)
subplot(1,2,2),imshow(X2,map2)
figure;
subplot(1,2,1),subimage(X1,map1)
subplot(1,2,2),subimage(X2,map2)
三、思考题:
图像显示时,若不带参数’notruesize’,显示效果如何?
如何显示RGB图像的某一个颜色分量?
如何显示多帧图像的所有帧?如何根据多帧图像创建电影片段? %pause(n)
实验二 图像运算
一、实验目的
熟悉图像点运算和代数运算的实现方法
了解图像几何运算的简单应用
了解图像的邻域操作
二、实验内容
图像点运算
读入图像‘rice.png’,通过图像点运算改变对比度。
rice=imread(rice.png);
subplot(131),imshow(rice)
I=double(rice); %转换为双精度类型
J=I*0.43+60;
rice2=uint8(J); %转换为uint8
subplot(132),i
显示全部