




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、1.圖像反轉(zhuǎn)MATLAB程序?qū)崿F(xiàn)如下:I=imread('xian.bmp'J=double(I;J=-J+(256-1; %圖像反轉(zhuǎn)線性變換H=uint8(J;subplot(1,2,1,imshow(I;subplot(1,2,2,imshow(H;2.灰度線性變換MATLAB程序?qū)崿F(xiàn)如下:I=imread('xian.bmp'subplot(2,2,1,imshow(I;title('原始圖像'axis(50,250,50,200;axis on; %顯示坐標(biāo)系I1=rgb2gray(I;subplot(2,2,2,imshow(I1;ti
2、tle('灰度圖像'axis(50,250,50,200;axis on; %顯示坐標(biāo)系J=imadjust(I1,0.1 0.5,; %局部拉伸,把0.1 0.5內(nèi)的灰度拉伸為0 1 subplot(2,2,3,imshow(J;title('線性變換圖像0.1 0.5'axis(50,250,50,200;grid on; %顯示網(wǎng)格線axis on; %顯示坐標(biāo)系K=imadjust(I1,0.3 0.7,; %局部拉伸,把0.3 0.7內(nèi)的灰度拉伸為0 1 subplot(2,2,4,imshow(K;title('線性變換圖像0.3 0.7
3、39;axis(50,250,50,200;grid on; %顯示網(wǎng)格線axis on; %顯示坐標(biāo)系3.非線性變換MATLAB程序?qū)崿F(xiàn)如下:I=imread('xian.bmp'I1=rgb2gray(I;subplot(1,2,1,imshow(I1;title('灰度圖像'axis(50,250,50,200;grid on; %顯示網(wǎng)格線axis on; %顯示坐標(biāo)系J=double(I1;J=40*(log(J+1;H=uint8(J;subplot(1,2,2,imshow(H;title('對(duì)數(shù)變換圖像'axis(50,250,5
4、0,200;grid on; %顯示網(wǎng)格線axis on; %顯示坐標(biāo)系4.直方圖均衡化MATLAB程序?qū)崿F(xiàn)如下:I=imread('xian.bmp'I=rgb2gray(I;figure;subplot(2,2,1;imshow(I;subplot(2,2,2;imhist(I;I1=histeq(I;figure;subplot(2,2,1;imshow(I1;subplot(2,2,2;imhist(I1;5.線性平滑濾波器用MA TLAB實(shí)現(xiàn)領(lǐng)域平均法抑制噪聲程序:I=imread('xian.bmp'subplot(231imshow(Ititle(
5、'原始圖像'I=rgb2gray(I;I1=imnoise(I,'salt & pepper',0.02;subplot(232imshow(I1title('添加椒鹽噪聲的圖像'k1=filter2(fspecial('average',3,I1/255; %進(jìn)行3*3模板平滑濾波k2=filter2(fspecial('average',5,I1/255; %進(jìn)行5*5模板平滑濾波k3=filter2(fspecial('average',7,I1/255; %進(jìn)行7*7模板平滑濾波k4
6、=filter2(fspecial('average',9,I1/255; %進(jìn)行9*9模板平滑濾波subplot(233,imshow(k1;title('3*3模板平滑濾波'subplot(234,imshow(k2;title('5*5模板平滑濾波'subplot(235,imshow(k3;title('7*7模板平滑濾波'subplot(236,imshow(k4;title('9*9模板平滑濾波'6.中值濾波器用MA TLAB實(shí)現(xiàn)中值濾波程序如下:I=imread('xian.bmp'I
7、=rgb2gray(I;J=imnoise(I,'salt&pepper',0.02;subplot(231,imshow(I;title('原圖像'subplot(232,imshow(J;title('添加椒鹽噪聲圖像' k1=medfilt2(J; %進(jìn)行3*3模板中值濾波k2=medfilt2(J,5,5; %進(jìn)行5*5模板中值濾波k3=medfilt2(J,7,7; %進(jìn)行7*7模板中值濾波k4=medfilt2(J,9,9; %進(jìn)行9*9模板中值濾波subplot(233,imshow(k1;title('3*3模板中
8、值濾波' subplot(234,imshow(k2;title('5*5模板中值濾波' subplot(235,imshow(k3;title('7*7模板中值濾波' subplot(236,imshow(k4;title('9*9模板中值濾波'7.用Sobel算子和拉普拉斯對(duì)圖像銳化:I=imread('xian.bmp'subplot(2,2,1,imshow(I;title('原始圖像'axis(50,250,50,200;grid on; %顯示網(wǎng)格線axis on; %顯示坐標(biāo)系I1=im2bw
9、(I;subplot(2,2,2,imshow(I1;title('二值圖像'axis(50,250,50,200;grid on; %顯示網(wǎng)格線axis on; %顯示坐標(biāo)系H=fspecial('sobel' %選擇sobel算子J=filter2(H,I1; %卷積運(yùn)算subplot(2,2,3,imshow(J;title('sobel算子銳化圖像'axis(50,250,50,200;grid on; %顯示網(wǎng)格線axis on; %顯示坐標(biāo)系h=0 1 0,1 -4 1,0 1 0; %拉普拉斯算子J1=conv2(I1,h,'
10、;same' %卷積運(yùn)算subplot(2,2,4,imshow(J1;title('拉普拉斯算子銳化圖像'axis(50,250,50,200;grid on; %顯示網(wǎng)格線axis on; %顯示坐標(biāo)系8.梯度算子檢測(cè)邊緣用MA TLAB實(shí)現(xiàn)如下:I=imread('xian.bmp'subplot(2,3,1;imshow(I;title('原始圖像'axis(50,250,50,200;grid on; %顯示網(wǎng)格線axis on; %顯示坐標(biāo)系I1=im2bw(I;subplot(2,3,2;imshow(I1;title(
11、39;二值圖像'axis(50,250,50,200;grid on; %顯示網(wǎng)格線axis on; %顯示坐標(biāo)系I2=edge(I1,'roberts'figure;subplot(2,3,3;imshow(I2;title('roberts算子分割結(jié)果' axis(50,250,50,200;grid on; %顯示網(wǎng)格線axis on; %顯示坐標(biāo)系I3=edge(I1,'sobel'subplot(2,3,4;imshow(I3;title('sobel算子分割結(jié)果'axis(50,250,50,200;grid
12、on; %顯示網(wǎng)格線axis on; %顯示坐標(biāo)系I4=edge(I1,'Prewitt'subplot(2,3,5;imshow(I4;title('Prewitt算子分割結(jié)果' axis(50,250,50,200;grid on; %顯示網(wǎng)格線axis on; %顯示坐標(biāo)系9.LOG算子檢測(cè)邊緣用MA TLAB程序?qū)崿F(xiàn)如下:I=imread('xian.bmp'subplot(2,2,1;imshow(I;title('原始圖像'I1=rgb2gray(I;subplot(2,2,2;imshow(I1;title('
13、;灰度圖像'I2=edge(I1,'log'subplot(2,2,3;imshow(I2;title('log算子分割結(jié)果'10.Canny算子檢測(cè)邊緣用MA TLAB程序?qū)崿F(xiàn)如下:I=imread('xian.bmp'subplot(2,2,1;imshow(I;title('原始圖像'I1=rgb2gray(I;subplot(2,2,2;imshow(I1;title('灰度圖像'I2=edge(I1,'canny'subplot(2,2,3;imshow(I2;title('
14、;canny算子分割結(jié)果'11.邊界跟蹤(bwtraceboundary函數(shù)clcclear allI=imread('xian.bmp'figureimshow(I;title('原始圖像'I1=rgb2gray(I; %將彩色圖像轉(zhuǎn)化灰度圖像threshold=graythresh(I1; %計(jì)算將灰度圖像轉(zhuǎn)化為二值圖像所需的門限BW=im2bw(I1, threshold; %將灰度圖像轉(zhuǎn)化為二值圖像figureimshow(BW;title('二值圖像'dim=size(BW;col=round(dim(2/2-90; %計(jì)算起始
15、點(diǎn)列坐標(biāo)row=find(BW(:,col,1; %計(jì)算起始點(diǎn)行坐標(biāo)connectivity=8;num_points=180;contour=bwtraceboundary(BW,row,col,'N',connectivity,num_points;%提取邊界figureimshow(I1;hold on;plot(contour(:,2,contour(:,1, 'g','LineWidth' ,2;title('邊界跟蹤圖像'12.Hough變換I= imread('xian.bmp'rotI=rgb2gr
16、ay(I;subplot(2,2,1;imshow(rotI;title('灰度圖像'axis(50,250,50,200;grid on;axis on;BW=edge(rotI,'prewitt'subplot(2,2,2;imshow(BW;title('prewitt算子邊緣檢測(cè)后圖像'axis(50,250,50,200;grid on;axis on;H,T,R=hough(BW;subplot(2,2,3;imshow(H,'XData',T,'YData',R,'InitialMagnifi
17、cation','fit' title('霍夫變換圖'xlabel('theta',ylabel('rho'axis on , axis normal, hold on;P=houghpeaks(H,5,'threshold',ceil(0.3*max(H(:;x=T(P(:,2;y=R(P(:,1;plot(x,y,'s','color','white'lines=houghlines(BW,T,R,P,'FillGap',5,'Mi
18、nLength',7; subplot(2,2,4;,imshow(rotI;title('霍夫變換圖像檢測(cè)'axis(50,250,50,200;grid on;axis on;hold on;max_len=0;for k=1:length(linesxy=lines(k.point1;lines(k.point2;plot(xy(:,1,xy(:,2,'LineWidth',2,'Color','green'plot(xy(1,1,xy(1,2,'x','LineWidth',2,
19、39;Color','yellow'plot(xy(2,1,xy(2,2,'x','LineWidth',2,'Color','red'len=norm(lines(k.point1-lines(k.point2;if(len>max_lenmax_len=len;xy_long=xy;endendplot(xy_long(:,1,xy_long(:,2,'LineWidth',2,'Color','cyan'13.直方圖閾值法用MA TLAB實(shí)現(xiàn)直方圖
20、閾值法:I=imread('xian.bmp'I1=rgb2gray(I;figure;subplot(2,2,1;imshow(I1;title('灰度圖像'axis(50,250,50,200;grid on; %顯示網(wǎng)格線axis on; %顯示坐標(biāo)系m,n=size(I1; %測(cè)量圖像尺寸參數(shù)GP=zeros(1,256; %預(yù)創(chuàng)建存放灰度出現(xiàn)概率的向量for k=0:255GP(k+1=length(find(I1=k/(m*n; %計(jì)算每級(jí)灰度出現(xiàn)的概率,將其存入GP中相應(yīng)位置endsubplot(2,2,2,bar(0:255,GP,'g&
21、#39; %繪制直方圖title('灰度直方圖'xlabel('灰度值'ylabel('出現(xiàn)概率'I2=im2bw(I,150/255;subplot(2,2,3,imshow(I2;title('閾值150的分割圖像'axis(50,250,50,200;grid on; %顯示網(wǎng)格線axis on; %顯示坐標(biāo)系I3=im2bw(I,200/255; %subplot(2,2,4,imshow(I3;title('閾值200的分割圖像'axis(50,250,50,200;grid on; %顯示網(wǎng)格線axis
22、 on; %顯示坐標(biāo)系14. 自動(dòng)閾值法:Otsu法用MA TLAB實(shí)現(xiàn)Otsu算法:clcclear allI=imread('xian.bmp'subplot(1,2,1,imshow(I;title('原始圖像'axis(50,250,50,200;grid on; %顯示網(wǎng)格線axis on; %顯示坐標(biāo)系level=graythresh(I; %確定灰度閾值BW=im2bw(I,level;subplot(1,2,2,imshow(BW;title('Otsu法閾值分割圖像'axis(50,250,50,200;grid on; %顯示
23、網(wǎng)格線axis on; %顯示坐標(biāo)系15.膨脹操作I=imread('xian.bmp' %載入圖像I1=rgb2gray(I;subplot(1,2,1;imshow(I1;title('灰度圖像'axis(50,250,50,200;grid on; %顯示網(wǎng)格線axis on; %顯示坐標(biāo)系se=strel('disk',1; %生成圓形結(jié)構(gòu)元素I2=imdilate(I1,se; %用生成的結(jié)構(gòu)元素對(duì)圖像進(jìn)行膨脹subplot(1,2,2;imshow(I2;title('膨脹后圖像'axis(50,250,50,200;
24、grid on; %顯示網(wǎng)格線axis on; %顯示坐標(biāo)系16.腐蝕操作MATLAB實(shí)現(xiàn)腐蝕操作I=imread('xian.bmp' %載入圖像I1=rgb2gray(I;subplot(1,2,1;imshow(I1;title('灰度圖像'axis(50,250,50,200;grid on; %顯示網(wǎng)格線axis on; %顯示坐標(biāo)系se=strel('disk',1; %生成圓形結(jié)構(gòu)元素I2=imerode(I1,se; %用生成的結(jié)構(gòu)元素對(duì)圖像進(jìn)行腐蝕subplot(1,2,2;imshow(I2;title('腐蝕后圖像&
25、#39;axis(50,250,50,200;grid on; %顯示網(wǎng)格線axis on; %顯示坐標(biāo)系17.開啟和閉合操作用MA TLAB實(shí)現(xiàn)開啟和閉合操作I=imread('xian.bmp' %載入圖像subplot(2,2,1,imshow(I;title('原始圖像'axis(50,250,50,200;axis on; %顯示坐標(biāo)系I1=rgb2gray(I;subplot(2,2,2,imshow(I1;title('灰度圖像'axis(50,250,50,200;axis on; %顯示坐標(biāo)系se=strel('disk
26、',1; %采用半徑為1的圓作為結(jié)構(gòu)元素I2=imopen(I1,se; %開啟操作I3=imclose(I1,se; %閉合操作subplot(2,2,3,imshow(I2;title('開啟運(yùn)算后圖像'axis(50,250,50,200;axis on; %顯示坐標(biāo)系subplot(2,2,4,imshow(I3;title('閉合運(yùn)算后圖像'axis(50,250,50,200;axis on; %顯示坐標(biāo)系18.開啟和閉合組合操作I=imread('xian.bmp' %載入圖像subplot(3,2,1,imshow(I;t
27、itle('原始圖像'axis(50,250,50,200;axis on; %顯示坐標(biāo)系I1=rgb2gray(I;subplot(3,2,2,imshow(I1;title('灰度圖像'axis(50,250,50,200;axis on; %顯示坐標(biāo)系se=strel('disk',1;I2=imopen(I1,se; %開啟操作I3=imclose(I1,se; %閉合操作subplot(3,2,3,imshow(I2;title('開啟運(yùn)算后圖像'axis(50,250,50,200;axis on; %顯示坐標(biāo)系subplot(3,2,4,imshow(I3;title('閉合運(yùn)算后圖像'axis(50,250,50,200;axis on; %顯示坐標(biāo)系se=strel('disk',1;I4=imopen(I1,se;I5=imclose(I4,se;subplot(3,2,5,imshow(I5; %開閉運(yùn)算圖像title('開閉運(yùn)算圖像'axis(50,250,50,200;axis on; %顯示坐標(biāo)系I6=imclose(I1,se;I7=imopen(I6,se;subplot(3,2,6,imshow(I7; %閉開運(yùn)算
溫馨提示
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 五年級(jí)上冊(cè)數(shù)學(xué)教案 除數(shù)是整數(shù)的小數(shù)除法(二) 西師大版
- 二年級(jí)下冊(cè)數(shù)學(xué)教案 第1課時(shí) 東西南北 北師大版
- 三年級(jí)數(shù)學(xué)下冊(cè)教學(xué)設(shè)計(jì)-1.6集郵北師大版
- 六年級(jí)下冊(cè)數(shù)學(xué)教案-7.2 圖形與位置 ∣蘇教版
- 三年級(jí)下冊(cè)數(shù)學(xué)教案-5.5 求簡(jiǎn)單的經(jīng)過時(shí)間丨蘇教版
- 2025年房地產(chǎn)經(jīng)紀(jì)公司補(bǔ)充協(xié)議反饋 副本
- 2025年學(xué)習(xí)雷鋒精神62周年主題活動(dòng)實(shí)施方案 (3份)
- 湖南省2024年普通高等學(xué)校【對(duì)口】招生考試【師范類】專業(yè)【綜合知識(shí)】試題及答案
- 3-乘法-北師大版三年級(jí)下冊(cè)數(shù)學(xué)單元測(cè)試卷(含答案)
- 《晚春》歷年中考古詩欣賞試題匯編(截至2023年)
- 生活會(huì)前談心談話提綱
- 比較思想政治教育(第二版)第十二章課件
- 普通外科常見疾病臨床路徑
- 人教版區(qū)域地理課件世界地理之中亞五國【公開課教學(xué)PPT課件】高中地理
- 人教版九年級(jí)下冊(cè)初中英語全冊(cè)作業(yè)設(shè)計(jì)一課一練(課時(shí)練)
- 2021新版GJB9001C-2017體系文件內(nèi)審檢查表
- 風(fēng)篩式清選機(jī)的使用與維護(hù)
- 《計(jì)算流體力學(xué)CFD》
- 馬克思主義宗教觀課件
- 語文版九年級(jí)下冊(cè)課外閱讀練習(xí)
- 【課件】第11課+美術(shù)的曙光-史前與早期文明的美術(shù)+課件高中美術(shù)人教版(2019)美術(shù)鑒賞
評(píng)論
0/150
提交評(píng)論