00001 #ifndef _RWindowPcaOp_H 00002 #define _RWindowPcaOp_H 00003 00036 #include <stdio.h> 00037 00038 #include "AnImage.hpp" 00039 #include "AbsRImageFilter.hpp" 00040 00041 #include "RImage.hpp" 00042 #include "Real3CImage.hpp" 00043 00044 class RWindowPcaOp : public AbsRImageFilter 00045 { 00046 private: 00047 00048 int width, height; 00049 00050 int pcaChannel; // wanted PCA channel 00051 00052 int nWindows; 00053 int widthW, heightW; // Window size 00054 int nwW, nhW, dimensionW; 00055 00056 double* meanSample; 00057 double* covariance; 00058 00059 00060 double* eigenValue; 00061 double* triDiagonalCov; 00062 double* eigenVectors; 00063 00064 double* e; // temporary eigenvalue computation 00065 00066 protected: 00067 00068 void computeWindowCovariance(RImage* g); 00069 00070 void triDiagonalisation(); 00071 00072 // Public householder tridiagonalisation in C 00073 void tri_diag(double* a,double* d,double* e,double* z,int n,double tol); 00074 int calc_eigenstructure(double* d,double* e,double* z,int n,double macheps); 00075 00076 public: 00077 00078 RWindowPcaOp(int widthWindow=8, int heightWindow=8, int pcaChannel=0); 00079 virtual ~RWindowPcaOp(); 00080 00081 // Default is principal component for each channel 00082 virtual RImage* filter(RImage* source, RImage* destination=0); 00083 00084 // All channels recovered 00085 // virtual Real3CImage* singleFilter(AnImage* source, Real3CImage* destination); 00086 00087 virtual void report(FILE* file){} 00088 virtual void report(){} 00089 }; 00090 00091 #endif