www.pudn.com > firev0.01.rar > gaborize.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 */ /** * program to extract gabor features from an image. * */ #include#include "rgbimage.hpp" #include "hdimage.hpp" #include "gabor.hpp" #include "getpot.hpp" using namespace std; using namespace img; /** * Write how to use this program to stdout. Might be out of date. But * is fine today: 2003-05-12 * */ void USAGE() { cout << "USAGE: gaborize [options] filename" << endl << " options:"<< endl << " -numpha (int, default 5)" << endl << " -numfreq (int, default 5)" << endl << " -threshold (double, default 200)" << endl << " -winsize (int default 7)" << endl << " -all (=save all, default= save only those with threshold above variance)" << endl << " -nOfFeatures " << endl << " -color or -grey to tell which type of image is loaded" << endl << endl; } int main(int argc, char **argv) { GetPot cl(argc,argv); if(cl.search("-h")) { USAGE(); exit(20); } string filename=argv[argc-1]; HDImage decomp; int counter; if(cl.search("-color")) { ::img::RGBImage image; image.load(filename.c_str()); decomp=decompose(image,cl.follow(5, "-numpha"),cl.follow(5,"-numfreq")); if(cl.search("-all")) { counter=saveGaborFeatures(decomp,filename+".gaborfeatures"); } else if(cl.search("-nOfFeatures")) { cout << "nOfFeatures determined" << endl; counter=extractGaborFeatures(filename+".gaborfeatures",image,decomp,cl.follow(1000,"-nOfFeatures"), cl.follow(7,"-winsize")); } else { cout << "threshold determinded " << endl; counter=extractGaborFeatures(filename+".gaborfeatures",image,decomp,cl.follow(200.0,"-threshold"), cl.follow(7,"-winsize")); } } else if(cl.search("-grey")) { ::img::BaseImage image; image.load(filename.c_str()); decomp=decompose(image,cl.follow(5, "-numpha"),cl.follow(5,"-numfreq")); if(cl.search("-all")) { counter=saveGaborFeatures(decomp,filename+".gaborfeatures"); } else if(cl.search("-nOfFeatures")) { cout << "nOfFeatures determined" << endl; counter=extractGaborFeatures(filename+".gaborfeatures",image,decomp,cl.follow(1000,"-nOfFeatures"), cl.follow(7,"-winsize")); } else { cout << "threshold determinded " << endl; counter=extractGaborFeatures(filename+".gaborfeatures",image,decomp,cl.follow(200.0,"-threshold"), cl.follow(7,"-winsize")); } } else { USAGE(); exit(20); } DBG(DBG_RESULT) << "Saved " << counter <<" gaborfeatures."<< endl; DBGI(DBG_VERBOSE,decomp.writePNG("decomp")); }