Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

ReferenceVector.hh

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*/
00006 /*---------------------------------------------------------------------------*/
00007 
00008 #include <iostream>
00009 #include <string>  
00010 #include <vector>
00011 #include <fstream>
00012 
00013 #include <cstdio>
00014 #include <cstdlib>
00015 #include <cmath>
00016 #include <cassert>
00017 
00018 #include "./Image_basics.hh"
00020 #define PIXEL float
00021 using namespace std;
00022 
00024 class Generic_Vector :  public vector<float*>
00025 {
00026         public: 
00027                 
00028                 Generic_Vector()
00029                 {       
00030                         Initialise();
00031                         
00032                 }
00033         protected:
00035                 Image<PIXEL>* im_point;
00036         
00037         private : 
00039                 virtual void Initialise()
00040                 {
00041                         im_point=NULL; 
00042                 }       
00043                 
00044                 
00045         
00046 };
00047 /**********************************************************************************************/
00048 
00051 class Ref_Vector : public Generic_Vector        
00052 {       
00053         public:
00055                 int nb_ref;
00057                 Ref_Vector(Image<PIXEL> *data_point,int nb_init) : Generic_Vector()
00058                 {               
00059                 im_point=data_point;
00060                 Initialise(im_point,nb_init);
00061 
00062                 }
00063                 /*--------------------------------------------------------------------------------------------*/
00065                 void AddRefVectors(int nb_init)
00066                 {
00067                 int i,j;
00068                         unsigned long int dim;
00069                         dim=(*im_point).nx*(*im_point).ny;
00070                         int nb_bands=(*im_point).nb_bands;
00071                         int Nb_Ref_Vector_Init=(int)((nb_init-nb_ref)*1.6);
00072                         float *moy=new float[nb_bands];
00073                         float *dev=new float[nb_bands];
00074                         float gasdev(long *idum); 
00075                         long int *auxI=new long int[1];
00076                         float ** tmp = new float * [Nb_Ref_Vector_Init];
00077                         for (i=0;i<Nb_Ref_Vector_Init;i++)
00078                                  {
00079                                  tmp[i] = new float[nb_bands];
00080                                  }
00081                         for (j=0;j<nb_bands;j++){
00082                                 moy[j]=(*im_point).Mean(j);
00083                                 dev[j]=(*im_point).Stdev(j);
00084                         }
00085                         
00086                         
00087                         for (i=0;i<Nb_Ref_Vector_Init;i++){     
00088                                 
00089                                 auxI[0]=(unsigned long)((float)rand()*1);
00090                                 for (j=0;j<nb_bands;j++)
00091                                         {tmp[i][j]=gasdev(auxI)*i/Nb_Ref_Vector_Init*dev[j]+moy[j];}
00092                                 push_back(tmp[i]);
00093                         }
00094                         
00095                         
00096                         nb_ref=Nb_Ref_Vector_Init+nb_ref;
00097                         cout <<Nb_Ref_Vector_Init<<" added Reference Vectors"<<endl;            
00098                         
00099                          delete [] moy; delete [] dev; delete [] auxI;
00100                         
00101                 }
00102                 /*---------------------------   -----------------------------------------------------------------*/
00103 
00104         private:        
00105                 /*--------------------------------------------------------------------------------------------*/
00107                         void Initialise(Image<PIXEL> *data_point,int nb_init)
00108                 {
00109                         int i,j;
00110                         unsigned long int dim;
00111                         dim=(*data_point).nx*(*data_point).ny;
00112                         
00113                         if(nb_init==-1){ nb_init=(int)((log((double)dim)))*3.5*log((double)im_point->nb_bands)*2.0;}
00114                             
00115                         int nb_bands=(*data_point).nb_bands;
00116                         int Nb_Ref_Vector_Init=(nb_init);
00117                         float ** tmp = new float * [Nb_Ref_Vector_Init];
00118                         float *moy=new float[nb_bands];
00119                         float *dev=new float[nb_bands];
00120                         float gasdev(long *idum); 
00121                         long int *auxI=new long int[1];
00122                         //auxI[0]=-(int)(((float)rand())/RAND_MAX);
00123                         for (i=0;i<Nb_Ref_Vector_Init;i++)
00124                                  {
00125                                  tmp[i] = new float[nb_bands];
00126                                  }
00127                         for (j=0;j<nb_bands;j++){
00128                                 moy[j]=(*data_point).Mean(j);
00129                                 dev[j]=(*data_point).Stdev(j);
00130                         }
00131                         
00132                         for (i=0;i<Nb_Ref_Vector_Init;i++){     
00133                                 
00134                                 auxI[0]=(unsigned long)((float)rand());
00135                                 for (j=0;j<nb_bands;j++)
00136                                         {tmp[i][j]=gasdev(auxI)*dev[j]+moy[j];}
00137                                 push_back(tmp[i]);
00138                         }
00139                         
00140                         nb_ref=Nb_Ref_Vector_Init;
00141                         cout << "Initialisation of " <<Nb_Ref_Vector_Init<<" Reference Vectors done"<<endl;             
00142                          delete [] moy; delete [] dev; delete [] auxI;
00143                         
00144                         
00145                 }
00146                 /*--------------------------------------------------------------------------------------------*/
00147 
00148                 
00149 
00150                 
00151 };
00152 /**********************************************************************************************/
00155 class Outliers : public Generic_Vector
00156 {
00157 
00158         public:
00160                 int nb_outliers;
00161                 
00162                 Outliers() : Generic_Vector()
00163                 {
00164                 Initialise();
00165                 }
00166         private:
00168                 void Initialise()
00169                 {
00170                 nb_outliers=0;
00171                 }
00172 
00173 
00174 
00175 };
00176 /**********************************************************************************************/

Generated on Thu Feb 17 11:01:08 2005 for Gaussian Mixture Modeling by the MDL principle by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002