资源简介
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
相关资源
- WindTurbineBlockset.rar
- 20113022.pdf
- VisualStudio2012入门教程(4个).pdf
- bacnet-stack-0.5.8.zip
- (2).rar
- 物流管理系统.rar
- AWS无服务器架构.pdf
- 2rbkxt.rar
- 拼图游戏c源代码附程序.zip
- 基于Adaboost算法的实时行人检测系统
- 论文.doc
- VC编程技术600个大型项目源码.rar
- 音像出租管理系统毕业设计c.rar
- DS2072快速指南.pdf
- 有数据的DataPetshop.zip
- tongxueluvc.rar
- 2055287学生管理系统.rar
- 图像去雾.docx
- busybox-1.21.0.tar.bz2
- 有这个变压器无敌手.rar
- 4947fbbfec974f79811df99fa25dbe13.zip
- KNIME设计之节点学习.pdf
- 1730365atherosar9565xp驱动.zip
- UcosII官方源码及中文注释.7z
- OV7670摄像头使用浅谈.pdf
- 2217601TankWar1.8.14.rar
- TankWar.rar
- erydor.rar
- MvcApplication1.rar
- UML与设计模式.zip
评论
共有 条评论