资源描述:
《《数字图像处理》实验指导书201403》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、1.直方图均衡化clearall;closeall%CleartheMATLABworkspaceofanyvariables%andcloseopenfigurewindows.I=imread('pout.tif');%Readsthesampleimages‘pout.tif’,andstoresitinimshow(I)%anarraynamedI.displaytheimagefigure,imhist(I)%Createahistogramoftheimageanddisplayitin%anewfigurewindow.[I2,T]=h
2、isteq(I);%Histogramequalization.figure,imshow(I2)%Displaythenewequalizedimage,I2,inanewfigurewindow.figure,imhist(I2)%CreateahistogramoftheequalizedimageI2.figure,plot((0:255)/255,T);%plotthetransformationcurve.imwrite(I2,'pout2.png');%WritethenewlyadjustedimageI2toadiskfilenam
3、ed%‘pout2.png’.imfinfo('pout2.png')%Checkthecontentsofthenewlywrittenfile2.直接灰度变换clearall;closeallI=imread('cameraman.tif');J=imadjust(I,[00.2],[0.51]);imshow(I)figure,imshow(J)[X,map]=imread('forest.tif');figure,imshow(X,map)I2=ind2gray(X,map);J2=imadjust(I2,[],[],0.5);figure,
4、imshow(I2)figure,imshow(J2)J3=imadjust(I2,[],[],1.5);figure,imshow(J3)helpimadjust%Displaytheimadjust()functioninformation.3.空域平滑滤波(模糊、去噪)clearall;closeallI=imread('eight.tif');h1=ones(3,3)/9;h2=ones(5,5)/25;8I1=imfilter(I,h1);I2=imfilter(I,h2);figure(1),imshow(I),title('Origin
5、alImage');figure(2),imshow(I1),title('FilteredImageWith3*3')figure(3),imshow(I2),title('FilteredImageWith5*5')%加入Gaussian噪声J1=imnoise(I,'gaussian',0,0.005);%加入椒盐噪声J2=imnoise(I,'salt&pepper',0.02);%对J1、J2进行平均值平滑滤波K1=imfilter(J1,fspecial('average',3));K2=imfilter(J2,fspecial('ave
6、rage',3));figure(4);subplot(2,2,1),imshow(J1),title('gaussian');subplot(2,2,2),imshow(J2),title('salt&pepper');subplot(2,2,3),imshow(K1),title('average');subplot(2,2,4),imshow(K2);%对J1、J2进行中值滤波K3=medfilt2(J1,[33]);K4=medfilt2(J2,[33]);figure(5);subplot(2,2,1),imshow(J1),title('
7、gaussian');subplot(2,2,2),imshow(J2),title('salt&pepper');subplot(2,2,3),imshow(K3),title('Medianfiltering');subplot(2,2,4),imshow(K4)4.空域锐化滤波clearall;closeallI=imread('moon.tif');w=fspecial('laplacian',0)w8=[1,1,1;1,-8,1;1,1,1]I1=imfilter(I,w,'replicate');figure(1);imshow(I),t
8、itle('OriginalImage');figure(2),imshow(I1),title('Lapl