[計(jì)算機(jī)]數(shù)字圖像處理實(shí)驗(yàn)程序MATLAB_第1頁(yè)
[計(jì)算機(jī)]數(shù)字圖像處理實(shí)驗(yàn)程序MATLAB_第2頁(yè)
[計(jì)算機(jī)]數(shù)字圖像處理實(shí)驗(yàn)程序MATLAB_第3頁(yè)
[計(jì)算機(jī)]數(shù)字圖像處理實(shí)驗(yàn)程序MATLAB_第4頁(yè)
[計(jì)算機(jī)]數(shù)字圖像處理實(shí)驗(yàn)程序MATLAB_第5頁(yè)
已閱讀5頁(yè),還剩3頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、.實(shí)驗(yàn)一內(nèi)容(一)(1)彩色圖像變灰度圖像A=imread('1.jpg');B=rgb2gray(A);figuresubplot(1,2,1),imshow(A)title('原圖')subplot(1,2,2),imshow(B)title('原圖灰度圖像')(2)彩色圖像變索引圖像A=imread('1.jpg');figuresubplot(1,2,1),imshow(A)title('原圖')X,map=rgb2ind(A,128);subplot(1,2,2),imshow(X,map)title(&

2、#39;原圖索引圖像')(3)彩色圖像變二值圖像A=imread('1.jpg');figuresubplot(1,2,1),imshow(A)title('原圖') C=im2bw(A,0.2);subplot(1,2,2),imshow(C)title('原圖二值圖像')(4)灰度圖像變索引圖像(一)A=imread('1.jpg');figureB=rgb2gray(A);subplot(1,2,1),imshow(B)title('灰度圖像')C=grayslice(B,39);subplot(1,

3、2,2),imshow(C)title('灰度變索引圖像')(5)灰度圖像變索引圖像(二)A=imread('1.jpg');figureB=rgb2gray(A);subplot(1,2,1),imshow(B)title('灰度圖像')X,map=gray2ind(B,63);subplot(1,2,2),imshow(X,map)title('灰度變索引圖像')(6)灰度圖像變彩色圖像 A=imread('1.jpg');figureB=rgb2gray(A);subplot(1,2,1),imshow(B)

