template<class ArrayT>
Definition at line 16 of file MatFeatureNormalization.h. References MatE(), MatNrCol(), MatNrRow(), MatSet(), and VecE(). Referenced by Impala::Core::Array::ColorSegmentation(). 00017 { 00018 typedef typename ArrayT::ArithType ArithT; 00019 typedef typename ArrayT::StorType StorT; 00020 00021 int nRow = MatNrRow(m); 00022 int nCol = MatNrCol(m); 00023 ArrayT* M = VecCreate<ArrayT>(nCol); //means 00024 ArrayT* S = VecCreate<ArrayT>(nCol); //variances 00025 00026 MatSet(M, 0); 00027 MatSet(S, 0); 00028 00029 StorT* MPtr = VecE(M, 0); 00030 StorT* SPtr = VecE(S, 0); 00031 for (int i=0 ; i<nRow ; i++) 00032 { 00033 StorT* miPtr = MatE(m, i, 0); 00034 for (int j=0 ; j<nCol ; j++) 00035 { 00036 ArithT x = miPtr[j]; 00037 MPtr[j] += x; 00038 SPtr[j] += x*x; 00039 } 00040 } 00041 00042 for (int j=0 ; j<nCol ; j++) 00043 { 00044 ArithT mj = MPtr[j]/nRow; 00045 SPtr[j] = sqrt( SPtr[j]/nRow - mj * mj ); 00046 } 00047 00048 //normalize 00049 for (int k=0 ; k<nRow; k++) 00050 { 00051 StorT* mkPtr = MatE(m, k, 0); 00052 for (int j=0 ; j<nCol ; j++) 00053 mkPtr[j] = mkPtr[j] / SPtr[j]; 00054 } 00055 00056 delete M; 00057 delete S; 00058 }
Here is the call graph for this function:
|