资源简介
路标识别与提取(采用聚类方法)(C-means)(K-means)能对路边进行有效识别和提取,采用MATLAB 语言编写。

代码片段和文件信息
%C均值聚类算法
clear
clc
[filenamepathname] = uigetfile(‘*.jpg‘‘读取图片文件‘);%选择图片文件
if isequal(filename0) %判断是否选择
msgbox(‘没有选择任何图片‘);
else
pathfile = fullfile(pathnamefilename); %获得图片路径
RGB = imread(pathfile); %将图片读入矩阵
YUV = rgb2ycbcr(RGB);%转成YUV
figure;
imshow(YUV); %绘制图片
end
size_image = size(YUV(::1));
YUV = double(YUV);
i = 1:1:size_image(1);
j = 1:1:size_image(2);
data = zeros(size_image(1)*size_image(2)2);
for i = 1:size_image(1); %data为n*m矩阵,n为样本点个数,m为么个特征的维数
for j = 1:size_image(2);
data(j+(i-1)*size_image(2)1) = YUV(ij1);
data(j+(i-1)*size_image(2)2) = YUV(ij3);
end
end
[centerUobj_fcn] = fcm(data4); %模糊C聚类算法
figure
plot(data(:1)data(:2)‘o‘);
hold on;
maxU = max(U);
index1 = find(U(1:) == maxU);
index2 = find(U(2:) == maxU);
index3 = find(U(3:) == maxU);
index4 = find(U(4:) == maxU);
plot(data(index11)data(index12)‘og‘);
plot(data(index21)data(index22)‘or‘);
plot(data(index31)data(index32)‘ob‘);
plot(data(index41)data(index42)‘oy‘);
%画聚类中心
plot(center(11)center(12)‘xr‘‘MarkerSize‘15‘LineWidth‘3);
plot(center(21)center(22)‘xb‘‘MarkerSize‘15‘LineWidth‘3);
plot(center(31)center(32)‘xy‘‘MarkerSize‘15‘LineWidth‘3);
plot(center(41)center(42)‘xk‘‘MarkerSize‘15‘LineWidth‘3);
title(‘分类结果‘);
hold off;
figure
result = zeros(size_image(1)size_image(2)3)+255;
a1 = fix(index1/size_image(2));
b1 = rem(index1size_image(2));
sizea1 = size(a1);
sizeb1 = size(b1);
%画第一类点
for i = 1:size_image(1);
temp_a1 = any(a1==i);
if(temp_a1==1)
pos_a1 = find(a1 == i);
size_pos_a1 = size(pos_a1);
b_block = b1(pos_a1(1):(pos_a1(1)+size_pos_a1(2)-1));
for j = 1:size_image(2);
temp_b1 = any(b_block == j);
if(temp_b1 == 1)
result(ij:) = [100];
end
end
end
end
a2 = fix(index2/size_image(2));
b2 = rem(index2size_image(2));
sizea2 = size(a2);
sizeb2 = size(b2);
%画第二类点
for i = 1:size_image(1);
temp_a2 = any(a2==i);
if(temp_a2==1)
pos_a2 = find(a2==i);
size_pos_a2 = size(pos_a2);
b_block = b2(pos_a2(1):(pos_a2(1)+size_pos_a2(2)-1));
for j = 1:size_image(2);
temp_b2 = any(b_block == j);
if(temp_b2 == 1)
result(ij:) = [010];
end
end
end
end
a3 = fix(index3/size_image(2));
b3 = rem(index3size_image(2));
sizea3 = size(a3);
sizeb3 = size(b3);
%画第三类点
for i = 1:size_image(1);
temp_a3 = any(a3==i);
if(temp_a3==1)
pos_a3 = find(a3==i);
size_pos_a3 = size(pos_a3);
b_block = b3(pos_a3(1):(pos_a3(1)+size_pos_a3(2)-1));
for j = 1:size_image(2);
temp_b3 = any(b_block == j);
if(temp_b3 == 1)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-05-14 13:55 聚类\
文件 188309 2018-05-08 20:35 聚类\1.jpg
文件 140902 2018-05-08 20:35 聚类\2.jpg
文件 131347 2018-05-08 20:35 聚类\3.jpg
文件 6192 2018-05-14 16:09 聚类\C_mean.asv
文件 9447 2018-05-14 16:36 聚类\C_mean.m
文件 150101 2018-05-12 08:40 聚类\fizzyC_RGB_3.fig
文件 2085162 2018-05-14 13:54 聚类\fuzzyC1.fig
文件 2035652 2018-05-14 13:55 聚类\fuzzyC2.fig
- 上一篇:MATLAB 常用函数参考
- 下一篇:机器视觉单目测量
相关资源
- matlab_OFDM调制解调(来自剑桥大学)
- Matlab路面裂缝识别69319
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
评论
共有 条评论