




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、共享知识分享快乐 clc % 读图 最后得到灰度图像rg A=imread(999.p ng); r c d=size(A); r2g=zeros(r,c); red=zeros(r,c); gree n=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); %提取图像的蓝色分量 end end for i=1:r; for j=1:c; rg(i,j)=
2、0.5*red(i,j)+0.5*gree n(i,j); end end rg=ui nt8(rg); for i=1:r; for j=1:c; if rg(i,j)178; rg(i,j)=255; end end end figure; subplot(2,2,1);imshow(A);title(原图)% 显示原图像 subplot(222);imshow(rg);title(彩色通道提取法-灰度图); % % figure r2g=rg; i=r2g; %输入灰度变换后的图像 subplot(221);imshow(i);title(原图) subplot(223);imhist(
3、i); % 显示直方图 h1=histeq(i); subplot(222);imshow(h1);title(直方图均衡化后的图) subplot(224);imhist(h1); % % i=h1;%直方图均衡化后的图像 j=imno ise(i, salt figure; subplot(121);imshow(j);title(添加椒盐噪声图像) subplot(122);imshow(k1);title( 3*3模板中值滤波) % % clc r2g; figure; subplot(221);imshow(r2g); title(原图像); W_H仁2 3 0; %选用自定义差分模
4、板增强左车道标记线 3 0 -3; 0 -3 -2; W_V1= 0 3 2; %选用自定义差分模板增强右车道标记线 -3 0 3; -2 -3 0; T = 0.28;% the threshold in the 2-value I = r2g; % read the image height,width = size(I); 11 = double(l); 13 = double(l); 14 = double(l); % put the images data into a bigger array to % move the wi ndow and calculate the grad
5、s %不同方向的模板算子 12 = zeros(height+2,width+2); void the edge I2(2:height+1,2:width+1) = I1; for i=2:height+1 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 en
6、d grey1 = abs(sum3) + abs(sum4); I3(i-1,j-1) = grey1; end end big = max(max(l3);% 归一化 small = min(min (13); 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 end end subplot(222); imshow(l3);title(sl、sr算子处理的图像) % % figur
7、e;subplot(221);imshow(A);title(原图) gg=bwmorph(l3,thi n ,inf); subplot(222);imshow(gg);title(细化的图像) I = rg; x,y=size(I); height,width = size(I); seedx=r oun d(x); seedy=ro un d(y/2); gr=I(seedx,seedy) W_H = 111; 1 1 1; 1 1 1; II = double(I); I2 = zeros(height+2,width+2); void the edge l2(2:height+1,2
8、:width+1) = I1; for i=2:height+1 for j=2:width+1 % the model in the horiz on direct ion % put the images data into a bigger array to % move the wi ndow and calculate the grads 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
9、-1) = grey; end end I1=ui nt8(l1);%邻域平均化灰度图像 %subplot(222);imshow(l1);title(区域生长-路面区域图像) x,y=size(I1); I2=zeros(x,y); l=double(l); I仁 double(I1); for i=1:x; for j=1:y; if abs(l1(i,j)-l(i,j)=70 end end end subplot(223) imshow(l2);title(区域生长-路面区域图像) I4=zeros(x,y); for i=roun d(5):x-4; for j=5:y-4; if
10、gg(i,j)=1 for m=i-4:i+4; for n =j-4:j+4; if I2(m, n)=0 end end end end end end subplot(224) imshow(I4);title(检测图像) % % clc; tO=clock ff=l4;%输入检测的图像 x,y=size(ff); a仁zeros(x,1); b1=zeros(y,1); k=1; for i=1:x for j=1:rou nd(y/2); if ff(i,j)=1; a1(k)=i; b1(k)=j; k=k+1; end end end m=le ngth(a1); a2=max(
11、a1) h=1; for i=1:m; if a1(i)=a2; jiaobiao(h)=i; h=h+1; end end b1=b1(jiaobiao); b1 仁m ax(b1); %ff(a1,b1)为选中的车道线第一个像素点 k=1; for i=roun d(1):ro un d(x); for j=1:rou nd(y/2 ); if ff(i,j)=1 kkb(k)=(b11-j)/(a2-i); bbc(k)=b11-kkb(k)*a2; k=k+1; end end end theta=ata n(-1./kkb); theta仁 theta+pi, roi=bbc.*si
12、 n(theta); roi1= roi+abs(roi); maxtheta=max( thetal); maxroi=max(roi1); accum=zeros(r oun d(maxtheta)+1,r ound( maxroi)+1); for i=1:le ngth(theta); thetai nt=rou nd( maxtheta/2+theta1(i)/2); roii nt=round( maxroi/2+roi1(i)/2)+1; accum(thetai nt,roii nt)=accum( thetai nt,roii nt)+1; end p=max(max(acc
13、um)%出现峰值处的累加器的值 for i=1:le ngth(theta); thetai nt=rou nd( maxtheta/2+theta1(i)/2); roii nt=round( maxroi/2+roi1(i)/2)+1; if accum(theta in t,roii nt)=p; ji=i; end end k=1; m=1; for i=roun d(x/2):x; for j=1:rou nd(y/2); if ff(i,j)=1 kk(k)=(b11-j)/(a2-i); bb(k)=b11-kk(k)*a2; theta(k)=ata n( -1./kk(k); if theta(k) =theta(ji); 刈(m)=i; yj
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 企业三定工作总结
- 弘扬塞罕坝精神团日活动
- 2025年 车险理赔考试卷库六附答案
- 创业培训开班
- 手卫生知识培训主要内容
- 银行年度员工培训方案
- 支原体肺炎检查方法与诊疗规范
- 肿瘤患者的舒适与安全
- 中药在肿瘤综合治疗中的应用
- 场地总监全面职责协议书模板
- 2025年人教版七年级数学下册期末测试卷
- 2025至2030年中国汽车轮毂轴承行业市场全景评估及发展趋势研判报告
- 人文英语4-005-国开机考复习资料
- 公司安全事故隐患内部举报、报告奖励制度
- 有趣的行为金融学知到章节答案智慧树2023年上海海洋大学
- 充电桩检测报告模板
- 车载诊断系统(OBD)简介课件
- 无犯罪证明委托书模板
- 城市轨道交通列车运行图编制课件
- 吊车施工专项施工方案
- (新版)国际法配套练习题库500题(含各题型)
评论
0/150
提交评论