Home | Develop | Download | Contact
test_funcclustering_kmeans.cpp
1 
23 #include <cmath>
24 #include <Pds/Ra>
25 #include <Pds/Sp>
26 #include <Pds/Ml>
27 
28 int main(void)
29 {
30  std::vector<Pds::Matrix> Block;
31  std::vector<Pds::Matrix> WPI;
32  std::vector<Pds::Matrix> CC;
33 
34  Block=Pds::Matrix::ImportBmpFile("imagen1.bmp");
35 
36  unsigned int K=256;
37  Pds::Matrix Colors;
38  Pds::Array<unsigned int> MAPID;
39 
40  Pds::IterationConf Conf;
41  Conf.SetMinError(1.0);
42 
43  Colors=Pds::Clustering::Kmeans(Conf,Block,K,MAPID);
44  MAPID.ExportBmpFile(Pds::Array<unsigned char>(Colors),"imagen1-kmeans.bmp");
45 
46  WPI =Pds::Image::WhitePatch(Block);
47  CC =Pds::Image::ChromaticityCoordinates(WPI,255);
48 
49  Colors=Pds::Clustering::Kmeans(Conf,CC,K/2,MAPID);
50  MAPID.ExportBmpFile(Pds::Array<unsigned char>(Colors),"imagen1-cc-kmeans.bmp");
51 
52  if(CC.size()==3)
53  Pds::Matrix::ExportBmpFile(CC[0],CC[1],CC[2],"imagen1-cc.bmp");
54 
55  return 0;
56 }
57 
58 
La clase tipo Pds::IterationConf . Esta clase genera una matriz de Nlin lineas y 1 columna....
bool SetMinError(double MinError)
Coloca el valor MinError.
Pds::Matrix Kmeans(Pds::IterationConf &Conf, const std::vector< Pds::Matrix > &Block, unsigned int K, Pds::Array< unsigned int > &IDMAP)
Calculo de los centroides.

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed