matlab圖像處理的幾個實例_第1頁
matlab圖像處理的幾個實例_第2頁
matlab圖像處理的幾個實例_第3頁
matlab圖像處理的幾個實例_第4頁
matlab圖像處理的幾個實例_第5頁
已閱讀5頁,還剩7頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領

文檔簡介

1、Matlab圖像處理的幾個實例(初學者用)1.圖像的基本信息及其加減乘除clear,clc;P=imread('yjx.jpg');whos PQ=imread('dt.jpg');P=im2double(P);Q=im2double(Q);gg1=im2bw(P,0.3);gg2=im2bw(P,0.5);gg3=im2bw(P,0.8);K=imadd(gg1,gg2);L=imsubtract(gg2,gg3);cf=immultiply(P,Q);sf=imdivide(Q,P);subplot(421),imshow(P),title('郁金香

2、原圖');subplot(422),imshow(gg1),title('0.3');subplot(423),imshow(gg2),title('0.5');subplot(424),imshow(gg3),title('0.8');subplot(425),imshow(K),title('0.3+0.5');subplot(426),imshow(L),title('0.5-0.3');subplot(427),imshow(cf),title('P*Q');subplot(428)

3、,imshow(sf),title('P/Q');2.圖像縮放clear,clc;I=imread('dt.jpg');A=imresize(I,0.1,'nearest');B=imresize(I,0.4,'bilinear');C=imresize(I,0.7,'bicubic');D=imresize(I,100,200);F=imresize(I,400,100);figuresubplot(321),imshow(I),title('原圖');subplot(322),imshow(A)

4、,title('最鄰近插值');subplot(323),imshow(B),title('雙線性插值');subplot(324),imshow(C),title('二次立方插值');subplot(325),imshow(D),title('水平縮放與垂直縮放比例為2:1');subplot(326),imshow(F),title('水平縮放與垂直縮放比例為1:4');灰度變換、直方圖變換clear,clc;fg=imread('fg.jpg');zl=imread('zl.jpg&#

5、39;);hfg=rgb2gray(fg);fg1=double(hfg);out1=255*(fg1/255).0.7;out1(find(out1>255)=255;fg1=uint8(fg1);out1=uint8(out1);img=rgb2gray(zl);harm,x=imhist(img);J=histeq(hfg,harm);figuresubplot(421),imshow(fg1),title('復古灰度圖');subplot(422),imhist(fg1),title('復古灰度圖的直方圖');subplot(423),imshow

6、(out1),title('對復古灰度圖像進行冪次變換');subplot(424),imhist(out1),title('冪次變換圖像的直方圖');subplot(425),imshow(img),title('朱莉');subplot(426),imhist(img),title('朱莉圖像對應的直方圖');subplot(427),imshow(J),title('直方圖變換后的復古圖');subplot(428),imhist(J),title('直方圖變換后的復古圖對應的直方圖');傅里

7、葉變換、頻域濾波1. 傅里葉變換clear,clc;rgb=imread('zl.jpg');rgb=imresize(rgb,0.7,'bilinear');rgb=im2double(rgb);fR=rgb(:,:,1);fG=rgb(:,:,2);fB=rgb(:,:,3);flyfR=fft2(fR);flyfG=fft2(fG);flyfB=fft2(fB);Frgb(:,:,1)=flyfR;Frgb(:,:,2)=flyfG;Frgb(:,:,3)=flyfB;tzR=fftshift(flyfR);tzG=fftshift(flyfG);tzB=

8、fftshift(flyfB);tzF(:,:,1)=tzR;tzF(:,:,2)=tzG;tzF(:,:,3)=tzB;iflyfR=ifft2(flyfR);iflyfG=ifft2(flyfG);iflyfB=ifft2(flyfB);out(:,:,1)=iflyfR;out(:,:,2)=iflyfG;out(:,:,3)=iflyfB;figuresubplot(221),imshow(rgb),title('原圖');subplot(222),imshow(Frgb),title('圖像頻譜');subplot(223),imshow(tzF),t

9、itle('調(diào)整中心后的圖像頻譜');subplot(224),imshow(out),title('逆變換得到的原圖');2.頻域濾波clear,clc;I=rgb2gray(imread('ml.jpg');J=imnoise(I,'gaussian',0.1);Jzz1=medfilt2(J,3 3);Jzz2=medfilt2(J,10 10);XJ=imnoise(I,'salt & pepper');f=im2double(XJ);g=fft2(f);g=fftshift(g);M,N=size

10、(g);nn=2;d0=50;m=fix(M/2);n=fix(M/2);for i=1:M for j=1:N d=sqrt(i-m)2+(j-n)2); h1=1/(1+0.414*(d/d0)(2*nn); result1(i,j)=h1*g(i,j); endendresult1=ifftshift(result1);J2=ifft2(result1);J3=im2uint8(real(J2);figuresubplot(231),imshow(I),title('原圖的灰度圖像');subplot(232),imshow(J),title('加高斯噪聲'

11、;);subplot(233),imshow(Jzz1),title('模板3*3中值濾波后的圖像');subplot(234),imshow(Jzz2),title('模板10*10中值濾波后的圖像');subplot(235),imshow(J3),title('低通濾波圖');彩色圖像處理clear,clc;rgb=imread('yjx.jpg');fR=rgb(:,:,1);fG=rgb(:,:,2);fB=rgb(:,:,3);R=rgb;R(:,:,2 3)=0;G=rgb;G(:,:,1 3)=0;B=rgb;B(

12、:,:,1 2)=0;yiq=rgb2ntsc(rgb);fY=yiq(:,:,1);fI=yiq(:,:,2);fQ=yiq(:,:,3);fR=histeq(fR,256);fG=histeq(fG,256);fB=histeq(fB,256);RGB=cat(3,fR,fG,fB);figuresubplot(341),imshow(rgb),title('原圖');subplot(342),imshow(R),title('圖像的紅色分量');subplot(343),imshow(G),title('圖像的綠色分量');subplot(344),imshow(B),title('圖像的藍色分量');subplot(345),imshow(yiq),title('NTSC彩色空間&#

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論