资源简介
K-means.rar

代码片段和文件信息
#include “opencv2/opencv.hpp“
#include
#include
#include
using namespace std;
using namespace cv;
struct CLASS_MEAN_POINT
{
float num; /* 类中点数 */
int RGBAve[3]; /* 类的BGR均值 */
} ;
const int Cnum = 5;
int classd[ Cnum ] = {0};
void ini ( CLASS_MEAN_POINT * classmean );
void copyclass ( CLASS_MEAN_POINT * classmean1 CLASS_MEAN_POINT * classmean2 );
int initialize ( CLASS_MEAN_POINT * classmean unsigned char * pixellabel Mat& SourceImage );
int calculate ( CLASS_MEAN_POINT * classmean0 CLASS_MEAN_POINT * classmeanunsigned char * pixellabel Mat& SourceImage );
int clusterresult ( CLASS_MEAN_POINT * classmean0 unsigned char * pixellabel Mat& ResultImage Mat& SourceImage );
int result ( CLASS_MEAN_POINT * classmean0 unsigned char * pixellabel Mat& ResultImage Mat& SourceImage int B int G int R ); /* 将路牌外的区域设置为白色 */
int main ( int argc char* argv[] )
{
CLASS_MEAN_POINT * classmean0 = NULL;
CLASS_MEAN_POINT * classmean = NULL;
Mat SourceImage ResultImage;
unsigned char * pixellabel = NULL;
if ( argc!=2 )
{
cout<< “Can‘t open the image! “< return -1;
}
SourceImage = imread( argv[1] );
classmean0 = new CLASS_MEAN_POINT [ Cnum ];
classmean = new CLASS_MEAN_POINT [ Cnum ];
pixellabel = new unsigned char [ SourceImage.cols * SourceImage.rows ] ;
ResultImage.create( SourceImage.rows SourceImage.cols SourceImage.type() );
ini ( classmean0 );
ini ( classmean );
initialize( classmean0 pixellabel SourceImage );
int stop = 0;
int num = 0;
while ( stop != Cnum )
{
stop = 0;
calculate ( classmean0 classmean pixellabel SourceImage );
for ( int k = 0; k < Cnum; k++)
{
if ( classmean0[k].RGBAve[0] == classmean[k].RGBAve[0] &&
classmean0[k].RGBAve[1] == classmean[k].RGBAve[1] &&
classmean0[k].RGBAve[2] == classmean[k].RGBAve[2] )
stop += 1;
}
copyclass ( classmean classmean0 );
num ++;
}
cout<<“一共分为“<
clusterresult ( classmean0 pixellabel ResultImage SourceImage );
imshow( “Cluster Image“ ResultImage );
/*int *greyk = new int[Cnum];
int ming = 255 minl = 0;
for( int i = 0; i {
cout<<“第“< cout< greyk[i] = (classmean0[i].RGBAve[0]+classmean0[i].RGBAve[1]+classmean0[i].RGBAve[2])/3;
cout< if ( greyk[i] < ming )
{
ming = greyk[i];
minl = i;
}
}*/
for( int i = 0; i {
cout<<“ 第 “< cout< }
cout<<“请输入路牌所属类的B均值:“< int B G R;
cin>>B;
cout<<“请输入路牌所属类的G均值:“< cin>>G;
cout<<“请输入路牌所属类的R均值:“< cin>>R;
//result ( classmean0 pixellabel ResultImage SourceImage classmea
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 59392 2015-04-17 13:17 K-means\Debug\K-means.exe
文件 499676 2015-04-17 13:17 K-means\Debug\K-means.ilk
文件 1371136 2015-04-17 13:17 K-means\Debug\K-means.pdb
文件 4197 2015-04-14 19:50 K-means\K-means\K-means.vcxproj
文件 942 2015-04-14 19:50 K-means\K-means\K-means.vcxproj.filters
文件 143 2015-04-14 19:47 K-means\K-means\K-means.vcxproj.user
文件 7453 2015-04-17 13:16 K-means\K-means\main.cpp
文件 13848576 2015-04-17 13:17 K-means\K-means.sdf
文件 888 2015-04-14 19:48 K-means\K-means.sln
..A..H. 11264 2015-04-17 13:17 K-means\K-means.suo
目录 0 2015-04-17 13:18 K-means\Debug
目录 0 2015-04-17 13:18 K-means\K-means
目录 0 2015-04-17 13:18 K-means
----------- --------- ---------- ----- ----
15803667 13
- 上一篇:20113022.pdf
- 下一篇:WindTurbineBlockset.rar
相关资源
- PID_AutoTune_v0.rar
- vspd7.2.308.zip
- 价值2k的H漫画小说系统
- Pythonamp;课堂amp;笔记(高淇amp;400;集第
- ddos压力测试工具99657
- UML建模大全
- 开源1A锂电池充电板TP4056原理图+PCB
- m1卡 ic卡可选择扇区初始化加密软件
- TSCC.exe
- FTP课程设计(服务端+客户端)
- 计算机图形学 边填充算法实现代码
- 电力系统潮流计算程序集合
- oracle数据迁移项目实施方案
- Web Api 通过文件流 文件到本地
- Visio图标-最新最全的网络通信图标库
- Spire API文档
- OpenGL参考手册
- Python中Numpy库最新教程
- SPD博士V5.3.exe
- 直流无刷电机方波驱动 stm32 例程代码
- layui后台管理模板
- 仿知乎界面小程序源代码
- 云平台-阿里云详细介绍
- photoshop经典1000例
- scratch垃圾分类源码(最终版本).sb
- IAR ARM 7.8破解
- TI CCS V5.4 安装步骤及破解文件
- 松下plc FP-XH的驱动
- 局域网硬件信息收集工具
- 加快Windows XP操作系统开机速度
评论
共有 条评论