/* -*- mode: c++ -*-
*/
/*
GIFT, a flexible content based image retrieval system.
Copyright (C) 1998, 1999, 2000 CUI, University of Geneva
This program 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.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* this file is mainly obsolete, because the surrounding test programs
have been deleted
WM
*/
#ifndef _HELPERS
#define _HELPERS
#include <string>
#include <iostream>
#include <fstream>
extern string gMasterNameBase;
extern int gNumberOfImages;
float indexToX(int inIndex);
float indexToY(int inIndex);
//getting a random ID
int getRandomID();
//Translating an index to a point in 2d-space
//then translating it to euclidean distance
float indexToDistance(int inIndexI,int inIndexJ);
string makeName(int inNumber,string inBase="Outfile.txt");
template<class TTIterator>
void show_singles_as_points(const TTIterator& inBegin,
const TTIterator& inEnd,
const string& inFileNameBase=string("Outfile.txt"),
int inFileNumber){
string lFileName=makeName(inFileNumber,inFileNameBase);
ofstream lOut(lFileName.c_str());
for(TTIterator i=inBegin;
i!=inEnd;
i++){
lOut << indexToX(*i)
<< " "
<< indexToY(*i)
<< " "
<< 0
<< endl
<< flush;
}
}
template<class TTIterator>
void show_pairs(const TTIterator& inBegin,
const TTIterator& inEnd,
const string& inFileNameBase=string("Outfile.txt")){
static int lFileNumber=0;
lFileNumber++;
string lFileName=makeName(lFileNumber,inFileNameBase);
ofstream lOut(lFileName.c_str());
for(TTIterator i=inBegin;
i!=inEnd;
i++){
lOut << indexToX(i->first)
<< " "
<< indexToY(i->first)
<< " "
<< i->second
<< endl
<< flush;
}
}
template<class TTIterator>
void show_ProbabilisticSetElements(const TTIterator& inBegin,
const TTIterator& inEnd,
const string& inFileNameBase
=string("Outfile.txt"),
const bool inConvertToPairs=false
){
static int lFileNumber=0;
lFileNumber++;
string lFileName=makeName(lFileNumber,
inFileNameBase);
ofstream lOut(lFileName.c_str());
for(TTIterator i=inBegin;
i!=inEnd;
i++){
if(inConvertToPairs){
lOut << indexToX(i->getContent())
<< " "
<< indexToY(i->getContent())
<< " "
<< i->getProbability()
<< endl
<< flush;
}else{
lOut << i->getContent()
<< " "
<< i->getProbability()
<< endl
<< flush;
}
}
}
#endif
Documentation generated by muellerw@pc7170 on Son Okt 8 16:04:40 CEST 2000