版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、clc%讀圖最后得到灰度圖像rgA=imread(999.png);r c d=size(A);r2g=zeros(r,c);red=zeros(r,c);green=zeros(r,c);blue=zeros(r,c);rg=zeros(r,c);for i=1:r; for j=1:c; red(i,j)=A(i,j,1);%提取圖像的紅色分量 green(i,j)=A(i,j,2);%提取圖像的綠色分量 blue(i,j)=A(i,j,3);%提取圖像的藍(lán)色分量 endendfor i=1:r; for j=1:c; rg(i,j)=0.5*red(i,j)+0.5*green(i,j)
2、; endendrg=uint8(rg); for i=1:r; for j=1:c; if rg(i,j)178; rg(i,j)=255; end endendfigure;subplot(2,2,1);imshow(A);title(原圖)% 顯示原圖像subplot(222);imshow(rg);title(彩色通道提取法-灰度圖);%figurer2g=rg;i=r2g;%輸入灰度變換后的圖像subplot(221);imshow(i);title(原圖)subplot(223);imhist(i);%顯示直方圖h1=histeq(i);subplot(222);imshow(h1
3、);title(直方圖均衡化后的圖)subplot(224);imhist(h1);%i=h1;%直方圖均衡化后的圖像j=imnoise(i,salt & pepper,0.02)k1=medfilt2(j);figure;subplot(121);imshow(j);title(添加椒鹽噪聲圖像)subplot(122);imshow(k1);title(3*3模板中值濾波)%clcr2g;figure;subplot(221);imshow(r2g);title(原圖像);W_H1=2 3 0;%選用自定義差分模板增強(qiáng)左車(chē)道標(biāo)記線 3 0 -3; 0 -3 -2; W_V1= 0 3 2;
4、%選用自定義差分模板增強(qiáng)右車(chē)道標(biāo)記線 -3 0 3; -2 -3 0;T = 0.28; % the threshold in the 2-valueI = r2g; % read the imageheight,width = size(I);I1 = double(I);I3 = double(I);I4 = double(I);I2 = zeros(height+2,width+2); % put the images data into a bigger array to void the edgeI2(2:height+1,2:width+1) = I1;for i=2:height
5、+1 % move the window and calculate the grads for j=2:width+1 sum3 = 0; % 不同方向的模板算子 sum4 = 0; for m=-1:1 for n=-1:1 sum3= sum3 + W_H1(m + 2,n + 2) * I2(i + m,j + n); end end for m=-1:1 for n=-1:1 sum4 = sum4 + W_V1(m + 2,n + 2) * I2(i + m,j + n); end end grey1 = abs(sum3) + abs(sum4); I3(i-1,j-1) = g
6、rey1; endendbig = max(max(I3); % 歸一化small = min(min(I3);for i=1:height for j=1:width I3(i,j) = (I3(i,j)-small)/(big - small); % 歸一化 if(I3(i,j) T) I3(i,j) = 1; % 二值化 else I3(i,j) = 0; end endend subplot(222);imshow(I3);title(sl、sr算子處理的圖像)%figure;subplot(221);imshow(A);title(原圖)gg=bwmorph(I3,thin,inf)
7、;subplot(222);imshow(gg);title(細(xì)化的圖像)I = rg;x,y=size(I);height,width = size(I);seedx=round(x);seedy=round(y/2);gr=I(seedx,seedy)W_H = 1 1 1; % the model in the horizon direction 1 1 1; 1 1 1;I1 = double(I);I2 = zeros(height+2,width+2); % put the images data into a bigger array to void the edgeI2(2:h
8、eight+1,2:width+1) = I1;for i=2:height+1 % move the window and calculate the grads for j=2:width+1 sum1 = 0; % the cumulus for m=-1:1 for n=-1:1 sum1 = sum1 + W_H(m + 2,n + 2) * I2(i + m,j + n); end end grey=sum1/9; I1(i-1,j-1) = grey; endendI1=uint8(I1);%鄰域平均化灰度圖像%subplot(222);imshow(I1);title(區(qū)域生長(zhǎng)
9、-路面區(qū)域圖像)x,y=size(I1);I2=zeros(x,y);I=double(I);I1=double(I1);for i=1:x; for j=1:y; if abs(I1(i,j)-I(i,j)=70&abs(I(seedx,seedy)-I1(i,j)=90) I2(i,j)=1; end endendsubplot(223)imshow(I2);title(區(qū)域生長(zhǎng)-路面區(qū)域圖像)I4=zeros(x,y);for i=round(5):x-4; for j=5:y-4; if gg(i,j)=1 for m=i-4:i+4; for n=j-4:j+4; if I2(m,n
10、)=0&sqrt(i-m)2+(j-n2)=2 I4(i,j)=1; end endendendendendsubplot(224)imshow(I4);title(檢測(cè)圖像) %clc;t0=clockff=I4;%輸入檢測(cè)的圖像x,y=size(ff);a1=zeros(x,1);b1=zeros(y,1);k=1;for i=1:x for j=1:round(y/2); if ff(i,j)=1; a1(k)=i; b1(k)=j; k=k+1; end endendm=length(a1);a2=max(a1)h=1;for i=1:m; if a1(i)=a2; jiaobiao(
11、h)=i; h=h+1; endendb1=b1(jiaobiao);b11=max(b1);%ff(a1,b1)為選中的車(chē)道線第一個(gè)像素點(diǎn)k=1;for i=round(1):round(x); for j=1:round(y/2 ); if ff(i,j)=1&i=a2&j=b11; kkb(k)=(b11-j)/(a2-i); bbc(k)=b11-kkb(k)*a2; k=k+1; end endend theta=atan(-1./kkb); theta1= theta+pi, roi=bbc.*sin(theta); roi1= roi+abs(roi); maxtheta=max
12、( theta1); maxroi=max(roi1); accum=zeros(round(maxtheta)+1,round( maxroi)+1); for i=1:length(theta); thetaint=round( maxtheta/2+theta1(i)/2); roiint=round( maxroi/2+roi1(i)/2)+1; accum(thetaint,roiint)=accum( thetaint,roiint)+1; end p=max(max(accum)%出現(xiàn)峰值處的累加器的值for i=1:length(theta); thetaint=round( maxtheta/2+theta1(i)/2); roiint=round( maxroi/2+roi1(i)/2)+1; if accum(thetaint,roiint)=p; ji=i; endend k=1;m=1;for i=round(x/2):x; for j=1:round(y/2); if ff(i,j)=1&i=a2&j=b11; kk(k)=(b11-j)/(a2-i); bb(k)=b11-kk(k)*a2; theta(k)=atan(-1./kk(k); if theta(k) =the
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 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ì)用戶上傳內(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 線下培訓(xùn)上海
- 2026年成華區(qū)商務(wù)局公開(kāi)招聘編外人員備考題庫(kù)及一套參考答案詳解
- 線上營(yíng)養(yǎng)培訓(xùn)課件教學(xué)
- 2026年中關(guān)村科學(xué)城城市大腦股份有限公司招聘?jìng)淇碱}庫(kù)完整參考答案詳解
- 2026年上海市教育發(fā)展有限公司招聘營(yíng)地教官、行政助理備考題庫(kù)及一套參考答案詳解
- 2026年廈門(mén)中遠(yuǎn)海運(yùn)化工物流有限公司招聘?jìng)淇碱}庫(kù)及完整答案詳解一套
- 2026年云南水務(wù)投資股份有限公司寧洱縣污水處理廠招聘?jìng)淇碱}庫(kù)及參考答案詳解1套
- 2026年宜昌高新區(qū)人民醫(yī)院編外醫(yī)療衛(wèi)生專(zhuān)業(yè)技術(shù)人才招聘?jìng)淇碱}庫(kù)及答案詳解參考
- 餐飲安全培訓(xùn)感悟總結(jié)
- 2026年合肥源創(chuàng)新人才發(fā)展有限公司公開(kāi)選聘?jìng)淇碱}庫(kù)有答案詳解
- 2025年武漢大學(xué)專(zhuān)職管理人員和學(xué)生輔導(dǎo)員招聘真題
- 社會(huì)實(shí)踐-形考任務(wù)三-國(guó)開(kāi)(CQ)-參考資料
- 盧氏縣橫澗壯溝鐵礦礦山地質(zhì)環(huán)境保護(hù)與土地復(fù)墾方案
- 醫(yī)護(hù)人員形象禮儀培訓(xùn)
- 中國(guó)的“愛(ài)經(jīng)”(一)-《天地陰陽(yáng)交⊥歡大樂(lè)賦》
- 心房鈉尿肽基因敲除小鼠的繁殖和鑒定
- 母嬰護(hù)理職業(yè)道德課件
- 口腔頜面外科學(xué)(全)
- 安徽金軒科技有限公司 年產(chǎn)60萬(wàn)噸硫磺制酸項(xiàng)目環(huán)境影響報(bào)告書(shū)
- 魔鬼理論之k線秘笈圖解課件
- GB/T 9163-2001關(guān)節(jié)軸承向心關(guān)節(jié)軸承
評(píng)論
0/150
提交評(píng)論