www.pudn.com > firev0.01.rar > gabor-histogramization.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 "filelist.hpp"
#include "getpot.hpp"
#include "basefeature.hpp"
#include "gaussiandensity.hpp"
#include "gabor.hpp"
#include "basetools.hpp"
#include "distances.hpp"
#include "histogram.hpp"

using namespace std;
using namespace img;

void USAGE() {
  cout << "cat qsub-log |  grep Cluster | grep -e variance -e mean | irma-gabor-histogramization " << endl
       << "  options:" << endl
       << "    -filelist    list of files to be processed" << endl
       << "    -suffix (default .gaborhisto)" << endl
       << endl;
}

const int whichCluster(const vector &obs ,const vector & clusters) {
  double minDist=999999999;
  int minClusters=-1;
  EuclideanDist* dist=new EuclideanDist();
  double aktDist=0;
  for(unsigned int i=0;idist(obs,clusters[i].mean,clusters[i].sigma);
    if(aktDist clustercenters;
  
  string tmp, clusterstring,typestring;
  int clusternumber;
  double value;
  char line[1025];
  
  istringstream iss;

  vector clusters;
  GaussianDensity gd;

  vector mean;
  vector sigma;
  string positioninFile;
  DBG(DBG_MESSAGE) << "Reading clusters from stdin: " ;

  while(!cin.eof()) {
    cin >> tmp >> positioninFile >> clusterstring >> clusternumber >> typestring;
    if(!cin.eof() &&  clusternumber == int(clusters.size())) {
      if(typestring=="mean") {
        BLINK(DBG_MESSAGE) << "µ";
        mean.clear();
        sigma.clear();        
        
        cin.getline(line,1024);
        istringstream iss(line);
        while(!iss.eof()) {
          iss >> value;
          mean.push_back(value);
        }
      } else if (typestring =="variance") {
        BLINK(DBG_MESSAGE) << "v";
        cin.getline(line,1024);
        istringstream iss(line);
        while(!iss.eof()) {
          iss >> value;
          sigma.push_back(value);
        }
        gd.mean=mean;
        gd.sigma=sigma;
        clusters.push_back(gd);
        BLINK(DBG_MESSAGE) << clusters.size()<< endl;;
      }
    } else break;
  }
  
  DBG(DBG_MESSAGE) << "Found " << clusters.size() << " clusters." << endl;
  
  FileList filelist(cl.follow("filelist","-filelist"));
  
  DBG(DBG_MESSAGE) << "Going to process " < histo;
  
  vector< vector* > read;
  for(unsigned int i=0;i(0,clusters.size(),clusters.size()-1);
    read=loadGaborFeatures(filelist[i]);
    DBG(DBG_MESSAGE) << "Histogrammizing '" << filelist[i] << "' with " << read.size() << " gaborfeatures." << endl;
    for(unsigned int k=0;k