// STL includes
#include <fstream>
#include <getopt.h>
#include <iostream>

// nice-core includes
#include <core/vector/VectorT.h>
#include <core/vector/MatrixT.h>
// 
#include <core/image/ImageT.h>
#include <core/imagedisplay/ImageDisplay.h>

// nice-vislearning includes
#include <vislearning/features/localfeatures/LocalFeatureColorWeijer.h>


using namespace std;
using namespace NICE;
using namespace OBJREC;


/**
 * @brief Printing main menu.
 * @author Alexander Freytag
 * @date 13-02-2013
 * 
 * @return void
 **/
void print_main_menu()
{
  std::cerr << "=====================================================================================" << std::endl;
  std::cerr << "||This is a small programm demonstrating the computation of 11-dim color features.  ||" << std::endl;
  std::cerr << "=====================================================================================" << std::endl;  
  
  std::cout << std::endl << "Input options:" << std::endl;
  std::cout << "   -i <filename>  the name of the image which shall be transformed"<< std::endl;
  return;
}


//post-process active learning segmentation results, such that the given images are normalized to be visualized in the same range
int main( int argc, char* argv[] )
{
  
  int rc;
  if (argc<2)
  {
    print_main_menu();
    return -1;
  }
  
  if ( (argc+1)%2 != 0 )
  {
    std::cerr << " WARNING -- even number of inputs required (specifier + value ) -- aborting... " << std::endl;
    return -1;
  }
   
  
  std::string filename("");
  while ((rc=getopt(argc,argv,"i:h"))>=0)
  {
    switch(rc)
    {
      case 'i': filename = optarg; break;
      default: print_main_menu();
    }
  }   

  NICE::Config *conf = new NICE::Config();
  OBJREC::LocalFeatureColorWeijer lfc(conf);

  //! testen
  NICE::ColorImage cimg;
  cimg.read( filename );
  
  NICE::ColorImage out;
  
  lfc.visualizeFeatures (cimg, out);

  cimg.writePPM("org.ppm");
  out.writePPM("out.ppm");
  
  delete conf;

  return 0;
}