4、title('灰度圖像')C=gray2rgb(B,map);subplot(1,2,2),imshow(C)title('灰度變彩色圖像')內(nèi)容(二)(1)灰度平均值A(chǔ)=imread('1.jpg');figureB=rgb2gray(A);subplot(1,2,1),imshow(B)title('灰度圖像')B=double(B);m,n=size(B);sumg=0.0;for i=1:m;for j=1:n; sumg=sumg+B(i,j);endendavg=sumg/(m*n) % 均值 maxg=max(max

5、(B) % 區(qū)域最大灰度ming=min(min(B) % 區(qū)域最小灰度(2)彩色平均值A(chǔ)=imread('1.jpg');figureimshow(A)title('彩色圖像')A=double(A);m,n=size(A);sumg=0.0;for i=1:m; for j=1:n; sumg=sumg+A(i,j); endendavg=sumg/(m*n)squre=m*nmaxg=max(max(A)ming=min(min(A)內(nèi)容(三)采樣量化實(shí)驗(yàn)二 圖像變換傅里葉變換、反變換、I=imread('19.jpg');A=rgb2gr

6、ay(I);x1=fft2(A);x2=fftshift(x1);x3=ifft(x1)/10;figure,subplot(1,4,1);imshow(A)title('原圖');subplot(1,4,2);imshow(x1)title('頻譜圖');subplot(1,4,3);imshow(log(abs(x2)+1),0 10);title('直流分量移至頻譜圖中心');subplot(1,4,4);imshow(x3,0 10)title('傅里葉反變換');DCT變換、反變換X=imread('19.jpg

7、');I=rgb2gray(X);subplot(1,3,1);imshow(I);title('原圖');subplot(1,3,2);J=dct2(I);imshow(log(abs(J),0 20);title('二維離散余弦變換');subplot(1,3,3);K=idct2(J)/20;imshow(K,0 20);title('二維離散反余弦變換');利用DCT變換壓縮圖像I=imread('19.jpg');A=rgb2gray(I);B=DCT2(A);B(abs(B)<0.1)=0;C=idct2

8、(B)/255;figure,subplot(1,3,1);imshow(A);title('原圖');subplot(1,3,2);imshow(B);title('二維離散余弦變換頻譜圖');subplot(1,3,3);imshow(C); title('壓縮后圖像');實(shí)驗(yàn)三 圖像增強(qiáng)(一)灰度圖像增強(qiáng)(1)線(xiàn)性變換法clc;clear all;I=imread('19.jpg');A=rgb2gray(I);colormap;imshow(A);%設(shè)置圖像倒數(shù)參數(shù)j=imadjust(A,0 1,1 0,1.5);fig

9、ure;subimage(j) (2)灰度圖像的非線(xiàn)性變換(之對(duì)數(shù))I=imread('19.jpg');colormapimshow(I)J=double(I);J=45*log(J+1);I=uint8(J);figure,subimage(J) (二)直方圖校正直方圖均衡I=imread('19.jpg');B=rgb2gray(I);imshow(B,40 255);figure,imhist(B) title('直方圖')J=imadjust(B,0.15 0.9,0 1);figure,imhist(B,64)title('均

10、衡直方圖')濾波I=imread('19.jpg');figure,B=rgb2gray(I);C=imnoise(B,'salt & pepper',0.02);D=imfilter(B,fspecial('average',3);E=medfilt2(B);subplot(1,3,2)imshow(D)title('均值濾波')subplot(1,3,3)imshow(D)title('中值濾波')subplot(1,3,1)imshow(C)title('加入椒鹽噪聲圖像')

11、銳化處理I=imread('19.jpg');A=rgb2gray(I);figure,subplot(2,3,1),imshow(A);title('原圖');hs=fspecial('sobel');S=imfilter(A,hs);hp=fspecial('prewitt');P=imfilter(A,hs);A=double(A);%雙精度型H=0 1 0,1 -4 1,0 1 0;%拉普拉斯算子J=conv2(A,H,'same');K=A-J;subplot(2,3,2),imshow(K);title

12、('拉普拉斯銳化圖像');B=edge(A,'roberts',0.1);subplot(2,3,3),imshow(B);title('羅伯特銳化圖像');subplot(2,3,4),imshow(S);title('sobel算子銳化圖像');subplot(2,3,5),imshow(P);title('prewitt算子銳化圖像');實(shí)驗(yàn)四放縮A=imread('19.jpg');imshow(A);title('原圖')B=imresize(A,2)figure,imsh

13、ow(B);title('二倍圖')C=imresize(A,0.5)figureimshow(C)title('二分之一圖')旋轉(zhuǎn)A=imread('19.jpg');figuresubplot(1,4,1),imshow(A);title('原圖像')B=imrotate(A,30,'nearest');subplot(1,4,2),imshow(uint8(B);title('旋轉(zhuǎn)30度圖像')C=imrotate(A,45,'nearest');subplot(1,4,3),

14、imshow(uint8(C);title('旋轉(zhuǎn)45度圖像')D=imrotate(A,60,'nearest');subplot(1,4,4),imshow(uint8(D);title('旋轉(zhuǎn)60度圖像')鏡像A1=imread('19.jpg');A1=double(A1);Figure,subplot(1,4,1),imshow(uint8(A1);H=size(A1);title('原像')A2(1:H(1),1:H(2),1:H(3)=A1(H(1):-1:1,1:H(2),1:H(3);%垂直鏡像s

15、ubplot(1,4,2),imshow(uint8(A2);title('垂直鏡像')A3(1:H(1),1:H(2),1:H(3)=A1(1:H(1),H(2):-1:1,1:H(3);%水平鏡像subplot(1,4,3),imshow(uint8(A3);title('水平鏡像')A4(1:H(1),1:H(2),1:H(3)=A1(H(1):-1:1,H(2):-1:1,1:H(3);%對(duì)角鏡像subplot(1,4,4),imshow(uint8(A4);title('對(duì)角鏡像') 剪切A1=imread('19.jpg

16、9;);A2=imcrop(A1,75 68 100 110);figuresubplot(1,2,1),imshow(A1);title('原像')subplot(1,2,2),imshow(A2);title('剪切后像')實(shí)驗(yàn)五閾值分割A(yù)=imread('19.jpg');figuresubplot(1,4,1),imshow(A);title('原圖像')B=im2bw(A,91/255);subplot(1,4,2),imshow(B);title('閾值91的圖像')C=im2bw(A,71/255);subplot(1,4,3),imshow(C);title('閾值71的圖像')D=im2bw(A,140/255);subplot(1,4,4),imshow(D);title('閾值140的圖像')邊緣檢測(cè)I=imread('19.jpg');A=rgb2gray(I);figuresubplot(1,4,1),imshow(A);title('原圖像')B=edge(

溫馨提示

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

最新文檔

評(píng)論

0/150

提交評(píng)論