《数字图像处理》实验指导书(2011年用过)

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

《数字图像处理》实验指导书实验一、图象的基本操作(2学时)实验二、图像的傅立叶变换(2学时)实验三、图像增强(2学时)实验四、图像压缩(2学时)实验五、图像融合(选做)实验一图像的基本操作1.实验目的熟悉常用的图像文件格式与格式转换;熟悉图像矩阵的显示方法(灰度、索引、黑白、彩色);熟悉图像矩阵的格式转换使学生熟悉图象文件格式、图象的载入、彩色图象的构成、图象的显示等。2.实验内容练习图像读写命令imread和imwrite并进行图像文件格式间的转换。特别是索引图像与1,4,8,16比特图像的存储与转换。ImagefileI/O.imread-Readimagefile.imwrite-Writeimagefile.Imagedisplay.colorbar-Displaycolorbar.getimage-Getimagedatafromaxes.image-Createanddisplayimageimagesc-Scaledataanddisplayasimage.immovie-Makemoviefrommultiframeimage.imshow-Displayimage.subimage-Displaymultipleimagesinsinglefigure.truesize-Adjustdisplaysizeofimage.warp-Displayimageastexture-mappedsurface.zoom-Zoominandoutofimageor2-Dplot.3.实验步骤a.从硬盘加载cameraman.tif图象(用函数imread).b.在图象显示窗口显示图象(usingfunctionimageorimshow).c.显示彩色图象的3基色图象。参考程序:football=imread('football.jpg');figure('Name','Football');imshow(football);figure('Name','Footballcolorplanes');subplot(2,2,1);imshow(football);redfootball=football;redfootball(:,:,2:3)=0;subplot(2,2,2);imshow(redfootball);greenfootball=football;greenfootball(:,:,1)=0;greenfootball(:,:,3)=0;subplot(2,2,3);imshow(greenfootball);bluefootball=football;bluefootball(:,:,1:2)=0;subplot(2,2,4);imshow(bluefootball);实验二图象的基本操作与变换一、实验目的通过实验了解并掌握图象的基本操作、图象的傅立叶变换及频谱、傅立叶变换可分离性和哈达吗变换。二、实验内容(1)进行图象的基本算术操作(+、-、*)载入图象‘lenna.gif’,加入躁声,观察图象的变化.(2)进行二值图象的逻辑运算(and、or、not)自编程序生成2个二值图象(256x256),进行逻辑操作.(3)设简单的二值图象为:imag=zeros(256,256);imag(100:180,100:150)=1;编制程序用两次一维傅立叶变换计算其二维傅立叶变换.并观察其幅值频谱和相位频谱.(fft,abs,imshow,angle,fftshift)(4)载入图象‘lenna.gif’,用fft2和ifft2观察图象的频谱,并进行逆傅立叶变换,观察还原后的图象与原图象的差异.(5)观察图象的旋转和其傅立叶变换。三实验要求(1)每位同学独立完成实验内容(2)实验报告包括程序代码、运行结果和体会。(3)实验报告中变换前后的图像须打印1,图像的基本操作a='checker.gif';imshow(a)title('originalcheckerimage');figure(2)b='castles.gif';imshow(b)title('originalcastlesimage');I=imread('checker.gif');I2=imread('castles.gif');BW=im2bw(I,0.0005);%binaryconversionBW2=im2bw(I2,0.0005);%computeAandBfigure(3)A=and(BW,BW2);%andoperationimshow(A)title('outputimages(checkerandcastles)');%computeAxorBfigure(4)B=xor(BW,BW2);imshow(B)title('outputimages(checkerxorcastles)');%computenot_Axnornot_Bfigure(5)NI=not(I);NI2=not(I2);c1=and(I,I2);c2=and(NI,NI2);C=or(c1,c2);imshow(C)title('outputimages(notcheckerxnornotcastles)');%computeE=max(C,D)figure(6)I3=imread('lenna.gif');imshow(I3)title('originallennaimage');figure(7)I4=imread('lv40.gif');imshow(I4)title('originallv40.gif');figure(8)D=max(I3,I4);imshow(D)title('outputimageofmax(lenna,lv40)');%computedifferenceusingimsubtractandimabsdifffigure(9)I5=imread('seq1_frame_0001.gif');imshow(I5)title('seq1frame0001originalimage');figure(10)I6=imread('seq1_frame_0002.gif');imshow(I6)title('seq1frame0002originalimage');figure(11)E=imsubtract(I5,I6);imshow(E)title('differencebetweenseq1frame0001.gifandseq1frame0002.gifusingimsubtract');figure(12)F=imabsdiff(I5,I6);imshow(F)title('differencebetweenseq1frame0001.gifandseq1frame0002.gifusingimabsdiff');%Connected-ComponentsAnalysisboard=checkerboard(1)0.5;four_conn=bwlabel(board,4)eight_conn=bwlabel(board,8)clear;clc;closeall;pack;%readimagesintomemoryimg_checkers=imread('checker.gif','gif');img_castles=imread('castles.gif','gif');img_lenna=imread('lenna.gif','gif');img_lv=imread('lv40.gif','gif');img_seq1=imread('seq1_frame_0001.gif');img_seq2=imread('seq1_frame_0002.gif');%noneedtoconverttheseimagestobinary--theyarealreadybinary%butiftheywerenottheywouldbethresholdedtobinaryhere%dothelogicaloperations%1.a.:ANDoperationontwobinaryimagesand_img=and(img_checkers,img_castles);figure;imshow(and_img);title('checker.gifANDcastles.gif:BinaryANDOperation');%1.b.:XORoperationontwobinaryimagesxor_img=xor(img_checkers,img_castles);figure;imshow(xor_img);title('checker.gifXORcastles.gif:BinaryXOROperation)');%1.c.:NOT...XNOR...NOToperationontwobinaryimages:%A'XNORB'=(A'XORB')'not_img=not(xor(not(img_checkers),not(img_castles)));figure;imshow(not_img);title('NOTcastles.gifXNORNOTchecker.gif');%1.d.:Findmaxvaluefortwoimagesimg_max=max(img_lenna,img_lv);figure;imshow(img_max);title('MAXPixelValueBetweenlenna.gifandlv40.gif');2傅立叶变换I=imread(‘原图像名.gif’);%读入原图像文件imshow(I);%显示原图像fftI=fft2(I);%二维离散傅立叶变换sfftI=fftshift(fftI);%直流分量移到频谱中心RR=real(sfftI);%取傅立叶变换的实部II=imag(sfftI);%取傅立叶变换的虚部A=sqrt(RR.^2+II.^2);%计算频谱幅值A=(A-min(min(A)))/(max(max(A))-min(min(A)))*225;%归一化figure;%设定窗口imshow(A);%显示原图像的频谱//选做%1.e.:Finddifferenceimagebetweentwoanimatedmotionsequenceframesfigure;imshow(img_seq1);title('FrameOne');figure;imshow(img_seq2);title('FrameTwo');img_diff=imabsdiff(img_seq2,img_seq1);figure;imshow(img_diff);title('DifferencebetweenFrameOneandFrameTwo--ShowsMotion');%ConnectedComponentsAnalysis%generateatestimageimg_con_test=checkerboard(1)0.5figure;imshow(img_con_test);title('CheckerboardtoShowConnectivity');%computematricesof4-connectivityand8-connectivityinthetestimage[four_con_matrix,val_4]=bwlabeln(img_con_test,4)figure;imshow(four_con_matrix);title('Imageof4-ConnectivityMatrix');[eight_con_matrix,val_8]=bwlabeln(img_con_test,8)figure;imshow(eight_con_matrix);title('Imageof8-ConnectivityMatrix');实验三图像增强(2学时)1.实验目的1掌握灰度直方图的

1 / 16
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功