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

下載本文檔

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

文檔簡介

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

2、變二值圖像A=imread('1.jpg'figuresubplot(1,2,1,imshow(Atitle('原圖'C=im2bw(A,0.2;subplot(1,2,2,imshow(Ctitle('原圖二值圖像'(4灰度圖像變索引圖像(一A=imread('1.jpg'figureB=rgb2gray(A;subplot(1,2,1,imshow(Btitle('灰度圖像'C=grayslice(B,39;subplot(1,2,2,imshow(Ctitle('灰度變索引圖像'(5灰度圖像變

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

4、('灰度變彩色圖像'內(nèi)容(二(1灰度平均值A(chǔ)=imread('1.jpg'figureB=rgb2gray(A;subplot(1,2,1,imshow(Btitle('灰度圖像'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(B % 區(qū)域最大灰度ming=min(min(B % 區(qū)域最小灰度(2彩色平均值figureimshow(Atitle('彩色圖像'A=double

5、(A;m,n=size(A;sumg=0.0;for i=1:m;for j=1:n;sumg=sumg+A(i,j;endendavg=sumg/(m*nsqure=m*nmaxg=max(max(Aming=min(min(A內(nèi)容(三采樣量化實(shí)驗(yàn)二圖像變換傅里葉變換、反變換、I=imread('19.jpg'A=rgb2gray(I;x1=fft2(A;x2=fftshift(x1;x3=ifft(x1/10;figure,subplot(1,4,1;imshow(Atitle('原圖'subplot(1,4,2;imshow(x1title('頻譜

6、圖'subplot(1,4,3;imshow(log(abs(x2+1,0 10;title('直流分量移至頻譜圖中心'subplot(1,4,4;imshow(x3,0 10title('傅里葉反變換'DCT變換、反變換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

7、('二維離散反余弦變換'利用DCT變換壓縮圖像I=imread('19.jpg'A=rgb2gray(I;B=DCT2(A;B(abs(B<0.1=0;C=idct2(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線性變換法clc;clear all;I=imread('

8、;19.jpg'A=rgb2gray(I;colormap;imshow(A;%設(shè)置圖像倒數(shù)參數(shù)j=imadjust(A,0 1,1 0,1.5;figure;subimage(j(2灰度圖像的非線性變換(之對(duì)數(shù) I=imread('19.jpg'colormapimshow(IJ=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(Btitle('直方圖&#

9、39;J=imadjust(B,0.15 0.9,0 1; figure,imhist(B,64title('均衡直方圖'濾波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,2imshow(Dtitle('均值濾波'subplot(1,3,3imshow(Dtitle('中值濾波's

10、ubplot(1,3,1imshow(Ctitle('加入椒鹽噪聲圖像'銳化處理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'

11、K=A-J; subplot(2,3,2,imshow(K; title('拉普拉斯銳化圖像' 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('原圖&#

12、39; B=imresize(A,2 figure, imshow(B; title('二倍圖' C=imresize(A,0.5 figure imshow(C title('二分之一圖' 旋轉(zhuǎn) A=imread('19.jpg' figure subplot(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,&#

13、39;nearest' subplot(1,4,3, 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(

14、1:-1:1,1:H(2,1:H(3;%垂直鏡像 subplot(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=imrea

15、d('19.jpg' A2=imcrop(A1,75 68 100 110; figure subplot(1,2,1, imshow(A1; title('原像' subplot(1,2,2, imshow(A2; title('剪切后像' 實(shí)驗(yàn)五 閾值分割 A=imread('19.jpg' figure subplot(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; figure subplot(1,4,1, imshow(A; title('原圖像' B=edge(A,'sobe

溫馨提示

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

最新文檔

評(píng)論

0/150

提交評(píng)論