www.pudn.com > firev0.01.rar > gabor-pca.cpp


/*
This file is part of the FIRE -- Flexible Image Retrieval System

FIRE is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

FIRE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with FIRE; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
#include 
#include 
#include 
#include "filelist.hpp"
#include "getpot.hpp"
#include "basetools.hpp"
#include "pca.hpp"
#include "diag.hpp"
#include "gabor.hpp"
using namespace std;
using namespace diag;

typedef vector FeatureVector;

void USAGE() {
  cout << "lf-l1o  filelist" << endl
       << "   -transform " << endl
       << "   -saveto " << endl
       << "   -transform and -saveto mutually exclusive" << endl
       << "   -suffix (default .pca)" << endl
       << "   -h show this help" << endl
       << "   -outDim int(default 20)" << endl
       << endl;
}

int main(int argc, char **argv) {
  GetPot cl(argc,argv);

  vector unident=cl.unidentified_options(6,"-transform","-saveto","-h","-outDim","-color","-suffix");

  if(unident.size()!=0 || argc<2 || cl.search("-h") || (cl.search("-transform") && cl.search("-saveto"))) {
    if(unident.size()!=0) {
      cout << "Unknown options: " ;
      for(unsigned int i=0;i* > read;
  PCA pca, pca2;
  
  bool color=cl.search("-color");
  int dim2=0;  
  if(! cl.search("-transform")) {
    read=loadGaborFeatures(filelist[0]);
    int dim=read[0]->size();
    
    
    if (color) {
      dim2=dim/2;
      pca=PCA(dim2);
      pca2=PCA(dim2);
      DBG(DBG_MESSAGE) << "2 x PCA with dim=" << dim2 << endl;
    } else {
      pca=PCA(dim);      
      pca2=PCA(0);
      DBG(DBG_MESSAGE) << "PCA with dim=" << dim << endl;
    }
    
    for(unsigned int i=0;i dat1(dim2), dat2(dim2);
          
          for(int x=0;x mean=pca.mean();
    for(unsigned int i=0;i > covar=pca.covariance();
    for(unsigned int i=0;i transformed;
  for(unsigned int i=0;i dat1(dim2), dat2(dim2);
        
        for( int x=0;x