Explorar o código

PCA problem fixed

Bjoern Froehlich %!s(int64=13) %!d(string=hai) anos
pai
achega
3b60d9789c

+ 202 - 174
baselib/ICETools.cpp

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file ICETools.cpp
 * @file ICETools.cpp
 * @brief simple ICE GUI tools
 * @brief simple ICE GUI tools
 * @author Erik Rodner
 * @author Erik Rodner
@@ -35,24 +35,24 @@ ICETools::~ICETools()
 
 
 void ICETools::selectRectangles ( const NICE::Image & panel, NICE::Image & overlay, vector<Vector> & x, int color )
 void ICETools::selectRectangles ( const NICE::Image & panel, NICE::Image & overlay, vector<Vector> & x, int color )
 {
 {
-	fthrow(Exception, "ICETools::selectRectangles -- not yet implemented due to old ICE version.");
+  fthrow ( Exception, "ICETools::selectRectangles -- not yet implemented due to old ICE version." );
 // #ifndef NOVISUAL
 // #ifndef NOVISUAL
 //     // new NICE code
 //     // new NICE code
 //     vector<RectT<double> > rectangles;
 //     vector<RectT<double> > rectangles;
-// 	 //TODO check this!
+//   //TODO check this!
 // //     NICE::selectRectangles ( panel, rectangles, "select rectangles" );
 // //     NICE::selectRectangles ( panel, rectangles, "select rectangles" );
-// // 	 selectRectangles ( panel, rectangles, "select rectangles" );
-// 
+// //   selectRectangles ( panel, rectangles, "select rectangles" );
+//
 //     for ( vector<RectT<double> >::const_iterator i = rectangles.begin();
 //     for ( vector<RectT<double> >::const_iterator i = rectangles.begin();
-// 	i != rectangles.end(); i++ )
+//  i != rectangles.end(); i++ )
 //     {
 //     {
-// 	Vector vec (4);
-// 	vec[0] = i->left;
-// 	vec[1] = i->top;
-// 	vec[2] = i->right();
-// 	vec[3] = i->bottom();
-// 
-// 	x.push_back ( vec ); 
+//  Vector vec (4);
+//  vec[0] = i->left;
+//  vec[1] = i->top;
+//  vec[2] = i->right();
+//  vec[3] = i->bottom();
+//
+//  x.push_back ( vec );
 //     }
 //     }
 // #else
 // #else
 //     fprintf (stderr, "ICETools::selectRectangles: visualization disabled !\n");
 //     fprintf (stderr, "ICETools::selectRectangles: visualization disabled !\n");
@@ -61,27 +61,27 @@ void ICETools::selectRectangles ( const NICE::Image & panel, NICE::Image & overl
 
 
 void ICETools::selectPoints ( const NICE::Image & panel, NICE::Image & overlay, vector<Vector> & x, int color )
 void ICETools::selectPoints ( const NICE::Image & panel, NICE::Image & overlay, vector<Vector> & x, int color )
 {
 {
-	fthrow(Exception, "ICETools::selectPoints -- not yet implemented due to old ICE version.");
+  fthrow ( Exception, "ICETools::selectPoints -- not yet implemented due to old ICE version." );
 // #ifndef NOVISUAL
 // #ifndef NOVISUAL
 //     vector<CoordT<double> > points;
 //     vector<CoordT<double> > points;
-// 	 //TODO check this!
+//   //TODO check this!
 // //     NICE::selectPoints ( panel, points, "select points" );
 // //     NICE::selectPoints ( panel, points, "select points" );
-// // 	selectPoints ( panel, points, "select points" );
-// 
+// //  selectPoints ( panel, points, "select points" );
+//
 //     for ( vector<CoordT<double> >::const_iterator i = points.begin();
 //     for ( vector<CoordT<double> >::const_iterator i = points.begin();
-// 	i != points.end(); i++ )
+//  i != points.end(); i++ )
 //     {
 //     {
-// 	Vector vec (2);
-// 	vec[0] = i->x;
-// 	vec[1] = i->y;
-// 
-// 	x.push_back ( vec ); 
+//  Vector vec (2);
+//  vec[0] = i->x;
+//  vec[1] = i->y;
+//
+//  x.push_back ( vec );
 //     }
 //     }
-//    
+//
 //     /** OLD ICE Code
 //     /** OLD ICE Code
 //     int p[2];
 //     int p[2];
 //     int rc = -1;
 //     int rc = -1;
-// 
+//
 //     while ( (rc = SelPoint ( DEFAULT, panel, p )) != -1 )
 //     while ( (rc = SelPoint ( DEFAULT, panel, p )) != -1 )
 //     {
 //     {
 //         int x1, y1;
 //         int x1, y1;
@@ -102,144 +102,172 @@ void ICETools::selectPoints ( const NICE::Image & panel, NICE::Image & overlay,
 
 
 void ICETools::toColor ( double x, double & r, double & g, double & b )
 void ICETools::toColor ( double x, double & r, double & g, double & b )
 {
 {
-    size_t seg = (size_t)(x * 6.0);
-    double y   = ( 6*x - seg );
-
-    switch ( seg ) {
-	case 0: r=0.0; g=0.0; b=y;   break; 
-	case 1: r=0.0; g=  y; b=1.0; break; 
-	case 2: r=0.0; g=1.0; b=1.0-y; break; 
-	case 3: r=  y; g=1.0; b=0.0;   break; 
-	case 4: r=1.0; g=1.0-y; b=0.0;   break; 
-	case 5: r=1.0; g=y; b=y;   break; 
-	default: r=1.0; g=1.0; b=1.0; break;
-    }
+  size_t seg = ( size_t ) ( x * 6.0 );
+  double y   = ( 6 * x - seg );
+
+  switch ( seg ) {
+    case 0:
+      r = 0.0;
+      g = 0.0;
+      b = y;
+      break;
+    case 1:
+      r = 0.0;
+      g =  y;
+      b = 1.0;
+      break;
+    case 2:
+      r = 0.0;
+      g = 1.0;
+      b = 1.0 - y;
+      break;
+    case 3:
+      r =  y;
+      g = 1.0;
+      b = 0.0;
+      break;
+    case 4:
+      r = 1.0;
+      g = 1.0 - y;
+      b = 0.0;
+      break;
+    case 5:
+      r = 1.0;
+      g = y;
+      b = y;
+      break;
+    default:
+      r = 1.0;
+      g = 1.0;
+      b = 1.0;
+      break;
+  }
 }
 }
 
 
 void ICETools::convertToRGB ( const NICE::Matrix & m, NICE::ColorImage & img )
 void ICETools::convertToRGB ( const NICE::Matrix & m, NICE::ColorImage & img )
 {
 {
-	img.resize ( m.cols(), m.rows() );
-    double max = - numeric_limits<double>::max();
-    double min = numeric_limits<double>::max();
-    for ( size_t x = 0 ; x < (size_t)m.cols(); x++ )
-	for ( size_t y = 0 ; y < (size_t)m.rows() ; y++ )
-	{
-	    if (m(y, x) > max ) max =m(y, x);
-	    if (m(y, x) < min ) min =m(y, x);
-	}
-    
-    for ( size_t y = 0 ; y < (size_t)m.rows() ; y++ )
-	for ( size_t x = 0 ; x < (size_t)m.cols(); x++ )
-	{
-	    double val =(m(y, x) - min) / (max-min);
-	    double r,g,b;
-	    toColor(val, r, g, b);
-	    img.setPixel(x,y,0,(int)(r*255));
-	    img.setPixel(x,y,1,(int)(g*255));
-	    img.setPixel(x,y,2,(int)(b*255));
-	}
+  img.resize ( m.cols(), m.rows() );
+  double max = - numeric_limits<double>::max();
+  double min = numeric_limits<double>::max();
+  for ( size_t x = 0 ; x < ( size_t ) m.cols(); x++ )
+    for ( size_t y = 0 ; y < ( size_t ) m.rows() ; y++ )
+    {
+      if ( m ( y, x ) > max ) max = m ( y, x );
+      if ( m ( y, x ) < min ) min = m ( y, x );
+    }
+cout << "max: " << max << " min: " << min << endl;
+  for ( size_t y = 0 ; y < ( size_t ) m.rows() ; y++ )
+    for ( size_t x = 0 ; x < ( size_t ) m.cols(); x++ )
+    {
+      double val = ( m ( y, x ) - min ) / ( max - min );
+      double r, g, b;
+      toColor ( val, r, g, b );
+      img.setPixel ( x, y, 0, ( int ) ( r*255 ) );
+      img.setPixel ( x, y, 1, ( int ) ( g*255 ) );
+      img.setPixel ( x, y, 2, ( int ) ( b*255 ) );
+    }
 }
 }
 
 
 void ICETools::convertToRGB ( const NICE::FloatImage & m, NICE::ColorImage & img )
 void ICETools::convertToRGB ( const NICE::FloatImage & m, NICE::ColorImage & img )
 {
 {
-	img.resize ( m.width(), m.height() );
-    double max = - numeric_limits<double>::max();
-    double min = numeric_limits<double>::max();
-    for ( size_t x = 0 ; x < (size_t)m.width(); x++ )
-	for ( size_t y = 0 ; y < (size_t)m.height() ; y++ )
-	{
-	    double v = m.getPixel(x,y);
-	    if ( v > max ) max = v;
-	    if ( v < min ) min = v;
-	}
-    
-    for ( size_t y = 0 ; y < (size_t)m.height() ; y++ )
-	for ( size_t x = 0 ; x < (size_t)m.width(); x++ )
-	{
-	    double val = (m.getPixel(x,y) - min) / (max-min);
-	    double r,g,b;
-	    toColor(val, r, g, b);
-	    img.setPixel(x,y,0,(int)(r*255));
-	    img.setPixel(x,y,1,(int)(g*255));
-	    img.setPixel(x,y,2,(int)(b*255));
-	}
+  img.resize ( m.width(), m.height() );
+  double max = - numeric_limits<double>::max();
+  double min = numeric_limits<double>::max();
+  for ( size_t x = 0 ; x < ( size_t ) m.width(); x++ )
+    for ( size_t y = 0 ; y < ( size_t ) m.height() ; y++ )
+    {
+      double v = m.getPixel ( x, y );
+      if ( v > max ) max = v;
+      if ( v < min ) min = v;
+    }
+
+  for ( size_t y = 0 ; y < ( size_t ) m.height() ; y++ )
+    for ( size_t x = 0 ; x < ( size_t ) m.width(); x++ )
+    {
+      double val = ( m.getPixel ( x, y ) - min ) / ( max - min );
+      double r, g, b;
+      toColor ( val, r, g, b );
+      img.setPixel ( x, y, 0, ( int ) ( r*255 ) );
+      img.setPixel ( x, y, 1, ( int ) ( g*255 ) );
+      img.setPixel ( x, y, 2, ( int ) ( b*255 ) );
+    }
 }
 }
 
 
 void ICETools::calcGrayImage ( const NICE::ColorImage & img, NICE::Image & imgg )
 void ICETools::calcGrayImage ( const NICE::ColorImage & img, NICE::Image & imgg )
 {
 {
-    imgg.resize(img.width(), img.height());
-    for ( int y = 0 ; y < img.height(); y++ )
-      for ( int x = 0 ; x < img.width() ; x++ )
-      {
-        unsigned char g = (unsigned char)(0.299*img.getPixel(x,y,0) + 
-          0.587*img.getPixel(x,y,1) + 0.114*img.getPixel(x,y,2));
-        imgg.setPixel(x,y,g);
-      }
+  imgg.resize ( img.width(), img.height() );
+  for ( int y = 0 ; y < img.height(); y++ )
+    for ( int x = 0 ; x < img.width() ; x++ )
+    {
+      unsigned char g = ( unsigned char ) ( 0.299 * img.getPixel ( x, y, 0 ) +
+                                            0.587 * img.getPixel ( x, y, 1 ) + 0.114 * img.getPixel ( x, y, 2 ) );
+      imgg.setPixel ( x, y, g );
+    }
 }
 }
 
 
 double *ICETools::convertICE2M ( const NICE::Matrix & M )
 double *ICETools::convertICE2M ( const NICE::Matrix & M )
 {
 {
-    double *raw = new double [ M.rows() * M.cols() ];
-    long index = 0;
-    for ( uint i = 0 ; i < M.rows() ; i++ )
-      for ( uint j = 0 ; j < M.cols() ; j++, index++ )
-        raw[index] = M(i, j);
+  double *raw = new double [ M.rows() * M.cols() ];
+  long index = 0;
+  for ( uint i = 0 ; i < M.rows() ; i++ )
+    for ( uint j = 0 ; j < M.cols() ; j++, index++ )
+      raw[index] = M ( i, j );
 
 
-    return raw;
+  return raw;
 }
 }
 
 
 void ICETools::convertM2ICE ( NICE::Matrix & M, double *raw )
 void ICETools::convertM2ICE ( NICE::Matrix & M, double *raw )
 {
 {
-    long index = 0;
-    for ( int i = 0 ; i < (int)M.rows() ; i++ )
-		for ( int j = 0 ; j < (int)M.cols() ; j++, index++ )
-	    	M(i, j) = raw[index];
+  long index = 0;
+  for ( int i = 0 ; i < ( int ) M.rows() ; i++ )
+    for ( int j = 0 ; j < ( int ) M.cols() ; j++, index++ )
+      M ( i, j ) = raw[index];
 }
 }
 
 
 #ifndef NOVISUAL
 #ifndef NOVISUAL
-int ICETools::markImage (const NICE::Image & img, NICE::Image & mark, int marksize, int color)
+int ICETools::markImage ( const NICE::Image & img, NICE::Image & mark, int marksize, int color )
 {
 {
-    fprintf (stderr, "ICETools::markImage: reimplement this function for NICE\n");
-    exit(-1);
-
-/*
-    int flags;
-    int p[2];
-    int xo = -1;
-    int yo = -1;
-    
-    while(1) {
-	// refactor-nice.pl: check this substitution
-	// old: flags = Mouse(img,p[0],p[1]);
-	// REFACTOR-FIXME Unable to map this statement
-	if ( (flags & M_LEFT_DOWN) > 0 ) {
-	    if ( (p[0] != xo) || (p[1] != yo) ) {
-		if ( marksize == 1 ) {
-		    // refactor-nice.pl: check this substitution
-		    // old: PutVal( mark, p[0], p[1], color );
-		    mark.setPixel(p[0],p[1],color);
-		} else {
-		    // refactor-nice.pl: check this substitution
-		    // old: Marker(3, p[0], p[1], color, marksize, mark);
-		    // REFACTOR-FIXME Unable to map this statement
-		}
-       
-		xo = p[0];
-		yo = p[1];
-	    }
-	}
-	if ( (flags & M_RIGHT_DOWN) > 0 ) {
-	    while ( (flags & M_RIGHT_DOWN) > 0 ) {
-		// refactor-nice.pl: check this substitution
-		// old: flags = Mouse(img,p[0],p[1]);
-		// REFACTOR-FIXME Unable to map this statement
-	    };
-	    return -1;
-	}
+  fprintf ( stderr, "ICETools::markImage: reimplement this function for NICE\n" );
+  exit ( -1 );
+
+  /*
+      int flags;
+      int p[2];
+      int xo = -1;
+      int yo = -1;
+
+      while(1) {
+   // refactor-nice.pl: check this substitution
+   // old: flags = Mouse(img,p[0],p[1]);
+   // REFACTOR-FIXME Unable to map this statement
+   if ( (flags & M_LEFT_DOWN) > 0 ) {
+       if ( (p[0] != xo) || (p[1] != yo) ) {
+    if ( marksize == 1 ) {
+        // refactor-nice.pl: check this substitution
+        // old: PutVal( mark, p[0], p[1], color );
+        mark.setPixel(p[0],p[1],color);
+    } else {
+        // refactor-nice.pl: check this substitution
+        // old: Marker(3, p[0], p[1], color, marksize, mark);
+        // REFACTOR-FIXME Unable to map this statement
     }
     }
-*/
 
 
-    return 0;
+    xo = p[0];
+    yo = p[1];
+       }
+   }
+   if ( (flags & M_RIGHT_DOWN) > 0 ) {
+       while ( (flags & M_RIGHT_DOWN) > 0 ) {
+    // refactor-nice.pl: check this substitution
+    // old: flags = Mouse(img,p[0],p[1]);
+    // REFACTOR-FIXME Unable to map this statement
+       };
+       return -1;
+   }
+      }
+  */
+
+  return 0;
 }
 }
 
 
 // refactor-nice.pl: check this substitution
 // refactor-nice.pl: check this substitution
@@ -247,46 +275,46 @@ int ICETools::markImage (const NICE::Image & img, NICE::Image & mark, int marksi
 int ICETools::showImages ( vector<NICE::Image> & imagelist )
 int ICETools::showImages ( vector<NICE::Image> & imagelist )
 {
 {
 #ifndef NOVISUAL
 #ifndef NOVISUAL
-    for ( size_t j = 0 ; j < imagelist.size() ; j++ )
-    {
-	// refactor-nice.pl: check this substitution
-	// old: Show(ON, imagelist[j]);
-	showImage(imagelist[j]);
-    }
+  for ( size_t j = 0 ; j < imagelist.size() ; j++ )
+  {
+    // refactor-nice.pl: check this substitution
+    // old: Show(ON, imagelist[j]);
+    showImage ( imagelist[j] );
+  }
 #endif
 #endif
 
 
-    // assumption: same size
-    // refactor-nice.pl: check this substitution
-    // old: int xsize = imagelist[0]->xsize;
-    int xsize = imagelist[0].width();
-    // refactor-nice.pl: check this substitution
-    // old: int ysize = imagelist[0]->ysize;
-    int ysize = imagelist[0].height();
-
-    int n = imagelist.size();
-    int n1 = (int)sqrt(n);
-    int n2 = n/n1 + 1;
-
-    NICE::Image img (n1*xsize, n2*ysize);
-    img.set(0);
-    int k = 0;
-    for ( int j = 0 ; j < n2 ; j++ )
-	for ( int i = 0 ; i < n1 ; i++,k++ )
-	    if ( k >= n ) break;
-	    else {
-		for ( int y = 0 ; y < imagelist[k].height(); y++ )
-		    for ( int x = 0 ; x < imagelist[k].width(); x++ )
-		    {
-          img.setPixel( i*xsize + x, j*ysize + y,
-              imagelist[k].getPixel(x,y) );
-		    }
-	    }
-
-    img.write ("display.bmp");
-
-    getchar();
-
-    return 0;
+  // assumption: same size
+  // refactor-nice.pl: check this substitution
+  // old: int xsize = imagelist[0]->xsize;
+  int xsize = imagelist[0].width();
+  // refactor-nice.pl: check this substitution
+  // old: int ysize = imagelist[0]->ysize;
+  int ysize = imagelist[0].height();
+
+  int n = imagelist.size();
+  int n1 = ( int ) sqrt ( n );
+  int n2 = n / n1 + 1;
+
+  NICE::Image img ( n1*xsize, n2*ysize );
+  img.set ( 0 );
+  int k = 0;
+  for ( int j = 0 ; j < n2 ; j++ )
+    for ( int i = 0 ; i < n1 ; i++, k++ )
+      if ( k >= n ) break;
+      else {
+        for ( int y = 0 ; y < imagelist[k].height(); y++ )
+          for ( int x = 0 ; x < imagelist[k].width(); x++ )
+          {
+            img.setPixel ( i*xsize + x, j*ysize + y,
+                           imagelist[k].getPixel ( x, y ) );
+          }
+      }
+
+  img.write ( "display.bmp" );
+
+  getchar();
+
+  return 0;
 }
 }
 
 
 #endif
 #endif

+ 75 - 75
baselib/ICETools.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file ICETools.h
 * @file ICETools.h
 * @brief simple ICE GUI tools
 * @brief simple ICE GUI tools
 * @author Erik Rodner
 * @author Erik Rodner
@@ -13,7 +13,7 @@
 #include "core/vector/MatrixT.h"
 #include "core/vector/MatrixT.h"
 
 
 #include <vector>
 #include <vector>
- 
+
 
 
 namespace OBJREC {
 namespace OBJREC {
 
 
@@ -21,82 +21,82 @@ namespace OBJREC {
 class ICETools
 class ICETools
 {
 {
 
 
-    protected:
-
-    public:
-  
-	/** simple constructor */
-	ICETools();
-      
-	/** simple destructor */
-	virtual ~ICETools();
-
-	/** select a set of rectangles (selection of top-left and bottom-right
-	    @param panel image which is displayed
-	    @param overlay overlay image which will be used to mark points
-	    @param x returned list of rectangles (top-left-x,top-left-y,width,height)
-	    @param color color which is used to mark points
-	*/
-	static void selectRectangles ( const NICE::Image & panel, NICE::Image & overlay, 
-	    std::vector<NICE::Vector> & x, int color );
-
-	/** select a set of points 
-	    @param panel image which is displayed
-	    @param overlay overlay image which will be used to mark points
-	    @param x returned list of image points
-	    @param color color which is used to mark points
-	*/
-	static void selectPoints ( const NICE::Image & panel, NICE::Image & overlay, 
-	    std::vector<NICE::Vector> & x, int color );
-
-	/** convert a double image to a pseudocolor rgb image
-	    @param m input double image
-	    @param img resulting pseudocolor rgb image
-	*/
-	static void convertToRGB ( const NICE::FloatImage & m, NICE::ColorImage & img );
-
-	/** convert a matrix to a pseudocolor rgb image
-	    @param m input double image
-	    @param img resulting pseudocolor rgb image
-	*/
-	static void convertToRGB ( const NICE::Matrix & m, NICE::ColorImage & img );
-
-	/** convert a single double value to a pseudocolor
-	    @param x input double value
-	    @param r resulting red value
-	    @param g resulting green value
-	    @param b resulting blue value
-	*/
-	static void toColor ( double x, double & r, double & g, double & b );
-
-	/** calc grayscale image from a rgb image
-	    @param img color image
-	    @param imgg resulting grayscale image
-	*/
-	static void calcGrayImage ( const NICE::ColorImage & img, NICE::Image & imgg );
-
-	/** convert a c buffer to a matrix
-	    @param M resulting matrix
-	    @param raw input c buffer
-	*/
-	static void convertM2ICE ( NICE::Matrix & M, double *raw );
-
-	/** convert a matrix to a c buffer
-	    @param M input matrix
-	    @return resulting c buffer
-	*/
-	static double *convertICE2M ( const NICE::Matrix & M );
-
-	/** show a collection of images 
-	    @param imagelist collection of images
-	    @return ...
-	*/
-	static int showImages ( std::vector<NICE::Image> & imagelist );
+  protected:
+
+  public:
+
+    /** simple constructor */
+    ICETools();
+
+    /** simple destructor */
+    virtual ~ICETools();
+
+    /** select a set of rectangles (selection of top-left and bottom-right
+        @param panel image which is displayed
+        @param overlay overlay image which will be used to mark points
+        @param x returned list of rectangles (top-left-x,top-left-y,width,height)
+        @param color color which is used to mark points
+    */
+    static void selectRectangles ( const NICE::Image & panel, NICE::Image & overlay,
+                                   std::vector<NICE::Vector> & x, int color );
+
+    /** select a set of points
+        @param panel image which is displayed
+        @param overlay overlay image which will be used to mark points
+        @param x returned list of image points
+        @param color color which is used to mark points
+    */
+    static void selectPoints ( const NICE::Image & panel, NICE::Image & overlay,
+                               std::vector<NICE::Vector> & x, int color );
+
+    /** convert a double image to a pseudocolor rgb image
+        @param m input double image
+        @param img resulting pseudocolor rgb image
+    */
+    static void convertToRGB ( const NICE::FloatImage & m, NICE::ColorImage & img );
+
+    /** convert a matrix to a pseudocolor rgb image
+        @param m input double image
+        @param img resulting pseudocolor rgb image
+    */
+    static void convertToRGB ( const NICE::Matrix & m, NICE::ColorImage & img );
+
+    /** convert a single double value to a pseudocolor
+        @param x input double value
+        @param r resulting red value
+        @param g resulting green value
+        @param b resulting blue value
+    */
+    static void toColor ( double x, double & r, double & g, double & b );
+
+    /** calc grayscale image from a rgb image
+        @param img color image
+        @param imgg resulting grayscale image
+    */
+    static void calcGrayImage ( const NICE::ColorImage & img, NICE::Image & imgg );
+
+    /** convert a c buffer to a matrix
+        @param M resulting matrix
+        @param raw input c buffer
+    */
+    static void convertM2ICE ( NICE::Matrix & M, double *raw );
+
+    /** convert a matrix to a c buffer
+        @param M input matrix
+        @return resulting c buffer
+    */
+    static double *convertICE2M ( const NICE::Matrix & M );
+
+    /** show a collection of images
+        @param imagelist collection of images
+        @return ...
+    */
+    static int showImages ( std::vector<NICE::Image> & imagelist );
 
 
 #ifndef NOVISUAL
 #ifndef NOVISUAL
-	static int markImage (const NICE::Image & img, NICE::Image & mark, int marksize, int maxColor);
+    static int markImage ( const NICE::Image & img, NICE::Image & mark, int marksize, int maxColor );
 #endif
 #endif
-     
+
 };
 };
 
 
 
 

+ 24 - 24
cbaselib/ClassificationResult.cpp

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file ClassificationResult.cpp
 * @file ClassificationResult.cpp
 * @brief classification result, what else?
 * @brief classification result, what else?
 * @author Erik Rodner
 * @author Erik Rodner
@@ -20,33 +20,33 @@ using namespace NICE;
 
 
 
 
 
 
-ClassificationResult::ClassificationResult( int _rejection_status, int maxClassNo ) : scores(maxClassNo+1)
+ClassificationResult::ClassificationResult ( int _rejection_status, int maxClassNo ) : scores ( maxClassNo + 1 )
 {
 {
-    rejection_status = _rejection_status;
-    classno = -1;
-    classno_groundtruth = -1;
-    classname = "rejected";
-	uncertainty = 0.0;
+  rejection_status = _rejection_status;
+  classno = -1;
+  classno_groundtruth = -1;
+  classname = "rejected";
+  uncertainty = 0.0;
 }
 }
 
 
-ClassificationResult::ClassificationResult( int _classno, double _score, int maxClassNo ) : scores(maxClassNo+1)
+ClassificationResult::ClassificationResult ( int _classno, double _score, int maxClassNo ) : scores ( maxClassNo + 1 )
 {
 {
-    rejection_status = REJECTION_NONE;
-    classno = _classno;
-    scores[classno] = _score;
-    classname = "unknown";
-    classno_groundtruth = -1;
-	uncertainty = 0.0;
+  rejection_status = REJECTION_NONE;
+  classno = _classno;
+  scores[classno] = _score;
+  classname = "unknown";
+  classno_groundtruth = -1;
+  uncertainty = 0.0;
 }
 }
 
 
-ClassificationResult::ClassificationResult( int _classno, const FullVector & _scores )
+ClassificationResult::ClassificationResult ( int _classno, const FullVector & _scores )
 {
 {
-    rejection_status = REJECTION_NONE;
-    classno = _classno;
-    scores = _scores;
-    classname = "unknown";
-    classno_groundtruth = -1;
-	uncertainty = 0.0;
+  rejection_status = REJECTION_NONE;
+  classno = _classno;
+  scores = _scores;
+  classname = "unknown";
+  classno_groundtruth = -1;
+  uncertainty = 0.0;
 }
 }
 
 
 ClassificationResult::~ClassificationResult()
 ClassificationResult::~ClassificationResult()
@@ -55,10 +55,10 @@ ClassificationResult::~ClassificationResult()
 
 
 double ClassificationResult::confidence () const
 double ClassificationResult::confidence () const
 {
 {
-    return scores.get(classno);
+  return scores.get ( classno );
 }
 }
-	
+
 bool ClassificationResult::ok () const
 bool ClassificationResult::ok () const
 {
 {
-    return ( rejection_status == REJECTION_NONE );
+  return ( rejection_status == REJECTION_NONE );
 }
 }

+ 59 - 62
cbaselib/ClassificationResult.h

@@ -1,6 +1,6 @@
-/** 
+/**
 * @file ClassificationResult.h
 * @file ClassificationResult.h
-* @brief classification result data (probabilities, most probable class, rejection status, ...) 
+* @brief classification result data (probabilities, most probable class, rejection status, ...)
 * @author Erik Rodner
 * @author Erik Rodner
 * @date 02/13/2008
 * @date 02/13/2008
 
 
@@ -16,7 +16,7 @@
 #include <map>
 #include <map>
 #include "core/vector/SparseVectorT.h"
 #include "core/vector/SparseVectorT.h"
 #include "vislearning/math/mathbase/FullVector.h"
 #include "vislearning/math/mathbase/FullVector.h"
-  
+
 
 
 namespace OBJREC {
 namespace OBJREC {
 
 
@@ -24,66 +24,63 @@ namespace OBJREC {
 class ClassificationResult
 class ClassificationResult
 {
 {
 
 
-    public:
-
-	/** rejection types */
-	enum {
-	    REJECTION_FEATURE = 0,
-	    REJECTION_CLASSIFIER,
-	    REJECTION_MISC,
-	    REJECTION_NONE,
-	    REJECTION_UNINTIALIZED
-	};
-
-	/** rejection status (selected from enum) */
-	int rejection_status;
-
-	/** std::vector consisting of scores for each class 
-	    @remark no guaranteed probabilities
-	    low scores means low probability for this class
-	*/
-	FullVector scores;
-
-	/** most important part: class number of classification result,
-	    most probable class */
-	int classno;
-
-	/** evil workaround: ground truth class number (useful within ClassificationResults)
-	    @see testClassification.cpp
-	    @see ClassificationResults
-	*/
-	int classno_groundtruth;
-
-	/** text representation of the most probable class 
-	    @remark has to be set manually !! */
-	std::string classname;
- 
- 	/** uncertainty of the estimate, only available for GP classifiers */
-	double uncertainty;
- 
-	/** simple constructor, create rejected result */
-	ClassificationResult( int rejection_status = REJECTION_UNINTIALIZED, int maxClassNo = 0 );
-      
-	/** result of classification only consists of the most probable
-	    class @p classno and a score of this assigment */
-	ClassificationResult( int classno, double score, int maxClassNo );
-	
-	/** result of classification consists of most probable class @p classno
-	    and a score for each of the other classes */
-	ClassificationResult( int classno, const FullVector & scores );
-
-	/** simple destructor */
-	virtual ~ClassificationResult();
-
-	/** was it rejected ? */
-	bool ok () const;
-
-	/** probability of predicted class */
-	double confidence () const;
-
-     
-};
+  public:
+
+    /** rejection types */
+    enum {
+      REJECTION_FEATURE = 0,
+      REJECTION_CLASSIFIER,
+      REJECTION_MISC,
+      REJECTION_NONE,
+      REJECTION_UNINTIALIZED
+    };
+
+    /** rejection status (selected from enum) */
+    int rejection_status;
+
+    /** std::vector consisting of scores for each class
+        @remark no guaranteed probabilities
+        low scores means low probability for this class
+    */
+    FullVector scores;
+
+    /** most important part: class number of classification result,
+        most probable class */
+    int classno;
+
+    /** evil workaround: ground truth class number (useful within ClassificationResults)
+        @see testClassification.cpp
+        @see ClassificationResults
+    */
+    int classno_groundtruth;
+
+    /** text representation of the most probable class
+        @remark has to be set manually !! */
+    std::string classname;
 
 
+    /** uncertainty of the estimate, only available for GP classifiers */
+    double uncertainty;
+
+    /** simple constructor, create rejected result */
+    ClassificationResult ( int rejection_status = REJECTION_UNINTIALIZED, int maxClassNo = 0 );
+
+    /** result of classification only consists of the most probable
+        class @p classno and a score of this assigment */
+    ClassificationResult ( int classno, double score, int maxClassNo );
+
+    /** result of classification consists of most probable class @p classno
+        and a score for each of the other classes */
+    ClassificationResult ( int classno, const FullVector & scores );
+
+    /** simple destructor */
+    virtual ~ClassificationResult();
+
+    /** was it rejected ? */
+    bool ok () const;
+
+    /** probability of predicted class */
+    double confidence () const;
+};
 
 
 } // namespace
 } // namespace
 
 

+ 49 - 47
features/localfeatures/LFonHSG.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file LFonHSG.h
 * @file LFonHSG.h
 * @brief This class can be used to calculate the positions of keyfeatures in a Honeyrate Structure Grid (HSG). Also the class call the normal getDescriptors methode from a given type of SIFT.
 * @brief This class can be used to calculate the positions of keyfeatures in a Honeyrate Structure Grid (HSG). Also the class call the normal getDescriptors methode from a given type of SIFT.
 * @author Eric Bach
 * @author Eric Bach
@@ -29,64 +29,66 @@
 /** STRINGTOOLS **/
 /** STRINGTOOLS **/
 /** 1) boost **/
 /** 1) boost **/
 #ifdef NICE_USELIB_BOOST
 #ifdef NICE_USELIB_BOOST
-  #include <boost/tokenizer.hpp>
+#include <boost/tokenizer.hpp>
 /** 2) NICE (standard) **/
 /** 2) NICE (standard) **/
 #else
 #else
-  #include <core/basics/StringTools.h>
+#include <core/basics/StringTools.h>
 #endif
 #endif
 
 
 namespace OBJREC
 namespace OBJREC
 {
 {
-	class LFonHSG : public LocalFeatureRepresentation
-	{		
-		/* private member */
-		private:
-			/* parameter for the grid */
-			//! stepwidhts of the grid
-			int sampleScaling;
-			//! which scales should be used
-			std::string scales;
-			//! vector which save the different scales
-			std::vector <float> scalesV;	
+class LFonHSG : public LocalFeatureRepresentation
+{
+    /* private member */
+  private:
+    /* parameter for the grid */
+    //! stepwidhts of the grid
+    int sampleScaling;
+    //! which scales should be used
+    std::string scales;
+    //! vector which save the different scales
+    std::vector <float> scalesV;
+
+    /** Calculate the keypoint-positions by given imagesize, sample-spacing and scales.
+        @brief The methode returns the calculated positions on a honeyrate-grid. This
+        positions starts with (0;0).
+        @param[in] unsigned int imageWidth  - width (x) of the given image
+        @param[in] unsigned int imageHeight - heigth (y) of the given image
+        @param[in,out] NICE::VVector positions    - destination for the calculated positions
+    **/
+    void getPositionsOnHSG ( const unsigned int imageWidth,
+                             const unsigned int imageHeight,
+                             NICE::VVector& positions ) const;
+
+    //! simple methode to convert a string into float
+    float strToFloat ( const std::string str ) const;
 
 
-			/** Calculate the keypoint-positions by given imagesize, sample-spacing and scales.
-			    @brief The methode returns the calculated positions on a honeyrate-grid. This 
-				   positions starts with (0;0).
-			    @param[in] unsigned int imageWidth  - width (x) of the given image
-			    @param[in] unsigned int imageHeight - heigth (y) of the given image
-			    @param[in,out] NICE::VVector positions    - destination for the calculated positions
-			**/
-			void getPositionsOnHSG ( const unsigned int imageWidth,
-						 const unsigned int imageHeight,
-						 NICE::VVector& positions ) const;    
+    //! if true, print some log-output
+    bool debug;
 
 
-			//! simple methode to convert a string into float
-			float strToFloat( const std::string str ) const;
+    //! the descritor instanz
+    LocalFeature* lf;
 
 
-			//! if true, print some log-output
-			bool debug;
-			
-			//! the descritor instanz
-			LocalFeature* lf; 
+    /* public member */
+  public:
+    //! simple contructor
+    LFonHSG ( const NICE::Config *conf, const std::string section = "HSG" );
+    //! simple desctructor
+    ~LFonHSG();
 
 
-		/* public member */
-		public:
-			//! simple contructor
-			LFonHSG( const NICE::Config *conf, const std::string section = "HSG");
-			//! simple desctructor
-			~LFonHSG();
+    //! Returns the descriptorsize
+    int getDescSize() const {
+      return lf->getDescSize();
+    };
 
 
-			//! Returns the descriptorsize
-			int getDescSize() const { return lf->getDescSize(); };
+    //! Extract the descriptor-Values from a given grayscale-Image.
+    int extractFeatures ( const NICE::Image & img, NICE::VVector & features, NICE::VVector & positions ) const;
 
 
-			//! Extract the descriptor-Values from a given grayscale-Image.
-			int extractFeatures ( const NICE::Image & img, NICE::VVector & features, NICE::VVector & positions ) const;
+    //! Extract the descriptor-Values from a given color-Image.
+    int extractFeatures ( const NICE::ColorImage & cimg, NICE::VVector & features, NICE::VVector & positions ) const;
 
 
-			//! Extract the descriptor-Values from a given color-Image.
-      int extractFeatures ( const NICE::ColorImage & cimg, NICE::VVector & features, NICE::VVector & positions ) const;
-			
-			//! Visualisierung
-			void visualizeFeatures ( NICE::Image & mark, const NICE::VVector & positions, size_t color ) const;
-	};
+    //! Visualisierung
+    void visualizeFeatures ( NICE::Image & mark, const NICE::VVector & positions, size_t color ) const;
+};
 }
 }
 #endif
 #endif

+ 10 - 5
math/ftransform/PCA.cpp

@@ -9,7 +9,7 @@
  * This is an example of how to use the Principal Component Analysis (PCA) class.
  * This is an example of how to use the Principal Component Analysis (PCA) class.
  */
  */
 
 
-// #define DEBUG
+//#define DEBUG
 #undef DEBUG
 #undef DEBUG
 
 
 #include <iostream>
 #include <iostream>
@@ -83,6 +83,7 @@ void PCA::calculateMean ( const NICE::Matrix &features, NICE::Vector & mean )
   mean.set(0);
   mean.set(0);
   for ( uint i = 0 ; i < features.rows(); i++ )
   for ( uint i = 0 ; i < features.rows(); i++ )
     mean = mean + features.getRow ( i );
     mean = mean + features.getRow ( i );
+  mean /= features.rows();
 }
 }
 
 
 void PCA::calculateBasis ( const NICE::Matrix &features,
 void PCA::calculateBasis ( const NICE::Matrix &features,
@@ -99,18 +100,21 @@ void PCA::calculateBasis ( const NICE::Matrix &features,
   NICE::Vector eigenvalue;
   NICE::Vector eigenvalue;
 
 
   calculateMean ( features, mean );
   calculateMean ( features, mean );
-
+  
 #ifdef NICE_USELIB_TRLAN
 #ifdef NICE_USELIB_TRLAN
   EigValues *eig;
   EigValues *eig;
-  if(mindimension < 4)
+  if(mindimension < 12)
     eig = new EVArnoldi();//Arnoldi for (srcFeatureSize<n)
     eig = new EVArnoldi();//Arnoldi for (srcFeatureSize<n)
   else
   else
     eig = new EigValuesTRLAN();//fast lanczos TRLAN
     eig = new EigValuesTRLAN();//fast lanczos TRLAN
 #else
 #else
   EigValues *eig = new EVArnoldi();//Arnoldi for (srcFeatureSize<n)
   EigValues *eig = new EVArnoldi();//Arnoldi for (srcFeatureSize<n)
 #endif
 #endif
+
   NICE::Matrix features_transpose = features.transpose();
   NICE::Matrix features_transpose = features.transpose();
+
   GMCovariance C ( &features_transpose );
   GMCovariance C ( &features_transpose );
+  
   if ( adaptive )
   if ( adaptive )
   {
   {
     eig->getEigenvalues ( C, eigenvalue, eigenvectors, srcFeatureSize );
     eig->getEigenvalues ( C, eigenvalue, eigenvectors, srcFeatureSize );
@@ -146,7 +150,6 @@ void PCA::calculateBasis ( const NICE::Matrix &features,
 
 
   //compute basis size
   //compute basis size
 
 
-
   if ( adaptive )
   if ( adaptive )
   { //compute target dimension
   { //compute target dimension
     uint dimensioncount = 0;
     uint dimensioncount = 0;
@@ -183,6 +186,7 @@ void PCA::calculateBasis ( const NICE::Matrix &features,
     count++;
     count++;
     it++;
     it++;
   }
   }
+  
   //normalization matrix / modify variance to 1 for all eigenvectors
   //normalization matrix / modify variance to 1 for all eigenvectors
   normalization = NICE::Matrix ( mindimension, mindimension, 0 );
   normalization = NICE::Matrix ( mindimension, mindimension, 0 );
   for ( uint k = 0; k < mindimension; k++ )
   for ( uint k = 0; k < mindimension; k++ )
@@ -203,12 +207,13 @@ NICE::Vector PCA::getFeatureVector ( const NICE::Vector &data,
   //free data of mean
   //free data of mean
   if ( normalize )
   if ( normalize )
   {
   {
-
     NICE::Vector meanfree ( data );
     NICE::Vector meanfree ( data );
     meanfree -= mean;
     meanfree -= mean;
     //Y=W^t * B^T
     //Y=W^t * B^T
+    
     if ( normbasis.rows() == 0 )
     if ( normbasis.rows() == 0 )
       normbasis.multiply ( normalization, basis, false, true );
       normbasis.multiply ( normalization, basis, false, true );
+    
     NICE::Vector tmp;
     NICE::Vector tmp;
     tmp.multiply ( normbasis, meanfree );
     tmp.multiply ( normbasis, meanfree );
     return tmp;
     return tmp;

+ 0 - 88
math/ftransform/progs/Makefile.inc

@@ -1,88 +0,0 @@
-# BINARY-DIRECTORY-MAKEFILE
-# conventions:
-# - there are no subdirectories, they are ignored!
-# - all ".C", ".cpp" and ".c" files in the current directory are considered
-#   independent binaries, and linked as such.
-# - the binaries depend on the library of the parent directory
-# - the binary names are created with $(BINNAME), i.e. it will be more or less
-#   the name of the .o file
-# - all binaries will be added to the default build list ALL_BINARIES
-
-# --------------------------------
-# - remember the last subdirectory
-#
-# set the variable $(SUBDIR) correctly to the current subdirectory. this
-# variable can be used throughout the current makefile.inc. The many 
-# SUBDIR_before, _add, and everything are only required so that we can recover
-# the previous content of SUBDIR before exitting the makefile.inc
-
-SUBDIR_add:=$(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
-SUBDIR_before:=$(SUBDIR)
-SUBDIR:=$(strip $(SUBDIR_add))
-SUBDIR_before_$(SUBDIR):=$(SUBDIR_before)
-
-# ------------------------
-# - include subdirectories
-#
-# note the variables $(SUBDIRS_OF_$(SUBDIR)) are required later on to recover
-# the dependencies automatically. if you handle dependencies on your own, you
-# can also dump the $(SUBDIRS_OF_$(SUBDIR)) variable, and include the
-# makefile.inc of the subdirectories on your own...
-
-#SUBDIRS_OF_$(SUBDIR):=$(patsubst %/Makefile.inc,%,$(wildcard $(SUBDIR)*/Makefile.inc))
-#include $(SUBDIRS_OF_$(SUBDIR):%=%/Makefile.inc)
-
-# ----------------------------
-# - include local dependencies
-#
-# include the libdepend.inc file, which gives additional dependencies for the
-# libraries and binaries. additionally, an automatic dependency from the library
-# of the parent directory is added (commented out in the code below).
-
--include $(SUBDIR)libdepend.inc
-
-PARENTDIR:=$(patsubst %/,%,$(dir $(patsubst %/,%,$(SUBDIR))))
-$(eval $(call PKG_DEPEND_INT,$(PARENTDIR)))
-
-# ---------------------------
-# - objects in this directory
-#
-# the use of the variable $(OBJS) is not mandatory. it is mandatory however
-# to update $(ALL_OBJS) in a way that it contains the path and name of
-# all objects. otherwise we can not include the appropriate .d files.
-
-OBJS:=$(patsubst %.cpp,$(OBJDIR)%.o,$(notdir $(wildcard $(SUBDIR)*.cpp))) \
-      $(patsubst %.C,$(OBJDIR)%.o,$(notdir $(wildcard $(SUBDIR)*.C))) \
-      $(shell grep -ls Q_OBJECT $(SUBDIR)*.h | sed -e's@^@/@;s@.*/@$(OBJDIR)moc_@;s@\.h$$@.o@') \
-      $(patsubst %.c,$(OBJDIR)%.o,$(notdir $(wildcard $(SUBDIR)*.c)))
-ALL_OBJS += $(OBJS)
-
-# ----------------------------
-# - binaries in this directory
-#
-# output of binaries in this directory. none of the variables has to be used.
-# but everything you add to $(ALL_LIBRARIES) and $(ALL_BINARIES) will be
-# compiled with `make all`. be sure again to add the files with full path.
-
-BINARIES:=$(patsubst %.o,$(BINDIR)%,$(filter-out moc_%,$(notdir $(OBJS))))
-ALL_BINARIES+=$(BINARIES)
-
-# ---------------------
-# - binary dependencies
-#
-# there is no way of determining the binary dependencies automatically, so we
-# follow conventions. each binary depends on the corresponding .o file and
-# on the libraries specified by the INTLIBS/EXTLIBS. these dependencies can be
-# specified manually or they are automatically stored in a .bd file.
-
-$(foreach head,$(wildcard $(SUBDIR)*.h),$(eval $(shell grep -q Q_OBJECT $(head) && echo $(head) | sed -e's@^@/@;s@.*/\(.*\)\.h$$@$(BINDIR)\1:$(OBJDIR)moc_\1.o@')))
--include $(OBJS:%.o=%.bd)
-
-# -------------------
-# - subdir management
-#
-# as the last step, always add this line to correctly recover the subdirectory
-# of the makefile including this one!
-
-SUBDIR:=$(SUBDIR_before_$(SUBDIR))
-

+ 59 - 75
math/ftransform/tests/TestFTransform.cpp

@@ -29,7 +29,7 @@ using namespace std;
 using namespace NICE;
 using namespace NICE;
 using namespace OBJREC;
 using namespace OBJREC;
 
 
-CPPUNIT_TEST_SUITE_REGISTRATION(TestFTransform);
+CPPUNIT_TEST_SUITE_REGISTRATION ( TestFTransform );
 
 
 void TestFTransform::setUp()
 void TestFTransform::setUp()
 {
 {
@@ -41,81 +41,65 @@ void TestFTransform::tearDown()
 
 
 void TestFTransform::TestFTransformComputation()
 void TestFTransform::TestFTransformComputation()
 {
 {
-    uint samplecount = 16; //samples
-    uint sampledimension = 8; //sample dimension
-    bool init_random = true;
-
-    NICE::Matrix T(samplecount, sampledimension);
-
-    //trivial test
-    CPPUNIT_ASSERT_EQUAL(samplecount, (uint)T.rows());
-    CPPUNIT_ASSERT_EQUAL(sampledimension, (uint)T.cols());
-
-
-    T.set(0.0);
-    if (init_random)
-        srand48(time(NULL));
-
-    // generate random matrix
-    for (uint i = 0 ; i < T.rows() ; i++)
-        for (uint j = 0 ; j < T.cols() ; j++)
-        {
-            T(i, j) = drand48();
-        }
-//cout<<T<<endl;
-    PCA *ftransform = new PCA(sampledimension);
-#ifdef NICE_USELIB_ICE
-#ifdef NICE_USELIB_TRLAN
-	for (int mode = 0;mode <= 1;mode++)
+  uint samplecount = 13; //samples
+  uint sampledimension = 4; //sample dimension
+
+  NICE::Matrix T ( samplecount, sampledimension );
+  NICE::Matrix goalBasis ( sampledimension, sampledimension );
+  NICE::Matrix goalFeats ( samplecount, sampledimension );
+
+  //trivial test
+  CPPUNIT_ASSERT_EQUAL ( samplecount, ( uint ) T.rows() );
+  CPPUNIT_ASSERT_EQUAL ( sampledimension, ( uint ) T.cols() );
+
+  ifstream is ( "./pca.data" );
+  for ( uint i = 0 ; i < T.rows() ; i++ )
+    for ( uint j = 0 ; j < T.cols() ; j++ )
+      is >> T ( i, j );
+
+  for ( uint i = 0 ; i < goalBasis.rows() ; i++ )
+    for ( uint j = 0 ; j < goalBasis.cols() ; j++ )
+      is >> goalBasis ( i, j );
+
+  for ( uint i = 0 ; i < goalFeats.rows() ; i++ )
+    for ( uint j = 0 ; j < goalFeats.cols() ; j++ )
+      is >> goalFeats ( i, j );
+  is.close();
+
+
+  PCA *ftransform = new PCA ( sampledimension );
+
+  bool mode = false;
+  ftransform->calculateBasis ( T, sampledimension, mode ); //fastes available method
+  NICE::Matrix basis, featurematrix;
+  featurematrix = T;
+  //cout << featurematrix << endl;
+  basis = ftransform->getBasis();
+  //cout<<basis<<endl;
+  //orthogonality test
+
+  for ( uint i = 0 ; i < goalBasis.rows() ; i++ )
+    for ( uint j = 0 ; j < goalBasis.cols() ; j++ )
+    {
+      CPPUNIT_ASSERT_DOUBLES_EQUAL_NOT_NAN ( abs ( goalBasis ( i, j ) ), abs ( basis ( i, j ) ), 1e-4 );
+    }
+  //transform features and test
+
+  for ( uint k = 0;k < T.rows();k++ )
+  {
+    NICE::Vector feature, feature_transformed;
+    feature = T.getRow ( k );
+    feature_transformed = ftransform-> getFeatureVector ( feature, false );
+    for ( uint d = 0;d < feature_transformed.size();d++ )
     {
     {
-        ftransform->calculateBasis(T, sampledimension, mode); //fastes available method
-        NICE::Matrix basis, featurematrix;
-        featurematrix = T;
-        basis = ftransform->getBasis();
-        //cout<<basis<<endl;
-        //orthogonality test
-        for (int k = 0;k < basis.rows() - 1;k++)
-        {
-            NICE::Vector b1, b2;
-            b1 = basis.getRow(k);
-            b2 = basis.getRow(k + 1);
-            double sp = b1.scalarProduct(b2);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL_NOT_NAN(0.0, sp, 1e-4);
-        }
-        //transform features and test
-
-        for (int k = 0;k < T.rows();k++)
-        {
-            NICE::Vector feature, feature_transformed;
-            feature = T.getRow(k);
-            feature_transformed = ftransform-> getFeatureVector(feature, true);
-            for (uint d = 0;d < feature_transformed.size();d++)
-            {
-                featurematrix(k, d) = feature_transformed[d];
-            }
-        }
-
-        //cout<<featurematrix<<endl;
-        //Covariance Test
-        NICE::Matrix covariance;
-        covariance = featurematrix.transpose() * featurematrix;
-        ////cout<<covariance<<endl;
-        for (uint i = 0;i < covariance.rows();i++)
-        {
-            for (uint j = 0;j < covariance.cols();j++)
-            {
-                if (i == j)
-                {
-                    CPPUNIT_ASSERT_DOUBLES_EQUAL_NOT_NAN((double)samplecount, covariance(i, j), 1e-4);
-                }
-                else
-                {
-                    CPPUNIT_ASSERT_DOUBLES_EQUAL_NOT_NAN(0.0, covariance(i, j), 1e-4);
-                }
-            }
-        }
+      featurematrix ( k, d ) = feature_transformed[d];
     }
     }
-#endif
-#endif
+  }
 
 
+  for ( uint i = 0 ; i < goalFeats.rows() ; i++ )
+    for ( uint j = 0 ; j < goalFeats.cols() ; j++ )
+    {
+      CPPUNIT_ASSERT_DOUBLES_EQUAL_NOT_NAN ( abs ( goalFeats ( i, j ) ), abs ( featurematrix ( i, j ) ), 1e-2 );
+    }
 }
 }
+

+ 15 - 14
math/ftransform/tests/TestFTransform.h

@@ -1,20 +1,20 @@
 //
 //
 // C++ Interface: TestFTransform
 // C++ Interface: TestFTransform
 //
 //
-// Description: 
+// Description:
 //
 //
 //
 //
 // Author: Michael Koch <Koch.Michael@uni-jena.de>, (C) 2009
 // Author: Michael Koch <Koch.Michael@uni-jena.de>, (C) 2009
 //
 //
 // Copyright: See COPYING file that comes with this distribution
 // Copyright: See COPYING file that comes with this distribution
 //
 //
-/** 
+/**
  * @file TestFTransform.h
  * @file TestFTransform.h
  * @brief TestFTransform
  * @brief TestFTransform
  * @author Michael Koch
  * @author Michael Koch
  * @date Di Aug 4 2009
  * @date Di Aug 4 2009
  */
  */
- 
+
 
 
 #ifndef OBJREC_TestFTransform_H
 #ifndef OBJREC_TestFTransform_H
 #define OBJREC_TestFTransform_H
 #define OBJREC_TestFTransform_H
@@ -23,26 +23,27 @@
 #include <cppunit/extensions/HelperMacros.h>
 #include <cppunit/extensions/HelperMacros.h>
 
 
 /**
 /**
- * CppUnit-Testcase. 
+ * CppUnit-Testcase.
  * Tests for EigenValue Operations
  * Tests for EigenValue Operations
  */
  */
 class TestFTransform : public CppUnit::TestFixture
 class TestFTransform : public CppUnit::TestFixture
 {
 {
-     CPPUNIT_TEST_SUITE( TestFTransform );
+    CPPUNIT_TEST_SUITE ( TestFTransform );
+
 
 
-    
-     CPPUNIT_TEST( TestFTransformComputation );
+    CPPUNIT_TEST ( TestFTransformComputation );
 
 
-     CPPUNIT_TEST_SUITE_END();
+    CPPUNIT_TEST_SUITE_END();
 
 
-     private:
+  private:
+
+  public:
+    void setUp();
+    void tearDown();
+    void TestFTransformComputation();
 
 
-     public:
-          void setUp();
-          void tearDown();
-          void TestFTransformComputation();
-       
 };
 };
 
 
 #endif // _TestFTransform_H_
 #endif // _TestFTransform_H_
 
 
+

+ 30 - 0
math/ftransform/tests/pca.data

@@ -0,0 +1,30 @@
+7	26	6	60
+1	29	15	52
+11	56	8	20
+11	31	8	47
+7	52	6	33
+11	55	9	22
+3	71	17	6
+1	31	22	44
+2	54	18	22
+21	47	4	26
+1	40	23	34
+11	66	9	12
+10	68	8	12
+-0.067799985695474	-0.646018286568727	0.567314540990512	0.506179559977705
+-0.678516235418647	-0.019993340484099	-0.543969276583817	0.493268092159297
+0.029020832106229	0.755309622491132	0.403553469172668	0.515567418476836
+0.730873909451461	-0.108480477171676	-0.468397518388289	0.484416225289198
+36.821825999449722	-6.870878154227368	-4.590944457629744	0.396652582713913
+29.607273420710978	4.610881963526304	-2.247578163663947	-0.395843536696488
+-12.981775719737621	-4.204913183175940	0.902243082694698	-1.126100587210614
+23.714725720918029	-6.634052554708719	1.854742000806314	-0.378564808384691
+-0.553191676624596	-4.461732123178687	-6.087412652325180	0.142384896047281
+-10.812490833309822	-3.646571174544059	0.912970791674604	-0.134968810314679
+-32.588166608817936	8.979846284936064	-1.606265913996589	0.081763927599949
+22.606395499005593	10.725906457369447	3.236537714483417	0.324334774646368
+-9.262587237675843	8.985373347478786	-0.016909578102172	-0.543746175981799
+-3.283969329640674	-14.157277337500913	7.046512994833764	0.340509860960608
+9.220031117829379	12.386080787220450	3.428342878284625	0.435152769664895
+-25.584908517429557	-2.781693148152387	-0.386716066864491	0.446817950545607
+-26.903161834677618	-2.930971165042989	-2.445522630195304	0.411607156409659