Home | Develop | Download | Contact
test_funcclustering_kmeans2.cpp
1 
23 #include <cmath>
24 #include <Pds/Ra>
25 #include <Pds/Ml>
26 
27 int main(void)
28 {
29  std::vector<Pds::Matrix> Block;
30 
31  Block=Pds::Matrix::ImportBmpFile("imagen1.bmp");
32  unsigned int Nlin=Block[0].Nlin();
33  unsigned int Ncol=Block[0].Ncol();
34  Pds::Matrix X=Pds::Matrix::GetSamples(Block);
35  Block[0].MakeEmpty(); Block[1].MakeEmpty(); Block[2].MakeEmpty();
36 
37  unsigned int K=256;//128;
38  Pds::Matrix Colors;
39  Pds::Array<unsigned int> MAPID;
40 
41  Pds::IterationConf Conf;
42  Conf.SetMinError(1.0);
43 
44  Colors=Pds::Clustering::Kmeans(Conf,X,K,MAPID);
45  MAPID.Reshape(Nlin,Ncol);
46  MAPID.ExportBmpFile(Pds::Array<unsigned char>(Colors),"imagen1-kmeans.bmp");
47 
48  return 0;
49 }
50 
51 
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