版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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);%提取图像的蓝色分量 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;%选用自定义差分模板增强左车道标记线 3 0 -3; 0 -3 -2; W_V1= 0 3 2;
4、%选用自定义差分模板增强右车道标记线 -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(细化的图像)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(区域生长
9、-路面区域图像)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(区域生长-路面区域图像)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(检测图像) %clc;t0=clockff=I4;%输入检测的图像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)为选中的车道线第一个像素点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)%出现峰值处的累加器的值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. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 医联体背景下基层患者价值感知
- 医联体机器人手术人才培养
- 1-Anthramine-1-Aminoanthracene-生命科学试剂-MCE
- 1-1-Z-Octadecenyl-2-adrenoyl-sn-glycero-3-PC-生命科学试剂-MCE
- 医联体云计算助力基层医疗
- 医疗资源跨域调配的伦理考量
- 医疗资源城乡均衡发展方案
- 2025年家长网络监管培训
- 太原母婴护理师常见病预防与护理
- 2025年安全培训团队建设培训课件
- 创文交通协管员劳务派遣投标方案
- 2024年湖南商务职业技术学院单招职业适应性测试题库带答案
- 《跨境电商直播(双语)》课件-1.1行业发展动态
- 标书中培训服务方案
- 全套教学课件《工程伦理学》
- 病毒性心肌炎诊疗知识考试试题及答案
- 新教材人教版高中数学必修第二册全册(基础练习题)原卷版
- 充电桩采购安装投标方案1
- 建设工程基本法律知识-建设工程担保制度
- 完小校长述职报告
- 中国的“爱经”(一)-《天地阴阳交⊥欢大乐赋》
评论
0/150
提交评论