Pārlūkot izejas kodu

added support for relative image path names in ImageInfo class

Johannes Ruehle 13 gadi atpakaļ
vecāks
revīzija
4bccbf3473
58 mainītis faili ar 3185 papildinājumiem un 2502 dzēšanām
  1. 1 1
      baselib/ColorSpace.cpp
  2. 96 98
      baselib/ColorSpace.tcc
  3. 9 0
      baselib/FastFilter.h
  4. 47 0
      baselib/FastFilter.tcc
  5. 29 52
      cbaselib/CachedExample.cpp
  6. 3 3
      cbaselib/CachedExample.h
  7. 20 19
      cbaselib/Feature.h
  8. 16 5
      cbaselib/ImageInfo.cpp
  9. 202 202
      cbaselib/LabeledFileList.cpp
  10. 331 0
      cbaselib/LabeledFileList.cpp~
  11. 9 8
      cbaselib/LabeledFileList.h
  12. 107 0
      cbaselib/LabeledFileList.h~
  13. 267 265
      cbaselib/MultiDataset.cpp
  14. 16 16
      cbaselib/MultiDataset.h
  15. 49 47
      cbaselib/progs/testCachedExample.cpp
  16. 51 57
      cbaselib/progs/testLabeledSet.cpp
  17. 2 0
      classifier/classifiercombination/VCPreRandomForest.cpp
  18. 0 2
      classifier/classifiercombination/VCPreRandomForest.h
  19. 2 0
      classifier/classifierinterfaces/VCFeaturePool.cpp
  20. 0 2
      classifier/classifierinterfaces/VCFeaturePool.h
  21. 4 2
      classifier/fpclassifier/logisticregression/FPCSMLR.cpp
  22. 0 2
      classifier/fpclassifier/logisticregression/FPCSMLR.h
  23. 3 0
      classifier/fpclassifier/logisticregression/SLR.cpp
  24. 0 2
      classifier/fpclassifier/logisticregression/SLR.h
  25. 3 0
      classifier/fpclassifier/randomforest/DecisionNode.cpp
  26. 1 2
      classifier/fpclassifier/randomforest/DecisionNode.h
  27. 3 0
      classifier/fpclassifier/randomforest/FPCRandomForests.cpp
  28. 0 2
      classifier/fpclassifier/randomforest/FPCRandomForests.h
  29. 8 6
      classifier/genericClassifierSelection.h
  30. 3 3
      classifier/vclassifier/VCDTSVM.cpp
  31. 0 2
      classifier/vclassifier/VCDTSVM.h
  32. 110 0
      classifier/vclassifier/VCNearestClassMean.cpp
  33. 55 0
      classifier/vclassifier/VCNearestClassMean.h
  34. 3 0
      classifier/vclassifier/VCOneVsAll.cpp
  35. 0 2
      classifier/vclassifier/VCOneVsAll.h
  36. 98 102
      features/fpfeatures/ColorHistogramFeature.cpp
  37. 34 37
      features/fpfeatures/ColorHistogramFeature.h
  38. 162 174
      features/fpfeatures/EOHFeature.cpp
  39. 49 46
      features/fpfeatures/EOHFeature.h
  40. 57 51
      features/fpfeatures/FIGradients.cpp
  41. 8 8
      features/fpfeatures/FIGradients.h
  42. 80 80
      features/fpfeatures/FIHistograms.cpp
  43. 191 187
      features/fpfeatures/HOGFeature.cpp
  44. 8 4
      features/fpfeatures/HaarFeature.cpp
  45. 163 168
      features/fpfeatures/HistFeature.cpp
  46. 53 58
      features/fpfeatures/HistFeature.h
  47. 180 173
      features/fpfeatures/PixelPairFeature.cpp
  48. 53 53
      features/fpfeatures/PixelPairFeature.h
  49. 121 117
      features/fpfeatures/SemanticFeature.cpp
  50. 47 47
      features/fpfeatures/SemanticFeature.h
  51. 221 221
      features/localfeatures/LFColorSande.cpp
  52. 49 49
      features/localfeatures/LFColorSande.h
  53. 16 1
      features/localfeatures/LFColorWeijer.cpp
  54. 19 19
      features/localfeatures/progs/testColorWeijer.cpp
  55. 2 5
      image/GenericImageTools.h
  56. 66 48
      image/GenericImageTools.tcc
  57. 54 54
      math/pdf/tests/TestPDF.cpp
  58. 4 0
      progs/libdepend.inc

+ 1 - 1
baselib/ColorSpace.cpp

@@ -22,7 +22,7 @@ using namespace NICE;
 //bad position for this function
 void ColorSpace::ColorImagetoMultiChannelImage(  const NICE::ColorImage &imgrgb, NICE::MultiChannelImageT<double> &genimg )
 {
-  genimg.reInit( imgrgb.width(), imgrgb.height(), 3, true );
+  genimg.reInit( imgrgb.width(), imgrgb.height(), 3);
   for ( int y = 0;y < imgrgb.height();y++ )
   {
     for ( int x = 0;x < imgrgb.width();x++ )

+ 96 - 98
baselib/ColorSpace.tcc

@@ -4,111 +4,109 @@
 
 namespace OBJREC {
 
-template<class SrcPixelType,class DstPixelType>
+template<class SrcPixelType, class DstPixelType>
 void ColorSpace::convert ( NICE::MultiChannelImageT<DstPixelType> & dst, const NICE::MultiChannelImageT<SrcPixelType> & src,
-	      int dstColorSpace, int srcColorSpace, double dstM, double srcM )
+                           int dstColorSpace, int srcColorSpace, double dstM, double srcM )
 {
-    assert ( (srcColorSpace >= 0) && (srcColorSpace < NUM_COLORSPACES) );
-    assert ( (dstColorSpace >= 0) && (dstColorSpace < NUM_COLORSPACES) );
+  assert ( ( srcColorSpace >= 0 ) && ( srcColorSpace < NUM_COLORSPACES ) );
+  assert ( ( dstColorSpace >= 0 ) && ( dstColorSpace < NUM_COLORSPACES ) );
 
-    dst.reInitFrom ( src, true );
+  dst.reInitFrom ( src );
 
-    if ( (srcColorSpace == COLORSPACE_RGB) && (dstColorSpace == COLORSPACE_HSL) )
-    {
-	 assert ( dst.numChannels == 3 );
-	 assert ( src.numChannels == 3 );
+  if ( ( srcColorSpace == COLORSPACE_RGB ) && ( dstColorSpace == COLORSPACE_HSL ) )
+  {
+    assert ( dst.channels() == 3 );
+    assert ( src.channels() == 3 );
 
-	 long k = 0;
-	 for ( int y = 0 ; y < src.ysize ; y++ )
-	     for ( int x = 0 ; x < src.xsize ; x++,k++ )
-	     {
-	       double R,G,B,H,S,L;
-	       R=(double)src.data[0][k]/srcM;
-	       G=(double)src.data[1][k]/srcM;
-	       B=(double)src.data[2][k]/srcM;
-	       ColorConversion::ccRGBtoHSL(R,G,B,&H,&S,&L);
-	       dst.data[0][k] = (DstPixelType)(H*dstM);
-	       dst.data[1][k] = (DstPixelType)(S*dstM);
-	       dst.data[2][k] = (DstPixelType)(L*dstM);
-	    }
-    } 
-    else if ( (srcColorSpace == COLORSPACE_RGB) && (dstColorSpace == COLORSPACE_LAB) )
-     {
-          long k = 0;
-          for ( int y = 0 ; y < src.ysize ; y++ )
-               for ( int x = 0 ; x < src.xsize ; x++,k++ )
-          {
-               double R,G,B,X,Y,Z,L,a,b;
-               R=(double)src.data[0][k]/255.0;
-			   G=(double)src.data[1][k]/255.0;
-			   B=(double)src.data[2][k]/255.0;
-               ColorConversion::ccRGBtoXYZ(R,G,B,&X,&Y,&Z,0);
-               ColorConversion::ccXYZtoCIE_Lab(X,Y,Z,&L,&a,&b,0);
-               dst.data[0][k] = (DstPixelType)(L);
-               dst.data[1][k] = (DstPixelType)(a);
-               dst.data[2][k] = (DstPixelType)(b);
-          }
-     }
-	 else if ( (srcColorSpace == COLORSPACE_LAB) && (dstColorSpace == COLORSPACE_RGB) )
-	 {
-		 long k = 0;
-		 for ( int y = 0 ; y < src.ysize ; y++ )
-			 for ( int x = 0 ; x < src.xsize ; x++,k++ )
-		 {
-			 double R,G,B,X,Y,Z,L,a,b;
-			 L=(double)src.data[0][k];
-			 a=(double)src.data[1][k];
-			 b=(double)src.data[2][k];
-			 ColorConversion::ccCIE_LabtoXYZ(L,a,b,&X,&Y,&Z,0);
-			 ColorConversion::ccXYZtoRGB(X,Y,Z,&R,&G,&B,0);
-			 dst.data[0][k] = (DstPixelType)(R);
-			 dst.data[1][k] = (DstPixelType)(G);
-			 dst.data[2][k] = (DstPixelType)(B);
-		 }		 
-	 }
-     else if ( (srcColorSpace == COLORSPACE_RGB) && (dstColorSpace == COLORSPACE_LMS) )
-     {
-          long k = 0;
-          for ( int y = 0 ; y < src.ysize ; y++ )
-               for ( int x = 0 ; x < src.xsize ; x++,k++ )
-          {
-               double R,G,B,X,Y,Z,L,M,S;
-               R=(double)src.data[0][k]/srcM;
-               G=(double)src.data[1][k]/srcM;
-               B=(double)src.data[2][k]/srcM;
-               ColorConversion::ccRGBtoXYZ(R,G,B,&X,&Y,&Z,0);
-               ColorConversion::ccXYZtoLMS(X,Y,Z,&L,&M,&S);
-               dst.data[0][k] = (DstPixelType)(L);
-               dst.data[1][k] = (DstPixelType)(M);
-               dst.data[2][k] = (DstPixelType)(S);
-          }
-     }
-     else if ( (srcColorSpace == COLORSPACE_RGB) && (dstColorSpace == COLORSPACE_OPP) )
-{
-          long k = 0;
-          for ( int y = 0 ; y < src.ysize ; y++ )
-               for ( int x = 0 ; x < src.xsize ; x++,k++ )
-{
-               double R,G,B,X,Y,Z,L,M,S,Lum,LM,SLM;
-               R=(double)src.data[0][k]/srcM;
-               G=(double)src.data[1][k]/srcM;
-               B=(double)src.data[2][k]/srcM;
-               ColorConversion::ccRGBtoXYZ(R,G,B,&X,&Y,&Z,0);
-               ColorConversion::ccXYZtoLMS(X,Y,Z,&L,&M,&S);
-               ColorConversion::ccLMStoOPP(L,M,S,&Lum,&LM,&SLM);
-               
-               dst.data[0][k] = (DstPixelType)(Lum);
-               dst.data[1][k] = (DstPixelType)(LM);
-               dst.data[2][k] = (DstPixelType)(SLM);
+    for ( int y = 0 ; y < src.height() ; y++ )
+      for ( int x = 0 ; x < src.width() ; x++)
+      {
+        double R, G, B, H, S, L;
+        R = ( double ) src.get(x,y,0) / srcM;
+        G = ( double ) src.get(x,y,1) / srcM;
+        B = ( double ) src.get(x,y,2) / srcM;
+        ColorConversion::ccRGBtoHSL ( R, G, B, &H, &S, &L );
+        dst[0](x,y) = ( DstPixelType ) ( H * dstM );
+        dst[1](x,y) = ( DstPixelType ) ( S * dstM );
+        dst[2](x,y) = ( DstPixelType ) ( L * dstM );
+      }
+  }
+  else if ( ( srcColorSpace == COLORSPACE_RGB ) && ( dstColorSpace == COLORSPACE_LAB ) )
+  {
+    for ( int y = 0 ; y < src.height() ; y++ )
+      for ( int x = 0 ; x < src.width() ; x++ )
+      {
+        double R, G, B, X, Y, Z, L, a, b;
+        R = ( double ) src.get(x,y,0) / 255.0;
+        G = ( double ) src.get(x,y,1) / 255.0;
+        B = ( double ) src.get(x,y,2) / 255.0;
+        ColorConversion::ccRGBtoXYZ ( R, G, B, &X, &Y, &Z, 0 );
+        ColorConversion::ccXYZtoCIE_Lab ( X, Y, Z, &L, &a, &b, 0 );
+        dst[0](x,y) = ( DstPixelType ) ( L );
+        dst[1](x,y) = ( DstPixelType ) ( a );
+        dst[2](x,y) = ( DstPixelType ) ( b );
+      }
+  }
+  else if ( ( srcColorSpace == COLORSPACE_LAB ) && ( dstColorSpace == COLORSPACE_RGB ) )
+  {
+    long k = 0;
+    for ( int y = 0 ; y < src.height() ; y++ )
+      for ( int x = 0 ; x < src.width() ; x++, k++ )
+      {
+        double R, G, B, X, Y, Z, L, a, b;
+        L = ( double ) src.get(x,y,0);
+        a = ( double ) src.get(x,y,1);
+        b = ( double ) src.get(x,y,2);
+        ColorConversion::ccCIE_LabtoXYZ ( L, a, b, &X, &Y, &Z, 0 );
+        ColorConversion::ccXYZtoRGB ( X, Y, Z, &R, &G, &B, 0 );
+        dst[0](x,y) = ( DstPixelType ) ( R );
+        dst[1](x,y) = ( DstPixelType ) ( G );
+        dst[2](x,y) = ( DstPixelType ) ( B );
+      }
+  }
+  else if ( ( srcColorSpace == COLORSPACE_RGB ) && ( dstColorSpace == COLORSPACE_LMS ) )
+  {
+    long k = 0;
+    for ( int y = 0 ; y < src.height() ; y++ )
+      for ( int x = 0 ; x < src.width() ; x++, k++ )
+      {
+        double R, G, B, X, Y, Z, L, M, S;
+        R = ( double ) src.get(x,y,0) / srcM;
+        G = ( double ) src.get(x,y,1) / srcM;
+        B = ( double ) src.get(x,y,2) / srcM;
+        ColorConversion::ccRGBtoXYZ ( R, G, B, &X, &Y, &Z, 0 );
+        ColorConversion::ccXYZtoLMS ( X, Y, Z, &L, &M, &S );
+        dst[0](x,y) = ( DstPixelType ) ( L );
+        dst[1](x,y) = ( DstPixelType ) ( M );
+        dst[2](x,y) = ( DstPixelType ) ( S );
+      }
+  }
+  else if ( ( srcColorSpace == COLORSPACE_RGB ) && ( dstColorSpace == COLORSPACE_OPP ) )
+  {
+    long k = 0;
+    for ( int y = 0 ; y < src.height() ; y++ )
+      for ( int x = 0 ; x < src.width() ; x++, k++ )
+      {
+        double R, G, B, X, Y, Z, L, M, S, Lum, LM, SLM;
+        R = ( double ) src.get(x,y,0) / srcM;
+        G = ( double ) src.get(x,y,1) / srcM;
+        B = ( double ) src.get(x,y,2) / srcM;
+        ColorConversion::ccRGBtoXYZ ( R, G, B, &X, &Y, &Z, 0 );
+        ColorConversion::ccXYZtoLMS ( X, Y, Z, &L, &M, &S );
+        ColorConversion::ccLMStoOPP ( L, M, S, &Lum, &LM, &SLM );
+
+        dst[0](x,y) = ( DstPixelType ) ( Lum );
+        dst[1](x,y) = ( DstPixelType ) ( LM );
+        dst[2](x,y) = ( DstPixelType ) ( SLM );
 #ifdef DEBUG
-               fprintf(stderr,"R:%.4f G:%.4f B:%.4f X:%.4f Y:%.4f Z:%.4f L:%.4f M:%.4f S:%.4f Lum:%.4f LM:%.4f SLM:%.4f\n",R,G,B,X,Y,Z,L,M,S,Lum,LM,SLM);
+        fprintf ( stderr, "R:%.4f G:%.4f B:%.4f X:%.4f Y:%.4f Z:%.4f L:%.4f M:%.4f S:%.4f Lum:%.4f LM:%.4f SLM:%.4f\n", R, G, B, X, Y, Z, L, M, S, Lum, LM, SLM );
 #endif
-}
-}
-     else {
-          fprintf (stderr, "ColorSpace::convert(): not yet implemented - SrcColorSpace %d -> DstColorSpace %d!!\n",srcColorSpace,dstColorSpace);
-	exit(-1);
-    }
+      }
+  }
+  else {
+    fprintf ( stderr, "ColorSpace::convert(): not yet implemented - SrcColorSpace %d -> DstColorSpace %d!!\n", srcColorSpace, dstColorSpace );
+    exit ( -1 );
+  }
 
 }
 

+ 9 - 0
baselib/FastFilter.h

@@ -65,6 +65,15 @@ class FastFilter
 	template <class SrcValueType, class DstValueType>
 	static void calcGradientX ( const SrcValueType *img, int xsize, int ysize, DstValueType *d );
 
+	///lazy attempt for realizing fast histogram of oriented gradients
+	///since (neg.) double values are allowed, fast filtering based on look-up tables is no longer possible
+	template <class GrayValueType, class OrientedGradientHistogramType>
+	static void calcOrientedGradientHistogram ( const GrayValueType *gray, 
+						    int xsize, int ysize,
+						    OrientedGradientHistogramType *hog, 
+						    int numBins, 
+						    bool usesigned );
+
 };
 
 } // namespace

+ 47 - 0
baselib/FastFilter.tcc

@@ -171,3 +171,50 @@ void FastFilter::calcGradient ( const GrayValueType *gray,
     delete [] gy;
 }
 
+
+//lazy attempt for realizing fast histogram of oriented gradients
+//since (neg.) double values are allowed, fast filtering based on look-up tables is no longer possible
+template <class GrayValueType, class OrientedGradientHistogramType>
+void FastFilter::calcOrientedGradientHistogram ( const GrayValueType *gray, 
+						 int xsize, int ysize,
+						 OrientedGradientHistogramType *hog, 
+						 int numBins, 
+						 bool usesigned )
+{
+    double *gx = new double[xsize*ysize];
+    calcGradientX ( gray, xsize, ysize, gx );
+    double *gy = new double[xsize*ysize];
+    calcGradientY ( gray, xsize, ysize, gy );
+    
+    double binq = usesigned ? 2*M_PI / numBins : M_PI / numBins;
+
+    for(int i=0; i<numBins; i++) hog[i] = (OrientedGradientHistogramType) 0.0;
+
+    int k = 0;
+    for ( int y = 0 ; y < ysize ; y++ )
+	for ( int x = 0 ; x < xsize ; x++,k++ )
+	{
+	    double rx = gx[k];
+	    double ry = gy[k];
+	    //GradientMagnitudeType g  = (GradientMagnitudeType)sqrt ( rx*rx + ry*ry );
+	    GrayValueType g  = (GrayValueType) sqrt(rx*rx + ry*ry);
+
+	    double angle = atan2(ry,rx);
+
+	    if ( usesigned ) {
+		if ( angle < 0 )
+		    angle = 2*M_PI + angle;
+	    } else {
+		if ( angle < 0 )
+		    angle = M_PI + angle;
+	    }
+
+	    uint bin = (uint)(angle / binq);
+            bin = bin < numBins ? bin : numBins - 1;
+	    hog[bin]+= (OrientedGradientHistogramType) g;
+	    
+	}
+
+    delete [] gx;
+    delete [] gy;
+}

+ 29 - 52
cbaselib/CachedExample.cpp

@@ -59,15 +59,9 @@ CachedExample::CachedExample ( const NICE::Image & _img )
 
   oxsize = _img.width();
   oysize = _img.height();
-  int *gray = new int [ oxsize*oysize ];
-  int k = 0;
-  for ( int y = 0 ; y < oysize ; y++ )
-    for ( int x = 0 ; x < oxsize ; x++, k++ )
-      gray[k] = _img.getPixel ( x, y );
-
-  ichannels[I_GRAYVALUES].reInit ( oxsize, oysize, 1, false );
-  ichannels[I_GRAYVALUES].setImage ( gray, oxsize, oysize, 0 );
-
+  
+  ichannels[I_GRAYVALUES].freeData();
+  ichannels[I_GRAYVALUES].addChannel(_img);
   hasColorInformation = false;
 }
 
@@ -87,31 +81,18 @@ CachedExample::CachedExample ( const NICE::ColorImage & img, bool disableGrayCon
     NICE::Image imggray;
     ICETools::calcGrayImage ( img, imggray );
 
-    ichannels[I_GRAYVALUES].reInit ( oxsize, oysize, 1, true );
-    int *gray = ichannels[I_GRAYVALUES].data[0];
-    int k = 0;
-    for ( int y = 0 ; y < oysize ; y++ )
-      for ( int x = 0 ; x < oxsize ; x++, k++ )
-        // refactor-nice.pl: check this substitution
-        // old: gray[k] = GetVal(imggray,x,y);
-        gray[k] = imggray.getPixel ( x, y );
+    ichannels[I_GRAYVALUES].freeData();
+    ichannels[I_GRAYVALUES].addChannel(imggray);
   }
 
-  ichannels[I_COLOR].reInit ( oxsize, oysize, 3, true );
+  ichannels[I_COLOR].reInit ( oxsize, oysize, 3);
 
-  long int k = 0;
   for ( int y = 0 ; y < oysize ; y++ )
-    for ( int x = 0 ; x < oxsize ; x++, k++ )
+    for ( int x = 0 ; x < oxsize ; x++ )
     {
-      // refactor-nice.pl: check this substitution
-      // old: ichannels[I_COLOR].data[0][k] = GetVal(img.RedImage(), x, y);
-      ichannels[I_COLOR].data[0][k] = img.getPixel ( x, y, 0 );
-      // refactor-nice.pl: check this substitution
-      // old: ichannels[I_COLOR].data[1][k] = GetVal(img.GreenImage(), x, y);
-      ichannels[I_COLOR].data[1][k] = img.getPixel ( x, y, 1 );
-      // refactor-nice.pl: check this substitution
-      // old: ichannels[I_COLOR].data[2][k] = GetVal(img.BlueImage(), x, y);
-      ichannels[I_COLOR].data[2][k] = img.getPixel ( x, y, 2 );
+      ichannels[I_COLOR](x,y,0) = img.getPixel ( x, y, 0 );
+      ichannels[I_COLOR](x,y,1) = img.getPixel ( x, y, 1 );
+      ichannels[I_COLOR](x,y,2) = img.getPixel ( x, y, 2 );
     }
 
   hasColorInformation = true;
@@ -173,12 +154,8 @@ void CachedExample::readImageData ()
   oxsize = imggray.width();
   oysize = imggray.height();
 
-  ichannels[I_GRAYVALUES].reInit ( oxsize, oysize, 1, true );
-  int *gray = ichannels[I_GRAYVALUES].data[0];
-  int k = 0;
-  for ( int y = 0 ; y < oysize ; y++ )
-    for ( int x = 0 ; x < oxsize ; x++, k++ )
-      gray[k] = imggray.getPixel ( x, y );
+  ichannels[I_GRAYVALUES].freeData();
+  ichannels[I_GRAYVALUES].addChannel(imggray);
 }
 
 void CachedExample::readImageDataRGB ()
@@ -199,40 +176,40 @@ void CachedExample::readImageDataRGB ()
 
   hasColorInformation = true;
 
-  ichannels[I_COLOR].reInit ( oxsize, oysize, 3, true );
-
-  long k = 0;
+  ichannels[I_COLOR].reInit ( oxsize, oysize, 3);
+  
   for ( int y = 0 ; y < oysize ; y++ )
-    for ( int x = 0 ; x < oxsize ; x++, k++ )
+    for ( int x = 0 ; x < oxsize ; x++)
     {
-      ichannels[I_COLOR].data[0][k] = img.getPixel ( x, y, 0 );
-      ichannels[I_COLOR].data[1][k] = img.getPixel ( x, y, 1 );
-      ichannels[I_COLOR].data[2][k] = img.getPixel ( x, y, 2 );
+      ichannels[I_COLOR](x,y,0) = img.getPixel ( x, y, 0 );
+      ichannels[I_COLOR](x,y,1) = img.getPixel ( x, y, 1 );
+      ichannels[I_COLOR](x,y,2) = img.getPixel ( x, y, 2 );
     }
 }
 
 void CachedExample::calcIntegralImage ()
 {
-  if ( ichannels[I_GRAYVALUES].xsize == 0 )
+  if ( ichannels[I_GRAYVALUES].width() == 0 )
   {
     readImageData ();
-    if ( ichannels[I_GRAYVALUES].xsize == 0 )
+    if ( ichannels[I_GRAYVALUES].width() == 0 )
     {
       fprintf ( stderr, "CachedExample::getChannel: unable to recover data channel\n" );
       exit ( -1 );
     }
   }
 
-  lchannels[L_INTEGRALIMAGE].reInit ( ichannels[I_GRAYVALUES].xsize,
-                                      ichannels[I_GRAYVALUES].ysize,
-                                      1, true );
+  lchannels[L_INTEGRALIMAGE].reInit ( ichannels[I_GRAYVALUES].width(),
+                                      ichannels[I_GRAYVALUES].height(),
+                                      1);
 
-  GenericImageTools::calcIntegralImage (
-    lchannels[L_INTEGRALIMAGE].data[0],
-    ichannels[I_GRAYVALUES].data[0],
-    ichannels[I_GRAYVALUES].xsize,
-    ichannels[I_GRAYVALUES].ysize );
+  ImageT<long int> tmp = lchannels[L_INTEGRALIMAGE][0];
 
+  GenericImageTools::calcIntegralImage (
+    tmp,
+    ichannels[I_GRAYVALUES][0],
+    ichannels[I_GRAYVALUES].width(),
+    ichannels[I_GRAYVALUES].height() );
 }
 
 void CachedExample::buildIntegralSV ( int svchannel,

+ 3 - 3
cbaselib/CachedExample.h

@@ -220,7 +220,7 @@ inline NICE::MultiChannelImageT<double> & CachedExample::getDChannel ( int chann
 {
   assert ( ( channel >= 0 ) && ( channel < D_NUMCHANNELS ) );
 
-  if ( dchannels[channel].data == NULL )
+  if ( dchannels[channel].channels() == 0 )
   {
     std::map<int, std::string>::const_iterator j = dtemps.find ( channel );
     if ( j == dtemps.end() )
@@ -248,7 +248,7 @@ inline NICE::MultiChannelImageT<int> & CachedExample::getIChannel ( int channel
 {
   assert ( ( channel >= 0 ) && ( channel < I_NUMCHANNELS ) );
 
-  if ( ( ichannels[channel].data == NULL ) )
+  if ( ( ichannels[channel].channels() == 0 ) )
   {
     if ( ( imgfn != "" ) && ( channel == I_GRAYVALUES ) )
     {
@@ -282,7 +282,7 @@ inline NICE::MultiChannelImageT<long> & CachedExample::getLChannel ( int channel
 {
   assert ( ( channel >= 0 ) && ( channel < L_NUMCHANNELS ) );
 
-  if ( lchannels[channel].data == NULL )
+  if ( lchannels[channel].channels() == 0 )
   {
     std::map<int, std::string>::const_iterator j = ltemps.find ( channel );
     if ( j == ltemps.end() )

+ 20 - 19
cbaselib/Feature.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file Feature.h
 * @brief abstraction of a feature
 * @author Erik Rodner
@@ -38,29 +38,29 @@ class FeatureStorageUnsorted : public std::map< int, FeatureValuesUnsorted > {};
 class Feature : public NICE::Persistent
 {
 
-    protected:
+protected:
 
-    public:
-  
-	/** simple constructor */
-	Feature();
-      
-	/** simple destructor */
-	virtual ~Feature();
+public:
 
-	virtual double val( const Example *example ) const = 0;
+    /** simple constructor */
+    Feature();
 
-	virtual Feature *clone() const = 0;
+    /** simple destructor */
+    virtual ~Feature();
 
-	virtual void explode ( FeaturePool & featurePool, bool variableWindow = true ) const = 0;
+    virtual double val( const Example *example ) const = 0;
 
-	virtual void calcFeatureValues ( const Examples & examples,
-				    std::vector<int> & examples_selection,
-				    FeatureValuesUnsorted & values ) const;
-    
-        virtual void calcFeatureValues ( const Examples & examples,
-				    std::vector<int> & examples_selection,
-				    FeatureValues & values ) const;
+    virtual Feature *clone() const = 0;
+
+    virtual void explode ( FeaturePool & featurePool, bool variableWindow = true ) const = 0;
+
+    virtual void calcFeatureValues ( const Examples & examples,
+                                     std::vector<int> & examples_selection,
+                                     FeatureValuesUnsorted & values ) const;
+
+    virtual void calcFeatureValues ( const Examples & examples,
+                                     std::vector<int> & examples_selection,
+                                     FeatureValues & values ) const;
 
 };
 
@@ -70,3 +70,4 @@ class Feature : public NICE::Persistent
 #undef ROADWORKS
 
 #endif
+

+ 16 - 5
cbaselib/ImageInfo.cpp

@@ -17,6 +17,8 @@
 #ifdef NICE_USELIB_QT4_XML
 
 #include <QFile>
+#include <QFileInfo>
+#include <QDir>
 #include <QString>
 #include <QByteArray>
 #include <QDomDocument>
@@ -87,16 +89,25 @@ ImageInfo::loadImageInfo(const string &aFilename)
 		if(!element.isNull()) {
 			/* path to the image */
 			if (element.tagName() == "image") {
-				string_buffer = element.text();
-				if (string_buffer.isEmpty()) {
+
+                string_buffer = element.text();
+
+                if (string_buffer.isEmpty())
+                {
 					cout << "loadImageInfo:The file with data"
 							" doesn't contain path to the image\n";
 					return false;
-					/* NOTREACHED */
 				}
+                if( QFileInfo(string_buffer).isRelative() )
+                {
+                    QString asd = QFileInfo( QString(aFilename.c_str()) ).absoluteDir().absolutePath();
+
+                    QString qwe = QFileInfo( asd + "/" + string_buffer ).absoluteFilePath();
+
+                    string_buffer = qwe;
+                }
 
-				QByteArray array = string_buffer.toAscii();
-				image_path_ = string(array.data());
+                image_path_ = string_buffer.toStdString();
 			}
 			/* path to the segmented image */
 			if (element.tagName() == "segmented") {

+ 202 - 202
cbaselib/LabeledFileList.cpp

@@ -22,9 +22,9 @@ using namespace OBJREC;
 using namespace std;
 using namespace NICE;
 
-LabeledFileList::LabeledFileList() 
+LabeledFileList::LabeledFileList()
 {
-    debug_dataset = false;
+  debug_dataset = true;
 }
 
 LabeledFileList::~LabeledFileList()
@@ -45,71 +45,71 @@ LabeledFileList::~LabeledFileList()
  * @param conf configuration structure containing a information from a loaded config file; has to tag "localization_format" in section "main" in order to obtain the correct label information from a file.
  */
 LocalizationResult *LabeledFileList::getLocalizationInfo ( const ClassNames & classnames,
-					    int classno,
-					    const std::string & file,
-					    const Config & conf ) const
+    int classno,
+    const std::string & file,
+    const Config & conf ) const
 {
-    /*
-    localization_pattern = image
-    localization_subst   = mask
-    localization_format  = image
-    */
-    std::string format = conf.gS("main", "localization_format", "unknown");
-    if ( format == "unknown" )
-	return NULL;
-
-    std::string pattern = conf.gS("main", "localization_pattern" );
-    std::string subst   = conf.gS("main", "localization_subst" );
-
-    std::string lfile = file;
-    if ( ! StringTools::regexSubstitute ( lfile, pattern, subst ) )
-    {
-	fprintf (stderr, "Unable to substitute using pattern #%s# and string #%s#\n",
-	    pattern.c_str(), lfile.c_str() );
-	exit(-1);
+  /*
+  localization_pattern = image
+  localization_subst   = mask
+  localization_format  = image
+  */
+  std::string format = conf.gS ( "main", "localization_format", "unknown" );
+  if ( format == "unknown" )
+    return NULL;
+
+  std::string pattern = conf.gS ( "main", "localization_pattern" );
+  std::string subst   = conf.gS ( "main", "localization_subst" );
+
+  std::string lfile = file;
+  if ( ! StringTools::regexSubstitute ( lfile, pattern, subst ) )
+  {
+    fprintf ( stderr, "Unable to substitute using pattern #%s# and string #%s#\n",
+              pattern.c_str(), lfile.c_str() );
+    exit ( -1 );
+  }
+
+  if ( ! FileMgt::fileExists ( lfile ) ) return NULL;
+  if ( debug_dataset )
+  {
+    fprintf ( stderr, "LabeledFileList: reading localization information %s\n", lfile.c_str() );
+  }
+
+  LocalizationResult *lr = NULL;
+
+  if ( format == "image" )
+  {
+    NICE::Image mask;
+    try {
+      mask.read ( lfile );
+    } catch ( ImageException & ) {
+      fprintf ( stderr, "WARNING: unable to open file %s (no localization info provided)\n",
+                lfile.c_str() );
+      return NULL;
     }
 
-    if ( ! FileMgt::fileExists(lfile) ) return NULL;
-    if ( debug_dataset )
-    {
-	fprintf (stderr, "LabeledFileList: reading localization information %s\n", lfile.c_str() );
+    lr = new LocalizationResult ( &classnames, mask, classno );
+
+  } else if ( format == "imagergb" ) {
+    NICE::ColorImage mask;
+    try {
+      mask.read ( lfile );
+    } catch ( ImageException &e ) {
+      fprintf ( stderr, "WARNING: unable to open file %s (no localization info provided)\n",
+                lfile.c_str() );
+      fprintf ( stderr, "Error: %s\n", e.what() );
+      return NULL;
     }
+    lr = new LocalizationResult ( &classnames, mask );
 
-    LocalizationResult *lr = NULL;
+  } else if ( format == "polygon" ) {
+    lr = new LocalizationResult ( &classnames );
 
-    if ( format == "image" )
-    {
-		NICE::Image mask;
-		try {
-			mask.read(lfile);
-		} catch (ImageException &) {
-			fprintf (stderr, "WARNING: unable to open file %s (no localization info provided)\n",
-			lfile.c_str() );
-			return NULL;
-		}
-		
-		lr = new LocalizationResult ( &classnames, mask, classno );
-
-    } else if ( format == "imagergb" ) {
-		NICE::ColorImage mask;
-		try {
-			mask.read( lfile );
-		} catch (ImageException &e) {
-			fprintf (stderr, "WARNING: unable to open file %s (no localization info provided)\n",
-			lfile.c_str() );
-			fprintf (stderr, "Error: %s\n", e.what() );
-			return NULL;
-		}
-		lr = new LocalizationResult ( &classnames, mask );
-
-    } else if ( format == "polygon" ) {
-		lr = new LocalizationResult ( &classnames );
-
-		lr->read ( lfile, LocalizationResult::FILEFORMAT_POLYGON );
-
-		if ( debug_dataset )
-		   fprintf (stderr, "LabeledFileList: object localization %d\n", (int)lr->size() );
-        }
+    lr->read ( lfile, LocalizationResult::FILEFORMAT_POLYGON );
+
+      if ( debug_dataset )
+	  fprintf (stderr, "LabeledFileList: object localization %d\n", (int)lr->size() );
+    }
     else if ( format == "imagelabeler" ) {
 
         lr = new LocalizationResult ( &classnames );
@@ -117,157 +117,157 @@ LocalizationResult *LabeledFileList::getLocalizationInfo ( const ClassNames & cl
 
     }
     else {
-			fthrow(Exception, "Localization format not yet supported !!\n");
-		}
+      fthrow(Exception, "Localization format not yet supported !!\n");
+    }
    
-	if ( debug_dataset )
-	    if ( lr != NULL )
-			fprintf (stderr, "%s (%d objects)\n", lfile.c_str(), (int)lr->size() );
+    if ( debug_dataset )
+	if ( lr != NULL )
+		    fprintf (stderr, "%s (%d objects)\n", lfile.c_str(), (int)lr->size() );
 
-    return lr;
+  return lr;
 }
 
 void LabeledFileList::getFromPattern (
-    const std::string & dir,
-    const Config & datasetconf,
-    const ClassNames & classnames, 
-    LabeledSet & ls,
-    bool localizationInfoDisabled ) const
+  const std::string & dir,
+  const Config & datasetconf,
+  const ClassNames & classnames,
+  LabeledSet & ls,
+  bool localizationInfoDisabled ) const
 {
-    std::string filemask;
-    
-    if ( dir.substr(dir.length()-1,1) != "/" )
-		filemask = dir + "/" + datasetconf.gS("main", "pattern");
-    else
-		filemask = dir + datasetconf.gS("main", "pattern");
-
-    std::vector<string> files;
-
-    int classnameField = datasetconf.gI("main", "classname_field", 1);
-    std::string fixedClassname = datasetconf.gS("main", "fixed_classname", "");
-    
-    files.clear();
-    FileMgt::DirectoryRecursive ( files, dir );
-    fprintf (stderr, "LabeledFileList: Files: %d\n", (int)files.size());
-
-    sort ( files.begin(), files.end() );
-
-    for ( vector<string>::const_iterator i  = files.begin();
-					 i != files.end(); 
-					 i++ ) 
+  std::string filemask;
+
+  if ( dir.substr ( dir.length() - 1, 1 ) != "/" )
+    filemask = dir + "/" + datasetconf.gS ( "main", "pattern" );
+  else
+    filemask = dir + datasetconf.gS ( "main", "pattern" );
+
+  std::vector<string> files;
+
+  int classnameField = datasetconf.gI ( "main", "classname_field", 1 );
+  std::string fixedClassname = datasetconf.gS ( "main", "fixed_classname", "" );
+
+  files.clear();
+  FileMgt::DirectoryRecursive ( files, dir );
+  fprintf ( stderr, "LabeledFileList: Files: %d\n", ( int ) files.size() );
+
+  sort ( files.begin(), files.end() );
+
+  for ( vector<string>::const_iterator i  = files.begin();
+        i != files.end();
+        i++ )
+  {
+    vector<string> submatches;
+    // refactor-nice.pl: check this substitution
+    // old: const string & file = *i;
+    const std::string & file = *i;
+    if ( debug_dataset )
+      fprintf ( stderr, "LabeledFileList: next file: %s\n", file.c_str() );
+
+    bool match = StringTools::regexMatch ( file, filemask, submatches );
+
+    if ( ( fixedClassname == "" ) && ( ( int ) submatches.size() <= classnameField ) ) match = false;
+
+    if ( ! match )
     {
-		vector<string> submatches;
-		// refactor-nice.pl: check this substitution
-		// old: const string & file = *i;
-		const std::string & file = *i;
-		if ( debug_dataset ) 
-			fprintf (stderr, "LabeledFileList: next file: %s\n", file.c_str() );
-
-		bool match = StringTools::regexMatch ( file, filemask, submatches );
-
-		if ( (fixedClassname == "") && ((int)submatches.size() <= classnameField) ) match = false;
-
-		if ( ! match  )
-		{
-			if ( debug_dataset )
-			fprintf (stderr, "LabeledFileList: WARNING: %s does not match filemask: %s!!\n", file.c_str(), filemask.c_str() );
-		} else {
-			std::string classcode = ( fixedClassname == "" ) ? submatches[classnameField] : fixedClassname;
-
-			if ( classnames.existsClassCode(classcode) ) {
-				int classno = classnames.classno(classcode);
-				LocalizationResult *lr  = NULL;
-				
-				if ( ! localizationInfoDisabled )
-					lr = getLocalizationInfo ( 
-					classnames, classno, file, datasetconf);
-
-				if ( debug_dataset )
-					fprintf (stderr, "LabeledFileList: LabeledSet: add %s (%d)\n", file.c_str(), classno );
-				if ( lr == NULL ) 
-				{
-					ls.add ( classno, new ImageInfo(file) );
-				} else {
-					ls.add ( classno, new ImageInfo(file, lr) );
-					if ( debug_dataset )
-					fprintf (stderr, "LabeledFileList: LocalizationResult added!\n");
-
-				}
-			} else {
-				if ( debug_dataset )
-				{
-					for ( vector<string>::iterator i = submatches.begin();
-								   i != submatches.end();
-								   i++ )
-					{
-						fprintf (stderr, "LabeledFileList: submatch: %s\n", i->c_str() );
-					}
-					fprintf (stderr, "LabeledFileList: WARNING: code %s ignored !\n", classcode.c_str() );
-				}
-			}
-		}
-		if ( debug_dataset )
-			fprintf (stderr, "LabeledFileList: filename processed\n");
-	}
-
-    cerr << "directory " << dir << " loaded..." << endl;
-    ls.printInformation();
+      if ( debug_dataset )
+        fprintf ( stderr, "LabeledFileList: WARNING: %s does not match filemask: %s!!\n", file.c_str(), filemask.c_str() );
+    } else {
+      std::string classcode = ( fixedClassname == "" ) ? submatches[classnameField] : fixedClassname;
+
+      if ( classnames.existsClassCode ( classcode ) ) {
+        int classno = classnames.classno ( classcode );
+        LocalizationResult *lr  = NULL;
+
+        if ( ! localizationInfoDisabled )
+          lr = getLocalizationInfo (
+                 classnames, classno, file, datasetconf );
+
+        if ( debug_dataset )
+          fprintf ( stderr, "LabeledFileList: LabeledSet: add %s (%d)\n", file.c_str(), classno );
+        if ( lr == NULL )
+        {
+          ls.add ( classno, new ImageInfo ( file ) );
+        } else {
+          ls.add ( classno, new ImageInfo ( file, lr ) );
+          if ( debug_dataset )
+            fprintf ( stderr, "LabeledFileList: LocalizationResult added!\n" );
+
+        }
+      } else {
+        if ( debug_dataset )
+        {
+          for ( vector<string>::iterator i = submatches.begin();
+                i != submatches.end();
+                i++ )
+          {
+            fprintf ( stderr, "LabeledFileList: submatch: %s\n", i->c_str() );
+          }
+          fprintf ( stderr, "LabeledFileList: WARNING: code %s ignored !\n", classcode.c_str() );
+        }
+      }
+    }
+    if ( debug_dataset )
+      fprintf ( stderr, "LabeledFileList: filename processed\n" );
+  }
+
+  cerr << "directory " << dir << " loaded..." << endl;
+  ls.printInformation();
 
 }
 
 void LabeledFileList::getFromList (
-    const std::string & filelist,
-    const Config & datasetconf,
-    const ClassNames & classnames, 
-    LabeledSet & ls,
-    bool localizationInfoDisabled) const
+  const std::string & filelist,
+  const Config & datasetconf,
+  const ClassNames & classnames,
+  LabeledSet & ls,
+  bool localizationInfoDisabled ) const
 {
-	if ( debug_dataset ) 
-		fprintf (stderr, "Reading file list: %s\n", filelist.c_str() );
+  if ( debug_dataset )
+    fprintf ( stderr, "Reading file list: %s\n", filelist.c_str() );
 
-    ifstream ifs ( filelist.c_str(), ios::in );
-	if ( ! ifs.good() ) 
-		fthrow(IOException, "File list " << filelist << " not found !");
-    
-    std::string fixedClassname = datasetconf.gS("main", "fixed_classname", "");
+  ifstream ifs ( filelist.c_str(), ios::in );
+  if ( ! ifs.good() )
+    fthrow ( IOException, "File list " << filelist << " not found !" );
 
-    while ( ! ifs.eof() )
-    {
-		std::string classcode;
-		std::string file;
-
-		if ( fixedClassname == "" ) {
-			if ( ! (ifs >> classcode) ) break;
-		} else {
-			classcode = fixedClassname;
-		}
-
-		if ( ! (ifs >> file) ) break;
-
-		if ( classnames.existsClassCode(classcode) ) {
-			int classno = classnames.classno(classcode);
-			
-			LocalizationResult *lr  = NULL;
-			
-			if ( ! localizationInfoDisabled )
-				lr = getLocalizationInfo ( classnames, classno, file, datasetconf);
-
-			if ( debug_dataset )
-				cerr << "Adding file " << file << " with classno " << classno << endl;
-
-			if ( lr == NULL ) 
-				ls.add ( classno, new ImageInfo(file) );
-			else
-				ls.add ( classno, new ImageInfo(file, lr) );
-		} else {
-			if ( debug_dataset )
-				fprintf (stderr, "WARNING: code %s ignored !\n", classcode.c_str() );
-		}
+  std::string fixedClassname = datasetconf.gS ( "main", "fixed_classname", "" );
 
+  while ( ! ifs.eof() )
+  {
+    std::string classcode;
+    std::string file;
+
+    if ( fixedClassname == "" ) {
+      if ( ! ( ifs >> classcode ) ) break;
+    } else {
+      classcode = fixedClassname;
     }
 
-	if ( debug_dataset )
-	    ls.printInformation();
+    if ( ! ( ifs >> file ) ) break;
+
+    if ( classnames.existsClassCode ( classcode ) ) {
+      int classno = classnames.classno ( classcode );
+
+      LocalizationResult *lr  = NULL;
+
+      if ( ! localizationInfoDisabled )
+        lr = getLocalizationInfo ( classnames, classno, file, datasetconf );
+
+      if ( debug_dataset )
+        cerr << "Adding file " << file << " with classno " << classno << endl;
+
+      if ( lr == NULL )
+        ls.add ( classno, new ImageInfo ( file ) );
+      else
+        ls.add ( classno, new ImageInfo ( file, lr ) );
+    } else {
+      if ( debug_dataset )
+        fprintf ( stderr, "WARNING: code %s ignored !\n", classcode.c_str() );
+    }
+
+  }
+
+  if ( debug_dataset )
+    ls.printInformation();
 }
 
 void LabeledFileList::get ( 
@@ -284,14 +284,14 @@ void LabeledFileList::get (
 
     this->debug_dataset = debugDataset;
 
-    if ( pattern.size() > 0 ) 
-		getFromPattern ( dir, datasetconf, classnames, ls, localizationInfoDisabled );
-    else if ( filelist.size() > 0 ) {
+  if ( pattern.size() > 0 )
+    getFromPattern ( dir, datasetconf, classnames, ls, localizationInfoDisabled );
+  else if ( filelist.size() > 0 ) {
 
-		std::string cfilelist = datasetconf.gS("main", "filelist");
+	std::string cfilelist = datasetconf.gS("main", "filelist");
         std::string filelist = ( cfilelist.substr(0,1) == "/" ) ? cfilelist : dir + "/" + cfilelist;
 
-		getFromList ( filelist, datasetconf, classnames, ls, localizationInfoDisabled );
+	getFromList ( filelist, datasetconf, classnames, ls, localizationInfoDisabled );
     }
     else if( !factoryxmlfile.empty() &&  m_pLabeledSetFactory != NULL )
     {
@@ -299,7 +299,7 @@ void LabeledFileList::get (
         m_pLabeledSetFactory->createLabeledSetFromXml( factoryxmlfile, datasetconf,classnames, ls );
     }
     else {
-		fprintf (stderr, "LabeledFileList: Unable to obtain labeled file list\n");
-		exit(-1);
+	fprintf (stderr, "LabeledFileList: Unable to obtain labeled file list\n");
+	exit(-1);
     }
 }

+ 331 - 0
cbaselib/LabeledFileList.cpp~

@@ -0,0 +1,331 @@
+/**
+* @file LabeledFileList.cpp
+* @brief reads images from directory
+* @author Erik Rodner
+* @date 17.09.2007
+
+*/
+#include "core/image/ImageT.h"
+#include "core/vector/VectorT.h"
+#include "core/vector/MatrixT.h"
+
+#include <iostream>
+#include <sstream>
+
+#include "core/basics/StringTools.h"
+#include "core/basics/FileMgt.h"
+
+#include "vislearning/cbaselib/LabeledFileList.h"
+
+using namespace OBJREC;
+
+using namespace std;
+using namespace NICE;
+
+LabeledFileList::LabeledFileList()
+{
+  debug_dataset = true;
+}
+
+LabeledFileList::~LabeledFileList()
+{
+}
+
+
+/**
+ * @brief Loads the label information according to a given label file format.
+ *
+ * Supported types of label file format (localization_format):
+ * - "image": <br>usage of a single channel images containing label regions
+ * - "imagergb": <br>usage of a multi channel color images containing label regions
+ * - "polygon": <br>obtaining bounding boxes from textural label files (used with e.g. PASCAL dataset)
+ * - "imagelabeler": <br>obtaining label information (currently only bounding boxes) from the separate label files (XML like) created with the ImageLabeler ( < file name >_labeled.dat ). @see ImageInfo
+ *
+ * @param classnames class containing all potential class names (label categories)
+ * @param conf configuration structure containing a information from a loaded config file; has to tag "localization_format" in section "main" in order to obtain the correct label information from a file.
+ */
+LocalizationResult *LabeledFileList::getLocalizationInfo ( const ClassNames & classnames,
+    int classno,
+    const std::string & file,
+    const Config & conf ) const
+{
+  /*
+  localization_pattern = image
+  localization_subst   = mask
+  localization_format  = image
+  */
+  std::string format = conf.gS ( "main", "localization_format", "unknown" );
+  if ( format == "unknown" )
+    return NULL;
+
+  std::string pattern = conf.gS ( "main", "localization_pattern" );
+  std::string subst   = conf.gS ( "main", "localization_subst" );
+
+  std::string lfile = file;
+  if ( ! StringTools::regexSubstitute ( lfile, pattern, subst ) )
+  {
+    fprintf ( stderr, "Unable to substitute using pattern #%s# and string #%s#\n",
+              pattern.c_str(), lfile.c_str() );
+    exit ( -1 );
+  }
+
+  if ( ! FileMgt::fileExists ( lfile ) ) return NULL;
+  if ( debug_dataset )
+  {
+    fprintf ( stderr, "LabeledFileList: reading localization information %s\n", lfile.c_str() );
+  }
+
+  LocalizationResult *lr = NULL;
+
+  if ( format == "image" )
+  {
+    NICE::Image mask;
+    try {
+      mask.read ( lfile );
+    } catch ( ImageException & ) {
+      fprintf ( stderr, "WARNING: unable to open file %s (no localization info provided)\n",
+                lfile.c_str() );
+      return NULL;
+    }
+
+    lr = new LocalizationResult ( &classnames, mask, classno );
+
+  } else if ( format == "imagergb" ) {
+    NICE::ColorImage mask;
+    try {
+      mask.read ( lfile );
+    } catch ( ImageException &e ) {
+      fprintf ( stderr, "WARNING: unable to open file %s (no localization info provided)\n",
+                lfile.c_str() );
+      fprintf ( stderr, "Error: %s\n", e.what() );
+      return NULL;
+    }
+    lr = new LocalizationResult ( &classnames, mask );
+
+  } else if ( format == "polygon" ) {
+    lr = new LocalizationResult ( &classnames );
+
+    lr->read ( lfile, LocalizationResult::FILEFORMAT_POLYGON );
+
+      if ( debug_dataset )
+	  fprintf (stderr, "LabeledFileList: object localization %d\n", (int)lr->size() );
+    }
+    else if ( format == "imagelabeler" ) {
+
+        lr = new LocalizationResult ( &classnames );
+        lr->loadImageInfo(lfile);
+
+    }
+    else {
+      fthrow(Exception, "Localization format not yet supported !!\n");
+    }
+   
+    if ( debug_dataset )
+	if ( lr != NULL )
+		    fprintf (stderr, "%s (%d objects)\n", lfile.c_str(), (int)lr->size() );
+
+  return lr;
+}
+
+void LabeledFileList::getFromPattern (
+  const std::string & dir,
+  const Config & datasetconf,
+  const ClassNames & classnames,
+  LabeledSet & ls,
+  bool localizationInfoDisabled ) const
+{
+  std::string filemask;
+
+  if ( dir.substr ( dir.length() - 1, 1 ) != "/" )
+    filemask = dir + "/" + datasetconf.gS ( "main", "pattern" );
+  else
+    filemask = dir + datasetconf.gS ( "main", "pattern" );
+
+  std::vector<string> files;
+
+  int classnameField = datasetconf.gI ( "main", "classname_field", 1 );
+  std::string fixedClassname = datasetconf.gS ( "main", "fixed_classname", "" );
+
+  files.clear();
+  FileMgt::DirectoryRecursive ( files, dir );
+  fprintf ( stderr, "LabeledFileList: Files: %d\n", ( int ) files.size() );
+
+  sort ( files.begin(), files.end() );
+
+  for ( vector<string>::const_iterator i  = files.begin();
+        i != files.end();
+        i++ )
+  {
+    vector<string> submatches;
+    // refactor-nice.pl: check this substitution
+    // old: const string & file = *i;
+    const std::string & file = *i;
+    if ( debug_dataset )
+      fprintf ( stderr, "LabeledFileList: next file: %s\n", file.c_str() );
+
+    bool match = StringTools::regexMatch ( file, filemask, submatches );
+
+    if ( ( fixedClassname == "" ) && ( ( int ) submatches.size() <= classnameField ) ) match = false;
+
+    if ( ! match )
+    {
+      if ( debug_dataset )
+        fprintf ( stderr, "LabeledFileList: WARNING: %s does not match filemask: %s!!\n", file.c_str(), filemask.c_str() );
+    } else {
+      std::string classcode = ( fixedClassname == "" ) ? submatches[classnameField] : fixedClassname;
+
+      if ( classnames.existsClassCode ( classcode ) ) {
+        int classno = classnames.classno ( classcode );
+        LocalizationResult *lr  = NULL;
+
+        if ( ! localizationInfoDisabled )
+          lr = getLocalizationInfo (
+                 classnames, classno, file, datasetconf );
+
+        if ( debug_dataset )
+          fprintf ( stderr, "LabeledFileList: LabeledSet: add %s (%d)\n", file.c_str(), classno );
+        if ( lr == NULL )
+        {
+          ls.add ( classno, new ImageInfo ( file ) );
+        } else {
+          ls.add ( classno, new ImageInfo ( file, lr ) );
+          if ( debug_dataset )
+            fprintf ( stderr, "LabeledFileList: LocalizationResult added!\n" );
+
+        }
+      } else {
+        if ( debug_dataset )
+        {
+          for ( vector<string>::iterator i = submatches.begin();
+                i != submatches.end();
+                i++ )
+          {
+            fprintf ( stderr, "LabeledFileList: submatch: %s\n", i->c_str() );
+          }
+          fprintf ( stderr, "LabeledFileList: WARNING: code %s ignored !\n", classcode.c_str() );
+        }
+      }
+    }
+    if ( debug_dataset )
+      fprintf ( stderr, "LabeledFileList: filename processed\n" );
+  }
+
+  cerr << "directory " << dir << " loaded..." << endl;
+  ls.printInformation();
+
+}
+
+void LabeledFileList::getFromList (
+  const std::string & filelist,
+  const Config & datasetconf,
+  const ClassNames & classnames,
+  LabeledSet & ls,
+  bool localizationInfoDisabled ) const
+{
+  if ( debug_dataset )
+    fprintf ( stderr, "Reading file list: %s\n", filelist.c_str() );
+
+  ifstream ifs ( filelist.c_str(), ios::in );
+  if ( ! ifs.good() )
+    fthrow ( IOException, "File list " << filelist << " not found !" );
+
+  std::string fixedClassname = datasetconf.gS ( "main", "fixed_classname", "" );
+
+  while ( ! ifs.eof() )
+  {
+    std::string classcode;
+    std::string file;
+
+    if ( fixedClassname == "" ) {
+      if ( ! ( ifs >> classcode ) ) break;
+    } else {
+      classcode = fixedClassname;
+    }
+
+    if ( ! ( ifs >> file ) ) break;
+
+    if ( classnames.existsClassCode ( classcode ) ) {
+      int classno = classnames.classno ( classcode );
+
+      LocalizationResult *lr  = NULL;
+
+      if ( ! localizationInfoDisabled )
+        lr = getLocalizationInfo ( classnames, classno, file, datasetconf );
+
+      if ( debug_dataset )
+        cerr << "Adding file " << file << " with classno " << classno << endl;
+
+      if ( lr == NULL )
+        ls.add ( classno, new ImageInfo ( file ) );
+      else
+        ls.add ( classno, new ImageInfo ( file, lr ) );
+    } else {
+      if ( debug_dataset )
+        fprintf ( stderr, "WARNING: code %s ignored !\n", classcode.c_str() );
+    }
+
+  }
+
+  if ( debug_dataset )
+    ls.printInformation();
+}
+
+<<<<<<< HEAD
+void LabeledFileList::get ( 
+    const std::string & dir,
+    const Config & datasetconf,
+    const ClassNames & classnames, 
+    LabeledSet & ls, 
+    bool localizationInfoDisabled,
+    bool debugDataset ) 
+{
+    std::string pattern = datasetconf.gS("main", "pattern", "");
+    std::string filelist = datasetconf.gS("main", "filelist", "");
+    std::string factoryxmlfile = datasetconf.gS("main", "factoryxml", "");
+
+    this->debug_dataset = debugDataset;
+=======
+
+void LabeledFileList::get (
+  const std::string & dir,
+  const Config & datasetconf,
+  const ClassNames & classnames,
+  LabeledSet & ls,
+  bool localizationInfoDisabled,
+  bool debugDataset )
+{
+  std::string pattern = datasetconf.gS ( "main", "pattern", "" );
+  std::string filelist = datasetconf.gS ( "main", "filelist", "" );
+  this->debug_dataset = debugDataset;
+>>>>>>> 58806271b9d9e859d773707495a6097dddd86924
+
+  if ( pattern.size() > 0 )
+    getFromPattern ( dir, datasetconf, classnames, ls, localizationInfoDisabled );
+  else if ( filelist.size() > 0 ) {
+
+<<<<<<< HEAD
+		std::string cfilelist = datasetconf.gS("main", "filelist");
+        std::string filelist = ( cfilelist.substr(0,1) == "/" ) ? cfilelist : dir + "/" + cfilelist;
+
+		getFromList ( filelist, datasetconf, classnames, ls, localizationInfoDisabled );
+    }
+    else if( !factoryxmlfile.empty() &&  m_pLabeledSetFactory != NULL )
+    {
+        factoryxmlfile = ( factoryxmlfile.substr(0,1) == "/" ) ? factoryxmlfile : dir + "/" + factoryxmlfile;
+        m_pLabeledSetFactory->createLabeledSetFromXml( factoryxmlfile, datasetconf,classnames, ls );
+    }
+    else {
+		fprintf (stderr, "LabeledFileList: Unable to obtain labeled file list\n");
+		exit(-1);
+    }
+=======
+    std::string cfilelist = datasetconf.gS ( "main", "filelist" );
+    std::string filelist = ( cfilelist.substr ( 0, 1 ) == "/" ) ? cfilelist : dir + "/" + cfilelist;
+
+    getFromList ( filelist, datasetconf, classnames, ls, localizationInfoDisabled );
+  } else {
+    fprintf ( stderr, "LabeledFileList: Unable to obtain labeled file list\n" );
+    exit ( -1 );
+  }
+>>>>>>> 58806271b9d9e859d773707495a6097dddd86924
+}

+ 9 - 8
cbaselib/LabeledFileList.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file LabeledFileList.h
 * @brief reads images from directory
 * @author Erik Rodner
@@ -24,8 +24,8 @@ namespace OBJREC {
  */
 class LabeledFileList
 {
-    private:
-	bool debug_dataset;
+  private:
+    bool debug_dataset;
 
     LabeledSetFactory *m_pLabeledSetFactory;
 
@@ -66,11 +66,12 @@ class LabeledFileList
 		   LabeledSet & ls,
 		   bool localizationInfoDisabled = false ) const;
 
-	void getFromList ( const std::string & filelist,
-		   const NICE::Config & datasetconf,
-		   const ClassNames & classnames, 
-		   LabeledSet & ls,
-		   bool localizationInfoDisabled = false ) const;
+
+    void getFromList ( const std::string & filelist,
+                       const NICE::Config & datasetconf,
+                       const ClassNames & classnames,
+                       LabeledSet & ls,
+                       bool localizationInfoDisabled = false ) const;
 
 
     void setFactory(LabeledSetFactory *pLabeledSetFactory)

+ 107 - 0
cbaselib/LabeledFileList.h~

@@ -0,0 +1,107 @@
+/**
+* @file LabeledFileList.h
+* @brief reads images from directory
+* @author Erik Rodner
+* @date 17.09.2007
+*/
+#ifndef LabeledFileListINCLUDE
+#define LabeledFileListINCLUDE
+
+#include <string>
+
+#include "core/basics/Config.h"
+#include "vislearning/baselib/ProgressBar.h"
+
+#include "ClassNames.h"
+#include "LocalizationResult.h"
+#include "LabeledSet.h"
+#include "LabeledSetFactory.h"
+
+namespace OBJREC {
+
+/**
+ * @brief reads images from directory
+ */
+class LabeledFileList
+{
+  private:
+    bool debug_dataset;
+
+    LabeledSetFactory *m_pLabeledSetFactory;
+
+    public:
+  
+	/** simple constructor */
+	LabeledFileList(); 
+      
+	/** simple destructor */
+	virtual ~LabeledFileList();
+ 
+	LocalizationResult *getLocalizationInfo ( const ClassNames & classnames,
+					    int classno,
+					    const std::string & file,
+					    const NICE::Config & conf ) const;
+
+    /**
+    * @brief extract multiple label information from different sources.
+    *
+    * Different sources specified in the logfile under section "main":
+    *-"pattern" <br>
+    *-"filelist" <br>
+    *-"factoryxml" <br>
+    *  xml file whose information is extracted and inserted into a LabeledSet. In order to use the right xml loader, a factory had to be provided
+    * ( ::setFactory() ). [Johannes Ruehle]
+    * @see LabeledSetFactory
+    */
+	void get ( const std::string & dir,
+		   const NICE::Config & datasetconf,
+		   const ClassNames & classnames, 
+		   LabeledSet & ls,
+		   bool localizationInfoDisabled = false,
+		   bool debugDataset = false );
+		   
+	void getFromPattern ( const std::string & dir,
+		   const NICE::Config & datasetconf,
+		   const ClassNames & classnames, 
+		   LabeledSet & ls,
+		   bool localizationInfoDisabled = false ) const;
+
+    /** simple destructor */
+    virtual ~LabeledFileList();
+
+    LocalizationResult *getLocalizationInfo ( const ClassNames & classnames,
+        int classno,
+        const std::string & file,
+        const NICE::Config & conf ) const;
+
+    void get ( const std::string & dir,
+               const NICE::Config & datasetconf,
+               const ClassNames & classnames,
+               LabeledSet & ls,
+               bool localizationInfoDisabled = false,
+               bool debugDataset = false );
+
+    void getFromPattern ( const std::string & dir,
+                          const NICE::Config & datasetconf,
+                          const ClassNames & classnames,
+                          LabeledSet & ls,
+                          bool localizationInfoDisabled = false ) const;
+
+    void getFromList ( const std::string & filelist,
+                       const NICE::Config & datasetconf,
+                       const ClassNames & classnames,
+                       LabeledSet & ls,
+                       bool localizationInfoDisabled = false ) const;
+
+
+    void setFactory(LabeledSetFactory *pLabeledSetFactory)
+    {
+         m_pLabeledSetFactory = pLabeledSetFactory;
+    }
+
+};
+
+
+} // namespace
+
+#endif

+ 267 - 265
cbaselib/MultiDataset.cpp

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file MultiDataset.cpp
 * @brief multiple datasets
 * @author Erik Rodner
@@ -25,308 +25,310 @@ using namespace NICE;
 #undef DEBUG_MultiDataset
 
 void MultiDataset::selectExamples ( const std::string & examples_command,
-		      const LabeledSet & base,
-		      LabeledSet & positives,
-		      LabeledSet & negatives,
-		      const ClassNames & cn ) const
+                                    const LabeledSet & base,
+                                    LabeledSet & positives,
+                                    LabeledSet & negatives,
+                                    const ClassNames & cn ) const
 {
-    vector<string> examples;
-    StringTools::split ( examples_command, ';', examples );
-    set<int> processed_classes;
-
-    for ( vector<string>::const_iterator i  = examples.begin();
-					 i != examples.end();
-					 i++ )
+  vector<string> examples;
+  StringTools::split ( examples_command, ';', examples );
+  set<int> processed_classes;
+
+  for ( vector<string>::const_iterator i  = examples.begin();
+        i != examples.end();
+        i++ )
+  {
+    const std::string & cmd = *i;
+    vector<string> parts;
+    StringTools::split ( cmd, ' ', parts );
+
+    if ( (parts.size() != 3) && ((parts.size() != 2) || (parts[0] != "all")) )
+      fthrow( Exception, "Syntax error " << examples_command );
+
+    const std::string & mode = parts[0];
+    const std::string & csel = parts[1];
+    double parameter = (parts.size() == 3 ) ? atof(parts[2].c_str()) : 0.0;
+    map<int, int> fpe;
+
+    set<int> selection;
+    cn.getSelection ( csel, selection );
+    for ( set<int>::const_iterator j  = selection.begin();
+          j != selection.end();
+          j++ )
     {
-		const std::string & cmd = *i;
-		vector<string> parts;
-		StringTools::split ( cmd, ' ', parts );
-		
-		if ( (parts.size() != 3) && ((parts.size() != 2) || (parts[0] != "all")) ) 
-			fthrow( Exception, "Syntax error " << examples_command );
-		
-		const std::string & mode = parts[0];
-		const std::string & csel = parts[1];
-		double parameter = (parts.size() == 3 ) ? atof(parts[2].c_str()) : 0.0;
-		map<int, int> fpe;
-
-		set<int> selection;
-		cn.getSelection ( csel, selection );
-		for ( set<int>::const_iterator j  = selection.begin();
-						   j != selection.end();
-						   j++ )
-		{
-			int classno = *j;
-			if ( processed_classes.find(classno) == processed_classes.end() )
-			{
+      int classno = *j;
+      if ( processed_classes.find(classno) == processed_classes.end() )
+      {
 #ifdef DEBUG_MultiDataset
-				fprintf (stderr, "class %s: %s %d\n", cn.text(classno).c_str(),
-					mode.c_str(), (int)parameter );
+        fprintf (stderr, "class %s: %s %d\n", cn.text(classno).c_str(),
+                 mode.c_str(), (int)parameter );
 #endif
-				fpe[*j] = (int)parameter;
-				processed_classes.insert(classno);
-			} else {
-				if ( csel != "*" ) {
-					fthrow ( Exception, "Example selection method for class %s has multiple specifications" << cn.text(classno) );
-				}
-			}
-		}
-
-		if ( mode == "seq" ) {
-			LabeledSetSelection<LabeledSet>::selectSequential ( 
-			fpe, base, positives, negatives );   
+        fpe[*j] = (int)parameter;
+        processed_classes.insert(classno);
+      } else {
+        if ( csel != "*" ) {
+          fthrow ( Exception, "Example selection method for class %s has multiple specifications" << cn.text(classno) );
+        }
+      }
+    }
+
+    if ( mode == "seq" ) {
+      LabeledSetSelection<LabeledSet>::selectSequential (
+        fpe, base, positives, negatives );
 #ifdef DEBUG_MultiDataset
-			fprintf (stderr, "MultiDataset: after special seq selection: %d\n", positives.count() );
+      fprintf (stderr, "MultiDataset: after special seq selection: %d\n", positives.count() );
 #endif
-		} else if ( mode == "step" ) {
-			LabeledSetSelection<LabeledSet>::selectSequentialStep ( 
-			fpe, base, positives, negatives );   
+    } else if ( mode == "step" ) {
+      LabeledSetSelection<LabeledSet>::selectSequentialStep (
+        fpe, base, positives, negatives );
 #ifdef DEBUG_MultiDataset
-			fprintf (stderr, "MultiDataset: after special step selection: %d\n", positives.count() );
+      fprintf (stderr, "MultiDataset: after special step selection: %d\n", positives.count() );
 #endif
-		} else if ( mode == "random" ) {
-			LabeledSetSelection<LabeledSet>::selectRandom ( 
-			fpe, base, positives, negatives );   
+    } else if ( mode == "random" ) {
+      LabeledSetSelection<LabeledSet>::selectRandom (
+        fpe, base, positives, negatives );
 #ifdef DEBUG_MultiDataset
-			fprintf (stderr, "MultiDataset: after special random selection: %d\n", positives.count() );
+      fprintf (stderr, "MultiDataset: after special random selection: %d\n", positives.count() );
 #endif
-		} else if ( mode == "all" ) {
-			if ( (int)selection.size() == cn.numClasses() ) 
-			{
-				// preserve permutation
-				LabeledSet::Permutation permutation;
-				base.getPermutation ( permutation );
-				for ( LabeledSet::Permutation::iterator i = permutation.begin(); i != permutation.end(); i++ )
-				{
-					int classno = i->first;
-					ImageInfo *element = const_cast< ImageInfo * > ( i->second );
-					positives.add_reference ( classno, element );
-				}
-			} else {
-				LabeledSetSelection<LabeledSet>::selectClasses ( selection, base, positives, negatives );
-			}
+    } else if ( mode == "all" ) {
+      if ( (int)selection.size() == cn.numClasses() )
+      {
+        // preserve permutation
+        LabeledSet::Permutation permutation;
+        base.getPermutation ( permutation );
+        for ( LabeledSet::Permutation::iterator i = permutation.begin(); i != permutation.end(); i++ )
+        {
+          int classno = i->first;
+          ImageInfo *element = const_cast< ImageInfo * > ( i->second );
+          positives.add_reference ( classno, element );
+        }
+      } else {
+        LabeledSetSelection<LabeledSet>::selectClasses ( selection, base, positives, negatives );
+      }
 #ifdef DEBUG_MultiDataset
-			fprintf (stderr, "MultiDataset: after special class selection: %d\n", positives.count() );
+      fprintf (stderr, "MultiDataset: after special class selection: %d\n", positives.count() );
 #endif
-		} else {
-			fthrow ( Exception, "Wrong value for parameter example\n");
-		}
+    } else {
+      fthrow ( Exception, "Wrong value for parameter example\n");
     }
+  }
 
 #ifdef DEBUG_MultiDataset
-    fprintf (stderr, "MultiDataset: after special selection operations: %d\n", positives.count() );
+  fprintf (stderr, "MultiDataset: after special selection operations: %d\n", positives.count() );
 #endif
-    
-    set<int> allclasses;
-    cn.getSelection ( "*", allclasses );
 
-    set<int> allnegative_classes;
+  set<int> allclasses;
+  cn.getSelection ( "*", allclasses );
 
-    // add all examples from allclasses \setminus processed_classes
-    set_difference(allclasses.begin(), allclasses.end(), processed_classes.begin(), processed_classes.end(),
-                      inserter(allnegative_classes, allnegative_classes.end()));
+  set<int> allnegative_classes;
 
-    LabeledSet dummy;
-    LabeledSetSelection<LabeledSet>::selectClasses ( allnegative_classes, 
-	base, negatives, dummy );
+  // add all examples from allclasses \setminus processed_classes
+  set_difference(allclasses.begin(), allclasses.end(), processed_classes.begin(), processed_classes.end(),
+                 inserter(allnegative_classes, allnegative_classes.end()));
+
+  LabeledSet dummy;
+  LabeledSetSelection<LabeledSet>::selectClasses ( allnegative_classes,
+      base, negatives, dummy );
 
 }
 
 /** MultiDataset ------- constructor */
 MultiDataset::MultiDataset( const Config *conf , LabeledSetFactory *pSetFactory)
 {
-    std::set<string> blocks;
-    conf->getAllBlocks ( blocks );
+  std::set<string> blocks;
+  conf->getAllBlocks ( blocks );
 
-    lfl.setFactory( pSetFactory );
+  lfl.setFactory( pSetFactory );
 
-    map<string, Config> dsconfs;
-    map<string, string> dirs;
-    for ( set<string>::iterator i = blocks.begin();
-	    i != blocks.end();  )
+  map<string, Config> dsconfs;
+  map<string, string> dirs;
+  for ( set<string>::iterator i = blocks.begin();
+        i != blocks.end();  )
+  {
+    if ( conf->gB(*i, "disable", false) )
     {
-		if ( conf->gB(*i, "disable", false) )
-		{
-			i++;
-			continue;
-		}
-
-		std::string dataset = conf->gS( *i, "dataset", "unknown" );
-		if ( dataset == "unknown" )
-			blocks.erase(i++);
-		else {
+      i++;
+      continue;
+    }
+
+    std::string dataset = conf->gS( *i, "dataset", "unknown" );
+    if ( dataset == "unknown" )
+      blocks.erase(i++);
+    else {
 #ifdef DEBUG_MultiDataset
-			fprintf (stderr, "Reading dataset config for block [%s]\n", i->c_str() );
+      fprintf (stderr, "Reading dataset config for block [%s]\n", i->c_str() );
 #endif
-			Config dsconf ( (dataset + "/dataset.conf").c_str() );
-			
-			dirs[*i] = dataset;
-			dsconfs[*i] = dsconf;
-			i++;
-		}
+      Config dsconf ( (dataset + "/dataset.conf").c_str() );
+
+      dirs[*i] = dataset;
+      dsconfs[*i] = dsconf;
+      i++;
     }
-  
-    if ( blocks.find("traintest") != blocks.end() )
+  }
+
+  if ( blocks.find("traintest") != blocks.end() )
+  {
+    LabeledSet ls_base;
+    LabeledSet ls_train (true);
+    LabeledSet ls_nontrain (true);
+    LabeledSet ls_test (true);
+    LabeledSet dummy (true);
+    LabeledSet temp (true);
+
+
+    bool localizationInfoDisabled = conf->gB("traintest", "disable_localization_info", false );
+
+    std::string classselection_train = conf->gS("traintest", "classselection_train", "*");
+    std::string classselection_test = conf->gS("traintest", "classselection_test", "*");
+    classnames["traintest"] = ClassNames();
+
+    std::string classNamesTxt = dirs["traintest"] + "/classnames.txt";
+    if ( FileMgt::fileExists ( classNamesTxt ) )
     {
-		LabeledSet ls_base;
-		LabeledSet ls_train (true);
-		LabeledSet ls_nontrain (true);
-		LabeledSet ls_test (true);
-		LabeledSet dummy (true);
-		LabeledSet temp (true);
-
-		bool localizationInfoDisabled = conf->gB("traintest", "disable_localization_info", false );
-
-		std::string classselection_train = conf->gS("traintest", "classselection_train", "*");
-		std::string classselection_test = conf->gS("traintest", "classselection_test", "*");
-		classnames["traintest"] = ClassNames();
-		
-		std::string classNamesTxt = dirs["traintest"] + "/classnames.txt";
-		if ( FileMgt::fileExists ( classNamesTxt ) )
-		{
-			classnames["traintest"].read ( classNamesTxt );
-		} else {
-			classnames["traintest"].readFromConfig ( dsconfs["traintest"], classselection_train );
-		}
-		
-        lfl.get ( dirs["traintest"], dsconfs["traintest"], classnames["traintest"], ls_base,
-			localizationInfoDisabled, conf->gB("traintest", "debug_dataset", false ) ); 
-
-		std::string examples_train =  conf->gS("traintest", "examples_train" );
-		selectExamples ( examples_train, ls_base, ls_train, ls_nontrain, classnames["traintest"] );
-			
-		set<int> selection_test;
-		classnames["traintest"].getSelection ( classselection_test, selection_test );
-
-		std::string examples_test =  conf->gS("traintest", "examples_test" );
-		if ( examples_test == "reclassification" )
-		{
-			LabeledSetSelection<LabeledSet>::selectClasses 
-			( selection_test, ls_train, ls_test, dummy );
-
-		} else {
-			selectExamples ( examples_test, ls_nontrain, temp, dummy, classnames["traintest"] );
-			LabeledSetSelection<LabeledSet>::selectClasses 
-			( selection_test, temp, ls_test, dummy );
-		}
-
-		classnames["train"] = classnames["traintest"];
-		classnames["test"] = ClassNames ( classnames["traintest"], classselection_test );
-		datasets["test"] = ls_test;
-		datasets["train"] = ls_train;
+        classnames["traintest"].read ( classNamesTxt );
+    } else {
+        classnames["traintest"].readFromConfig ( dsconfs["traintest"], classselection_train );
     }
 
-    for ( set<string>::const_iterator i = blocks.begin();
-				      i != blocks.end();
-				      i++ )
+    lfl.get ( dirs["traintest"], dsconfs["traintest"], classnames["traintest"], ls_base,
+        localizationInfoDisabled, conf->gB("traintest", "debug_dataset", false ) );
+
+    std::string examples_train =  conf->gS("traintest", "examples_train" );
+    selectExamples ( examples_train, ls_base, ls_train, ls_nontrain, classnames["traintest"] );
+
+    set<int> selection_test;
+    classnames["traintest"].getSelection ( classselection_test, selection_test );
+
+    std::string examples_test =  conf->gS("traintest", "examples_test" );
+    if ( examples_test == "reclassification" )
     {
-		std::string name = *i;
-		if ( classnames.find(name) != classnames.end() )
-			continue;
+      LabeledSetSelection<LabeledSet>::selectClasses
+      ( selection_test, ls_train, ls_test, dummy );
+
+    } else {
+      selectExamples ( examples_test, ls_nontrain, temp, dummy, classnames["traintest"] );
+      LabeledSetSelection<LabeledSet>::selectClasses
+      ( selection_test, temp, ls_test, dummy );
+    }
 
-		if ( conf->gB(name, "disable", false) == true )
-			continue;
+    classnames["train"] = classnames["traintest"];
+    classnames["test"] = ClassNames ( classnames["traintest"], classselection_test );
+    datasets["test"] = ls_test;
+    datasets["train"] = ls_train;
+  }
 
-		if ( dsconfs.find(name) == dsconfs.end() )
-			continue;
+  for ( set<string>::const_iterator i = blocks.begin();
+        i != blocks.end();
+        i++ )
+  {
+    std::string name = *i;
+    if ( classnames.find(name) != classnames.end() )
+      continue;
 
-		LabeledSet ls_base;
-		LabeledSet ls (true);
-		LabeledSet dummy (true);
-		LabeledSet temp (true);
+    if ( conf->gB(name, "disable", false) == true )
+      continue;
 
-		bool localizationInfoDisabled = conf->gB(name, "disable_localization_info", false );
+    if ( dsconfs.find(name) == dsconfs.end() )
+      continue;
 
-		std::string classselection = conf->gS(name, "classselection", "*");
-		classnames[name] = ClassNames();
+    LabeledSet ls_base;
+    LabeledSet ls (true);
+    LabeledSet dummy (true);
+    LabeledSet temp (true);
 
-		std::string classNamesTxt = dirs[name] + "/classnames.txt";
-		if ( FileMgt::fileExists ( classNamesTxt ) )
-		{
+    bool localizationInfoDisabled = conf->gB(name, "disable_localization_info", false );
+
+    std::string classselection = conf->gS(name, "classselection", "*");
+    classnames[name] = ClassNames();
+
+    std::string classNamesTxt = dirs[name] + "/classnames.txt";
+    if ( FileMgt::fileExists ( classNamesTxt ) )
+    {
 #ifdef DEBUG_MultiDataset
-			fprintf (stderr, "MultiDataset: reading class names from %s\n", classNamesTxt.c_str() );
+      fprintf (stderr, "MultiDataset: reading class names from %s\n", classNamesTxt.c_str() );
 #endif
-			classnames[name].read ( classNamesTxt );
-		} else {
+      classnames[name].read ( classNamesTxt );
+    } else {
 #ifdef DEBUG_MultiDataset
-			fprintf (stderr, "MultiDataset: reading class names from dataset config file\n" );
+      fprintf (stderr, "MultiDataset: reading class names from dataset config file\n" );
 #endif
-			classnames[name].readFromConfig ( dsconfs[name], classselection );
-		}
+        classnames[name].readFromConfig ( dsconfs[name], classselection );
+    }
 		
 
-        lfl.get (   dirs[name],
-                    dsconfs[name],
-                    classnames[name],
-                    ls_base,
-                    localizationInfoDisabled,
-                    conf->gB(name, "debug_dataset", false ) );
+    lfl.get (   dirs[name],
+                dsconfs[name],
+                classnames[name],
+                ls_base,
+                localizationInfoDisabled,
+                conf->gB(name, "debug_dataset", false ) );
+
 
 #ifdef DEBUG_MultiDataset
-		fprintf (stderr, "MultiDataset: class names -->\n" );
-		classnames[name].store ( cerr );
-		fprintf (stderr, "MultiDataset: all information about %s set obtained ! (size %d)\n", name.c_str(), ls_base.count() );
+    fprintf (stderr, "MultiDataset: class names -->\n" );
+    classnames[name].store ( cerr );
+    fprintf (stderr, "MultiDataset: all information about %s set obtained ! (size %d)\n", name.c_str(), ls_base.count() );
 #endif
 
-		std::string examples = conf->gS(name, "examples", "all *" );
-		selectExamples ( examples, ls_base, ls, dummy, classnames[name] );
-		
+    std::string examples = conf->gS(name, "examples", "all *" );
+    selectExamples ( examples, ls_base, ls, dummy, classnames[name] );
+
 #ifdef DEBUG_MultiDataset
-		fprintf (stderr, "MultiDataset: size after selection %d\n", ls.count() );
+    fprintf (stderr, "MultiDataset: size after selection %d\n", ls.count() );
 #endif
 
-		datasets[name] = ls;
-    }
+    datasets[name] = ls;
+  }
 
-    bool dumpSelections = conf->gB("datasets", "dump_selection", false);
-    if ( dumpSelections )
+  bool dumpSelections = conf->gB("datasets", "dump_selection", false);
+  if ( dumpSelections )
+  {
+    for ( map<string, LabeledSet>::const_iterator i = datasets.begin();
+          i != datasets.end(); i++ )
     {
-		for ( map<string, LabeledSet>::const_iterator i = datasets.begin();
-			i != datasets.end(); i++ )
-		{
-			const std::string & name = i->first;
-			const LabeledSet & ls = i->second;
-			const ClassNames & classNames = classnames[name];
-
-			mkdir ( name.c_str(), 0755 );
-
-			std::string filelist = name + "/files.txt";
-			ofstream olist ( filelist.c_str(), ios::out );
-			if ( !olist.good() )
-				fthrow (IOException, "Unable to dump selections to " << filelist );
-			
-			LOOP_ALL_S(ls)
-			{
-				EACH_S(classno, file);
-				std::string classtext = classNames.code(classno);
-				olist << classtext << " " << file << endl;
-			}
-			olist.close();
-
-			std::string datasetconf = name + "/dataset.conf";
-			ofstream oconf ( datasetconf.c_str(), ios::out );
-			if ( !oconf.good() )
-				fthrow (IOException, "Unable to dump selections to " << datasetconf );
-
-			set<int> classnos;
-			classNames.getSelection ( "*", classnos);
-
-			oconf << "[main]" << endl;
-			oconf << "filelist = \"files.txt\"" << endl << endl;
-
-			oconf << "[classnames]" << endl;
-			for ( set<int>::const_iterator i = classnos.begin();
-					i != classnos.end(); i++ )
-			{
-				const std::string & code = classNames.code(*i);
-				const std::string & text = classNames.text(*i);
-				oconf << code << "     =     \"" << text << "\"" << endl;
-			}
-			oconf.close();
-			
-			classNames.save ( name + "/classnames.txt" );
-		}
+      const std::string & name = i->first;
+      const LabeledSet & ls = i->second;
+      const ClassNames & classNames = classnames[name];
+
+      mkdir ( name.c_str(), 0755 );
+
+      std::string filelist = name + "/files.txt";
+      ofstream olist ( filelist.c_str(), ios::out );
+      if ( !olist.good() )
+        fthrow (IOException, "Unable to dump selections to " << filelist );
+
+      LOOP_ALL_S(ls)
+      {
+        EACH_S(classno, file);
+        std::string classtext = classNames.code(classno);
+        olist << classtext << " " << file << endl;
+      }
+      olist.close();
+
+      std::string datasetconf = name + "/dataset.conf";
+      ofstream oconf ( datasetconf.c_str(), ios::out );
+      if ( !oconf.good() )
+        fthrow (IOException, "Unable to dump selections to " << datasetconf );
+
+      set<int> classnos;
+      classNames.getSelection ( "*", classnos);
+
+      oconf << "[main]" << endl;
+      oconf << "filelist = \"files.txt\"" << endl << endl;
+
+      oconf << "[classnames]" << endl;
+      for ( set<int>::const_iterator i = classnos.begin();
+            i != classnos.end(); i++ )
+      {
+        const std::string & code = classNames.code(*i);
+        const std::string & text = classNames.text(*i);
+        oconf << code << "     =     \"" << text << "\"" << endl;
+      }
+      oconf.close();
+
+      classNames.save ( name + "/classnames.txt" );
     }
+  }
 
 }
 
@@ -336,32 +338,32 @@ MultiDataset::~MultiDataset()
 
 const ClassNames & MultiDataset::getClassNames ( const std::string & key ) const
 {
-    map<string, ClassNames>::const_iterator i = classnames.find(key);
-    if ( i == classnames.end() )
-    {
-	fprintf (stderr, "MultiDataSet::getClassNames() FATAL ERROR: dataset <%s> not found !\n", key.c_str() );
-	exit(-1);
-    } 
-    return (i->second);
+  map<string, ClassNames>::const_iterator i = classnames.find(key);
+  if ( i == classnames.end() )
+  {
+    fprintf (stderr, "MultiDataSet::getClassNames() FATAL ERROR: dataset <%s> not found !\n", key.c_str() );
+    exit(-1);
+  }
+  return (i->second);
 
 }
 
 const LabeledSet *MultiDataset::operator[] ( const std::string & key ) const
 {
-    map<string, LabeledSet>::const_iterator i = datasets.find(key);
-    if ( i == datasets.end() )
-    {
-	fprintf (stderr, "MultiDataSet: FATAL ERROR: dataset <%s> not found !\n", key.c_str() );
-	exit(-1);
-    } 
-    return &(i->second);
+  map<string, LabeledSet>::const_iterator i = datasets.find(key);
+  if ( i == datasets.end() )
+  {
+    fprintf (stderr, "MultiDataSet: FATAL ERROR: dataset <%s> not found !\n", key.c_str() );
+    exit(-1);
+  }
+  return &(i->second);
 }
 
 const LabeledSet *MultiDataset::at ( const std::string & key ) const
 {
-    map<string, LabeledSet>::const_iterator i = datasets.find(key);
-    if ( i == datasets.end() )
-	return NULL;
-    else
-	return &(i->second);
+  map<string, LabeledSet>::const_iterator i = datasets.find(key);
+  if ( i == datasets.end() )
+    return NULL;
+  else
+    return &(i->second);
 }

+ 16 - 16
cbaselib/MultiDataset.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file MultiDataset.h
 * @brief multiple datasets
 * @author Erik Rodner
@@ -28,16 +28,16 @@ namespace OBJREC {
 class MultiDataset
 {
 
-    protected:
-	LabeledFileList lfl;
-	std::map<std::string, ClassNames> classnames;
-	std::map<std::string, LabeledSet> datasets;
+protected:
+    LabeledFileList lfl;
+    std::map<std::string, ClassNames> classnames;
+    std::map<std::string, LabeledSet> datasets;
 
-	void selectExamples ( const std::string & examples_command,
-		      const LabeledSet & base,
-		      LabeledSet & positives,
-		      LabeledSet & negatives,
-		      const ClassNames & cn ) const;
+    void selectExamples ( const std::string & examples_command,
+                          const LabeledSet & base,
+                          LabeledSet & positives,
+                          LabeledSet & negatives,
+                          const ClassNames & cn ) const;
 
     public:
   
@@ -52,14 +52,14 @@ class MultiDataset
 	/** simple destructor */
 	virtual ~MultiDataset();
     
-  /** access class information, e.g., md.getClassNames("train") */
-	const ClassNames & getClassNames ( const std::string & key ) const;
+    /** access class information, e.g., md.getClassNames("train") */
+    const ClassNames & getClassNames ( const std::string & key ) const;
 
-  /** access stored dataset by name, e.g., md["train"], if you have a [train] section
-    * in your config file */
-	const LabeledSet * operator[] ( const std::string & key ) const;
+    /** access stored dataset by name, e.g., md["train"], if you have a [train] section
+      * in your config file */
+    const LabeledSet * operator[] ( const std::string & key ) const;
 
-	const LabeledSet * at ( const std::string & key ) const;
+    const LabeledSet * at ( const std::string & key ) const;
 
 };
 

+ 49 - 47
cbaselib/progs/testCachedExample.cpp

@@ -1,9 +1,8 @@
-/** 
+/**
 * @file testCachedExample.cpp
 * @brief test cached example implementation
 * @author Erik Rodner
 * @date 09/12/2008
-
 */
 
 #include <core/imagedisplay/ImageDisplay.h>
@@ -19,61 +18,64 @@ using namespace NICE;
 using namespace std;
 
 
-int main (int argc, char **argv)
-{   
-    std::set_terminate(__gnu_cxx::__verbose_terminate_handler);
+int main ( int argc, char **argv )
+{
+  std::set_terminate ( __gnu_cxx::__verbose_terminate_handler );
 
-    char configfile [300];
+  char configfile [300];
 
-    struct CmdLineOption options[] = {
-	{"config", "use config file", NULL, "%s", configfile},
-	{NULL, NULL, NULL, NULL, NULL} 
-    };
-    int ret;
-    char *more_options[argc];
-    ret = parse_arguments( argc, (const char**)argv, options, more_options);
+  struct CmdLineOption options[] = {
+    {"config", "use config file", NULL, "%s", configfile},
+    {NULL, NULL, NULL, NULL, NULL}
+  };
+  int ret;
+  char *more_options[argc];
+  ret = parse_arguments ( argc, ( const char** ) argv, options, more_options );
 
-    if ( ret != 0 )
-    {
-	if ( ret != 1 ) fprintf (stderr, "Error parsing command line !\n");
-	exit (-1);
-    }
+  if ( ret != 0 )
+  {
+    if ( ret != 1 ) fprintf ( stderr, "Error parsing command line !\n" );
+    exit ( -1 );
+  }
 
-    Config conf ( configfile );
-    
-    int i = 0;
-    while ( more_options[i] != NULL )
-    {
+  Config conf ( configfile );
 
-	std::string filename ( more_options[i] );
-	fprintf (stderr, "Filename: %s\n", filename.c_str() );
-	CachedExample ce ( filename );
+  int i = 0;
+  while ( more_options[i] != NULL )
+  {
 
-	NICE::MultiChannelImageT<int> & img = ce.getIChannel(CachedExample::I_COLOR);
-	NICE::MultiChannelImageT<double> & imgc = ce.getDChannel(CachedExample::D_INTEGRALCOLOR);
+    std::string filename ( more_options[i] );
+    fprintf ( stderr, "Filename: %s\n", filename.c_str() );
+    CachedExample ce ( filename );
 
-	imgc.reInitFrom ( img, true );
-	for ( uint j = 0 ; j < img.numChannels; j++ )
-	    GenericImageTools::calcIntegralImage ( imgc.data[j], img.data[j], img.xsize, img.ysize );
+    NICE::MultiChannelImageT<int> & img = ce.getIChannel ( CachedExample::I_COLOR );
+    NICE::MultiChannelImageT<double> & imgc = ce.getDChannel ( CachedExample::D_INTEGRALCOLOR );
+
+    imgc.reInitFrom ( img );
+    for ( uint j = 0 ; j < img.channels(); j++ )
+    {
+      ImageT<double> tmp = imgc[j];
+      GenericImageTools::calcIntegralImage ( tmp, img[j], img.width(), img.height() );
+    }
 
-	Image visimg = imgc.getChannel(0);
-	showImage(visimg);
+    Image visimg = imgc.getChannel ( 0 );
+    showImage ( visimg );
 
-	ce.dropPreCached();
+    ce.dropPreCached();
 
 #ifndef NOVISUAL
-	getchar();
+    getchar();
 #endif
-	
-	imgc = ce.getDChannel ( CachedExample::D_INTEGRALCOLOR );
-	
-	visimg = imgc.getChannel(0);
-	showImage(visimg);
-	
-
-	i++;
-    }
-    
-    
-    return 0;
+
+    imgc = ce.getDChannel ( CachedExample::D_INTEGRALCOLOR );
+
+    visimg = imgc.getChannel ( 0 );
+    showImage ( visimg );
+
+
+    i++;
+  }
+
+
+  return 0;
 }

+ 51 - 57
cbaselib/progs/testLabeledSet.cpp

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file testLabeledSet.cpp
 * @brief test multidataset
 * @author Erik Rodner
@@ -15,65 +15,59 @@
 #include <vislearning/cbaselib/MultiDataset.h>
 
 using namespace OBJREC;
-
-
-
-// refactor-nice.pl: check this substitution
-// old: using namespace ice;
 using namespace NICE;
 using namespace std;
 
 
-/** 
-    
-    test multidataset 
-    
+/**
+
+    test multidataset
+
 */
-int main (int argc, char **argv)
-{   
-    std::set_terminate(__gnu_cxx::__verbose_terminate_handler);
-
-    char configfile [300];
-
-    struct CmdLineOption options[] = {
-	{"config", "use config file", NULL, "%s", configfile},
-	{NULL, NULL, NULL, NULL, NULL} 
-    };
-    int ret;
-    char *more_options[argc];
-    ret = parse_arguments( argc, (const char**)argv, options, more_options);
-
-    if ( ret != 0 )
-    {
-	if ( ret != 1 ) fprintf (stderr, "Error parsing command line !\n");
-	exit (-1);
-    }
-
-    Config conf ( configfile );
-    
-    
-    MultiDataset md ( &conf );
-
-    const LabeledSet *train = md["train"];
-    const LabeledSet *test = md["test"];
-    const ClassNames & cn = md.getClassNames ( "train" );
-    
-    
-    fprintf (stderr, "Training Dataset\n");
-    LOOP_ALL_S( *train )
-    {
-	EACH_S(classno, fn);
-	fprintf (stderr, "%s %s\n", cn.text(classno).c_str(), fn.c_str() );
-    }
- 
-    fprintf (stderr, "Test Dataset\n");
-    LOOP_ALL_S( *test )
-    {
-	EACH_S(classno, fn);
-	fprintf (stderr, "%s %s\n", cn.text(classno).c_str(), fn.c_str() );
-    }
-   
-    
-    
-    return 0;
+int main ( int argc, char **argv )
+{
+  std::set_terminate ( __gnu_cxx::__verbose_terminate_handler );
+
+  char configfile [300];
+
+  struct CmdLineOption options[] = {
+    {"config", "use config file", NULL, "%s", configfile},
+    {NULL, NULL, NULL, NULL, NULL}
+  };
+  int ret;
+  char *more_options[argc];
+  ret = parse_arguments ( argc, ( const char** ) argv, options, more_options );
+
+  if ( ret != 0 )
+  {
+    if ( ret != 1 ) fprintf ( stderr, "Error parsing command line !\n" );
+    exit ( -1 );
+  }
+
+  Config conf ( configfile );
+
+  MultiDataset md ( &conf );
+
+  const LabeledSet *train = md["train"];
+  const LabeledSet *test = md["test"];
+  const ClassNames & cn = md.getClassNames ( "train" );
+
+
+  fprintf ( stderr, "Training Dataset\n" );
+  LOOP_ALL_S ( *train )
+  {
+    EACH_S ( classno, fn );
+    fprintf ( stderr, "%s %s\n", cn.text ( classno ).c_str(), fn.c_str() );
+  }
+
+  fprintf ( stderr, "Test Dataset\n" );
+  LOOP_ALL_S ( *test )
+  {
+    EACH_S ( classno, fn );
+    fprintf ( stderr, "%s %s\n", cn.text ( classno ).c_str(), fn.c_str() );
+  }
+
+
+
+  return 0;
 }

+ 2 - 0
classifier/classifiercombination/VCPreRandomForest.cpp

@@ -12,6 +12,8 @@
 
 #include <vislearning/cbaselib/VectorFeature.h>
 
+#include "core/image/ImageT.h"
+//#include "core/imagedisplay/ImageDisplay.h"
 
 using namespace OBJREC;
 using namespace std;

+ 0 - 2
classifier/classifiercombination/VCPreRandomForest.h

@@ -9,8 +9,6 @@
 
 #include "core/vector/VectorT.h"
 #include "core/vector/MatrixT.h"
-#include "core/image/ImageT.h"
-#include "core/imagedisplay/ImageDisplay.h"
 
 #include <map>
 

+ 2 - 0
classifier/classifierinterfaces/VCFeaturePool.cpp

@@ -9,6 +9,8 @@
 
 #include "VCFeaturePool.h"
 #include "vislearning/cbaselib/VectorFeature.h"
+#include "core/image/ImageT.h"
+//#include "core/imagedisplay/ImageDisplay.h"
 
 using namespace OBJREC;
 

+ 0 - 2
classifier/classifierinterfaces/VCFeaturePool.h

@@ -10,8 +10,6 @@
 
 #include "core/vector/VectorT.h"
 #include "core/vector/MatrixT.h"
-#include "core/image/ImageT.h"
-#include "core/imagedisplay/ImageDisplay.h"
 
 #include <string>
 

+ 4 - 2
classifier/fpclassifier/logisticregression/FPCSMLR.cpp

@@ -1,6 +1,9 @@
 #include "vislearning/classifier/fpclassifier/logisticregression/FPCSMLR.h"
 #include "vislearning/cbaselib/FeaturePool.h"
 
+#include "core/image/ImageT.h"
+//#include "core/imagedisplay/ImageDisplay.h"
+
 #include <iostream>
 
 using namespace OBJREC;
@@ -25,8 +28,7 @@ FPCSMLR::~FPCSMLR()
 
 ClassificationResult FPCSMLR::classify ( Example & pce )
 {
-  FullVector overall_distribution ( maxClassNo + 1 );
-  overall_distribution[maxClassNo] = 0.0;
+  FullVector overall_distribution ( maxClassNo);
 
   double maxp = -numeric_limits<double>::max();
   int classno = 0;

+ 0 - 2
classifier/fpclassifier/logisticregression/FPCSMLR.h

@@ -10,8 +10,6 @@
 
 #include "core/vector/VectorT.h"
 #include "core/vector/MatrixT.h"
-#include "core/image/ImageT.h"
-#include "core/imagedisplay/ImageDisplay.h"
 
 #include "vislearning/classifier/classifierbase/FeaturePoolClassifier.h"
 #include "vislearning/classifier/fpclassifier/logisticregression/SLR.h"

+ 3 - 0
classifier/fpclassifier/logisticregression/SLR.cpp

@@ -5,6 +5,9 @@
 #include "vislearning/classifier/fpclassifier/logisticregression/SLR.h"
 #include "vislearning/cbaselib/FeaturePool.h"
 
+#include "core/image/ImageT.h"
+//#include "core/imagedisplay/ImageDisplay.h"
+
 #include <iostream>
 
 #define SLRDEBUG

+ 0 - 2
classifier/fpclassifier/logisticregression/SLR.h

@@ -9,8 +9,6 @@
 
 #include "core/vector/VectorT.h"
 #include "core/vector/MatrixT.h"
-#include "core/image/ImageT.h"
-#include "core/imagedisplay/ImageDisplay.h"
 
 #include "vislearning/classifier/classifierbase/FeaturePoolClassifier.h"
 #include "vislearning/cbaselib/FeaturePool.h"

+ 3 - 0
classifier/fpclassifier/randomforest/DecisionNode.cpp

@@ -7,6 +7,9 @@
 */
 #include <iostream>
 
+#include "core/image/ImageT.h"
+#include "core/imagedisplay/ImageDisplay.h"
+
 #include "vislearning/classifier/fpclassifier/randomforest/DecisionNode.h"
 
 using namespace OBJREC;

+ 1 - 2
classifier/fpclassifier/randomforest/DecisionNode.h

@@ -10,8 +10,7 @@
 
 #include "core/vector/VectorT.h"
 #include "core/vector/MatrixT.h"
-#include "core/image/ImageT.h"
-#include "core/imagedisplay/ImageDisplay.h"
+
 #include <map>
 #include <limits>
 

+ 3 - 0
classifier/fpclassifier/randomforest/FPCRandomForests.cpp

@@ -12,6 +12,9 @@
 
 #include <iostream>
 
+#include "core/image/ImageT.h"
+#include "core/imagedisplay/ImageDisplay.h"
+
 #include "vislearning/classifier/fpclassifier/randomforest/FPCRandomForests.h"
 #include "vislearning/classifier/fpclassifier/randomforest/DTBStandard.h"
 #include "vislearning/classifier/fpclassifier/randomforest/DTBRandom.h"

+ 0 - 2
classifier/fpclassifier/randomforest/FPCRandomForests.h

@@ -12,8 +12,6 @@
 
 #include "core/vector/VectorT.h"
 #include "core/vector/MatrixT.h"
-#include "core/image/ImageT.h"
-#include "core/imagedisplay/ImageDisplay.h"
 
 #include "vislearning/classifier/classifierbase/FeaturePoolClassifier.h"
 #include "vislearning/cbaselib/FeaturePool.h"

+ 8 - 6
classifier/genericClassifierSelection.h

@@ -4,6 +4,7 @@
 #include "core/basics/StringTools.h"
 
 #include "vislearning/classifier/vclassifier/VCAmitSVM.h"
+#include "vislearning/classifier/vclassifier/VCNearestClassMean.h"
 #include "vislearning/classifier/vclassifier/VCSimpleGaussian.h"
 #include "vislearning/classifier/vclassifier/VCNearestNeighbour.h"
 #include "vislearning/classifier/vclassifier/VCCrossGeneralization.h"
@@ -60,12 +61,13 @@ class GenericClassifierSelection
 
       if ( classifier_type == "amit" ) {
         classifier = new VCAmitSVM ( conf );
-
-      } else if ( classifier_type == "nn" ) {
-        classifier = new VCNearestNeighbour ( conf, new NICE::EuclidianDistance<double>() );
-#ifdef NICE_USELIB_ICE
-      } else if ( classifier_type == "gauss" ) {
-        classifier = new VCSimpleGaussian ( conf );
+     } else if ( classifier_type == "nn" ) {
+	classifier = new VCNearestNeighbour( conf, new NICE::EuclidianDistance<double>() );
+#ifdef NICE_USELIB_ICE 
+     } else if ( classifier_type == "gauss" ) {
+        classifier = new VCSimpleGaussian( conf );
+     } else if ( classifier_type == "nearest_classmean" ) {
+        classifier = new VCNearestClassMean( conf, new NICE::EuclidianDistance<double>() );
 #endif
       } else if ( classifier_type == "random_forest" ) {
         FeaturePoolClassifier *fpc = new FPCRandomForests ( conf, "RandomForest" );

+ 3 - 3
classifier/vclassifier/VCDTSVM.cpp

@@ -2,6 +2,8 @@
 
 #include "vislearning/classifier/vclassifier/VCDTSVM.h"
 
+#include "core/image/ImageT.h"
+//#include "core/imagedisplay/ImageDisplay.h"
 #include "core/basics/StringTools.h"
 
 #undef WRITE
@@ -117,9 +119,7 @@ ClassificationResult VCDTSVM::classify ( const NICE::Vector & x ) const
     }
   }
   return ClassificationResult ( bclass, scores );
-#endif
-
-#ifndef WRITE
+#else
   int c2 = ( *counter ) [0];
   ( *counter ) [0]++;
   FullVector tmp ( results[c2].size() );

+ 0 - 2
classifier/vclassifier/VCDTSVM.h

@@ -9,8 +9,6 @@
 
 #include "core/vector/VectorT.h"
 #include "core/vector/MatrixT.h"
-#include "core/image/ImageT.h"
-#include "core/imagedisplay/ImageDisplay.h"
 
 #include "vislearning/cbaselib/LabeledSet.h"
 #include "vislearning/classifier/classifierbase/VecClassifier.h"

+ 110 - 0
classifier/vclassifier/VCNearestClassMean.cpp

@@ -0,0 +1,110 @@
+#ifdef NICE_USELIB_ICE
+
+#include <iostream>
+
+#include "vislearning/classifier/vclassifier/VCNearestClassMean.h"
+
+using namespace OBJREC;
+
+using namespace std;
+
+using namespace NICE;
+
+VCNearestClassMean::VCNearestClassMean( const Config *_conf, NICE::VectorDistance<double> *_distancefunc  ) 
+: VecClassifier ( _conf ), distancefunc (_distancefunc)
+{    
+    if ( _distancefunc == NULL )
+		distancefunc = new EuclidianDistance<double>();
+}
+
+VCNearestClassMean::~VCNearestClassMean()
+{
+    clear();
+}
+
+/** classify using simple vector */
+
+ClassificationResult VCNearestClassMean::classify ( const NICE::Vector & x ) const
+{
+     double min_distance= std::numeric_limits<double>::max();
+     int min_class = -1;
+     FullVector scores ( classNo.size() );
+     
+     for(uint i=0;i<this->classNo.size();i++)
+     {
+          double distance = distancefunc->calculate ( x, means[i] );
+          scores[i] = - distance;
+          if ( distance < min_distance)
+          {
+               min_distance = distance;
+               min_class = classNo[i];
+          }
+     }
+     
+     return ClassificationResult ( min_class, scores );
+}
+
+
+void VCNearestClassMean::teach ( const LabeledSetVector & _teachSet )
+{
+
+    _teachSet.getClasses ( this->classNo );
+
+    //initialize means
+    NICE::Vector zero( _teachSet.dimension() );
+    for(uint d=0;d<zero.size();d++) zero[d]=0.0;
+    for(uint c=0;c<this->classNo.size();c++)
+    {
+	means.push_back(zero);
+    }
+
+    //add all class-specific vectors 
+    int index=0;
+    LOOP_ALL(_teachSet)
+    {
+	EACH(classno,x);
+	//determine index
+	for(uint c=0;c<this->classNo.size();c++)
+        {
+		if(classno==classNo[c]) index=c;
+        }
+	for(uint d=0;d<zero.size();d++)
+        {
+	   means[index][d]+=x[d];
+        }
+    }
+
+    //normalize vectors
+    for(uint c=0;c<this->classNo.size();c++)
+    {
+	for(uint d=0;d<zero.size();d++)
+        {
+	   means[c][d]/=_teachSet.count(this->classNo[c]);
+        }
+    }
+
+}
+
+void VCNearestClassMean::finishTeaching()
+{
+//nothing more to do
+}
+
+void VCNearestClassMean::clear ()
+{
+//nothing to do
+}
+
+void VCNearestClassMean::store ( std::ostream & os, int format ) const
+{
+    fprintf (stderr, "NOT YET IMPLEMENTED\n");
+    exit(-1);
+}
+
+void VCNearestClassMean::restore ( std::istream & is, int format )
+{
+    fprintf (stderr, "NOT YET IMPLEMENTED\n");
+    exit(-1);
+}
+
+#endif

+ 55 - 0
classifier/vclassifier/VCNearestClassMean.h

@@ -0,0 +1,55 @@
+/** 
+* @file VCNearestClassMean.h
+* @brief Nearest Class Mean Classifier (Naive Bayes with identity covariance matrix for all classes) -> code is based on VCSimpleGaussian and VCNearestNeighbor
+* @author Erik Rodner + Mi.Ke
+* @date 12/05/2007
+
+*/
+
+#ifndef VCNEARESTCLASSMEANINCLUDE
+#define VCNEARESTCLASSMEANINCLUDE
+
+#include "vislearning/classifier/classifierbase/VecClassifier.h"
+#include <core/vector/Distance.h>
+
+#include <image_nonvis.h>
+
+namespace OBJREC {
+
+/** Simple Gaussian Classifier */
+class VCNearestClassMean : public VecClassifier
+{
+    public:
+	std::vector<NICE::Vector> means;
+	std::vector<int> classNo;
+	NICE::VectorDistance<double> *distancefunc;
+	std::map<int, ice::Statistics *> statistics;
+
+    public:
+  
+	/** simple constructor */
+	VCNearestClassMean( const NICE::Config *conf, NICE::VectorDistance<double> *distancefunc = NULL );
+      
+	/** simple destructor */
+	virtual ~VCNearestClassMean();
+ 
+	/** classify using simple vector */
+	ClassificationResult classify ( const NICE::Vector & x ) const;
+
+	/** classify using a simple vector */
+	void teach ( const LabeledSetVector & teachSet );
+	
+	void finishTeaching();
+
+	void clear ();
+
+	void store ( std::ostream & os, int format = 0 ) const;
+
+	void restore ( std::istream & is, int format = 0 );
+
+};
+
+
+} // namespace
+
+#endif

+ 3 - 0
classifier/vclassifier/VCOneVsAll.cpp

@@ -6,6 +6,9 @@
 */
 #include <iostream>
 
+#include "core/image/ImageT.h"
+#include "core/imagedisplay/ImageDisplay.h"
+
 #include "vislearning/classifier/vclassifier/VCOneVsAll.h"
 
 

+ 0 - 2
classifier/vclassifier/VCOneVsAll.h

@@ -10,8 +10,6 @@
 
 #include "core/vector/VectorT.h"
 #include "core/vector/MatrixT.h"
-#include "core/image/ImageT.h"
-#include "core/imagedisplay/ImageDisplay.h"
 
 #include "vislearning/classifier/classifierbase/VecClassifier.h"
 #include "core/basics/triplet.h"

+ 98 - 102
features/fpfeatures/ColorHistogramFeature.cpp

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file ColorHistogramFeature.cpp
 * @brief histogram of oriented gradients ( dalal and triggs )
 * @author Erik Rodner
@@ -19,17 +19,17 @@ using namespace NICE;
 const double epsilon = 10e-8;
 
 /** simple constructor */
-ColorHistogramFeature::ColorHistogramFeature( const Config *conf )
+ColorHistogramFeature::ColorHistogramFeature ( const Config *conf )
 {
-    window_size_x = conf->gI("ColorHistogramFeature", "window_size_x", 21 );
-    window_size_y = conf->gI("ColorHistogramFeature", "window_size_y", 21 );
-    scaleStep = conf->gD("ColorHistogramFeature", "scale_step", sqrt(2) );
-    numScales = conf->gI("ColorHistogramFeature", "num_scales", 5 );
-
-    int numBinsH = conf->gI("ColorHistogramFeature", "num_bins_h", 4);
-    int numBinsS = conf->gI("ColorHistogramFeature", "num_bins_s", 2);
-    int numBinsV = conf->gI("ColorHistogramFeature", "num_bins_v", 2);
-    numBins = numBinsH*numBinsS*numBinsV;
+  window_size_x = conf->gI ( "ColorHistogramFeature", "window_size_x", 21 );
+  window_size_y = conf->gI ( "ColorHistogramFeature", "window_size_y", 21 );
+  scaleStep = conf->gD ( "ColorHistogramFeature", "scale_step", sqrt ( 2 ) );
+  numScales = conf->gI ( "ColorHistogramFeature", "num_scales", 5 );
+
+  int numBinsH = conf->gI ( "ColorHistogramFeature", "num_bins_h", 4 );
+  int numBinsS = conf->gI ( "ColorHistogramFeature", "num_bins_s", 2 );
+  int numBinsV = conf->gI ( "ColorHistogramFeature", "num_bins_v", 2 );
+  numBins = numBinsH * numBinsS * numBinsV;
 }
 
 /** simple destructor */
@@ -37,124 +37,120 @@ ColorHistogramFeature::~ColorHistogramFeature()
 {
 }
 
-double ColorHistogramFeature::val( const Example *example ) const
+double ColorHistogramFeature::val ( const Example *example ) const
 {
-    const NICE::MultiChannelImageT<double> & img = 
-	example->ce->getDChannel ( CachedExample::D_INTEGRALCOLOR );
-    int tm_xsize = img.xsize;
-    int tm_ysize = img.ysize;
-
-    int xsize;
-    int ysize;
-    example->ce->getImageSize ( xsize, ysize );
-
-    int wsx2, wsy2;
-    int exwidth = example->width;
-    if ( exwidth == 0 ) {
-	wsx2 = window_size_x * tm_xsize / (2*xsize);
-	wsy2 = window_size_y * tm_ysize / (2*ysize);
-    } else {
-	int exheight = example->height;
-	wsx2 = exwidth * tm_xsize / (2*xsize);
-	wsy2 = exheight * tm_ysize / (2*ysize);
-    }
-	
-    int xx, yy;
-    xx = ( example->x ) * tm_xsize / xsize;
-    yy = ( example->y ) * tm_ysize / ysize;
-
-    assert ( (wsx2 > 0) && (wsy2 > 0) );
-
-    int xtl = xx - wsx2;
-    int ytl = yy - wsy2;
-    int xrb = xx + wsx2;
-    int yrb = yy + wsy2;
+  const NICE::MultiChannelImageT<double> & img =
+    example->ce->getDChannel ( CachedExample::D_INTEGRALCOLOR );
+  int tm_xsize = img.width();
+  int tm_ysize = img.height();
+
+  int xsize;
+  int ysize;
+  example->ce->getImageSize ( xsize, ysize );
+
+  int wsx2, wsy2;
+  int exwidth = example->width;
+  if ( exwidth == 0 ) {
+    wsx2 = window_size_x * tm_xsize / ( 2 * xsize );
+    wsy2 = window_size_y * tm_ysize / ( 2 * ysize );
+  } else {
+    int exheight = example->height;
+    wsx2 = exwidth * tm_xsize / ( 2 * xsize );
+    wsy2 = exheight * tm_ysize / ( 2 * ysize );
+  }
+
+  int xx, yy;
+  xx = ( example->x ) * tm_xsize / xsize;
+  yy = ( example->y ) * tm_ysize / ysize;
+
+  assert ( ( wsx2 > 0 ) && ( wsy2 > 0 ) );
+
+  int xtl = xx - wsx2;
+  int ytl = yy - wsy2;
+  int xrb = xx + wsx2;
+  int yrb = yy + wsy2;
 
 #define BOUND(x,min,max) (((x)<(min))?(min):((x)>(max)?(max):(x)))
-    xtl = BOUND ( xtl, 0, tm_xsize - 1 );
-    ytl = BOUND ( ytl, 0, tm_ysize - 1 );
-    xrb = BOUND ( xrb, 0, tm_xsize - 1 );
-    yrb = BOUND ( yrb, 0, tm_ysize - 1 );
+  xtl = BOUND ( xtl, 0, tm_xsize - 1 );
+  ytl = BOUND ( ytl, 0, tm_ysize - 1 );
+  xrb = BOUND ( xrb, 0, tm_xsize - 1 );
+  yrb = BOUND ( yrb, 0, tm_ysize - 1 );
 #undef BOUND
 
-    assert ( bin < (int)img.numChannels );
-    assert ( img.data[bin] != NULL );
-
-    long kA = xtl + ytl * tm_xsize;
-    long kB = xrb + ytl * tm_xsize;
-    long kC = xtl + yrb * tm_xsize;
-    long kD = xrb + yrb * tm_xsize;
-    double A,B,C,D;
-    A = img.data[bin][ kA ];
-    B = img.data[bin][ kB ];
-    C = img.data[bin][ kC ];
-    D = img.data[bin][ kD ];
-
-    double val1 =  (D - B - C + A);
-    double sum = val1*val1;
-    for ( int b = 0 ; b < (int)img.numChannels ; b++)
-    {
-	if ( b == bin ) continue;
-	A = img.data[b][ kA ];
-	B = img.data[b][ kB ];
-	C = img.data[b][ kC ];
-	D = img.data[b][ kD ];
-	double val = ( D - B - C + A );
-	sum += val*val;
-    }
-    sum = sqrt(sum);
-    return ( val1 + epsilon ) / ( sum + epsilon );
+  assert ( bin < ( int ) img.channels() );
+
+  double A, B, C, D;
+  A = img.get ( xtl, ytl, bin );
+  B = img.get ( xrb, ytl, bin );
+  C = img.get ( xtl, yrb, bin );
+  D = img.get ( xrb, yrb, bin );
+
+  double val1 = ( D - B - C + A );
+  double sum = val1 * val1;
+  for ( int b = 0 ; b < ( int ) img.channels() ; b++ )
+  {
+    if ( b == bin ) 
+      continue;
+    A = img.get ( xtl, ytl, b );
+    B = img.get ( xrb, ytl, b );
+    C = img.get ( xtl, yrb, b );
+    D = img.get ( xrb, yrb, b );
+    double val = ( D - B - C + A );
+    sum += val * val;
+  }
+  sum = sqrt ( sum );
+  return ( val1 + epsilon ) / ( sum + epsilon );
 }
 
 void ColorHistogramFeature::explode ( FeaturePool & featurePool, bool variableWindow ) const
 {
-    int nScales = (variableWindow ? numScales : 1 );
+  int nScales = ( variableWindow ? numScales : 1 );
 
-    for ( int i = 0 ; i < nScales ; i++ )
+  for ( int i = 0 ; i < nScales ; i++ )
+  {
+    int wsy = window_size_y;
+    int wsx = window_size_x;
+    for ( int _bin = 0 ; _bin < numBins ; _bin++ )
     {
-	int wsy = window_size_y;
-	int wsx = window_size_x;
-	for ( int _bin = 0 ; _bin < numBins ; _bin++ )
-	{
-	    ColorHistogramFeature *f = new ColorHistogramFeature();
-	    f->window_size_x = wsx;
-	    f->window_size_y = wsy;
-	    f->bin = _bin;
-	    featurePool.addFeature ( f, 1.0 / ( numBins * nScales ) ); 
-	}
-	wsx = (int) (scaleStep * wsx);
-	wsy = (int) (scaleStep * wsy);
+      ColorHistogramFeature *f = new ColorHistogramFeature();
+      f->window_size_x = wsx;
+      f->window_size_y = wsy;
+      f->bin = _bin;
+      featurePool.addFeature ( f, 1.0 / ( numBins * nScales ) );
     }
+    wsx = ( int ) ( scaleStep * wsx );
+    wsy = ( int ) ( scaleStep * wsy );
+  }
 }
 
 Feature *ColorHistogramFeature::clone() const
 {
-    ColorHistogramFeature *f = new ColorHistogramFeature();
-    f->window_size_x = window_size_x;
-    f->window_size_y = window_size_y;
-    f->bin = bin;
+  ColorHistogramFeature *f = new ColorHistogramFeature();
+  f->window_size_x = window_size_x;
+  f->window_size_y = window_size_y;
+  f->bin = bin;
 
-    return f;
+  return f;
 }
 
 Feature *ColorHistogramFeature::generateFirstParameter () const
 {
-    return clone();
+  return clone();
 }
 
-void ColorHistogramFeature::restore (istream & is, int format)
+void ColorHistogramFeature::restore ( istream & is, int format )
 {
-    is >> window_size_x;
-    is >> window_size_y;
-    is >> bin;
+  is >> window_size_x;
+  is >> window_size_y;
+  is >> bin;
 }
 
-void ColorHistogramFeature::store (ostream & os, int format) const
+void ColorHistogramFeature::store ( ostream & os, int format ) const
 {
-    os << "ColorHistogramFeature "
-       << window_size_x << " "
-       << window_size_y << " "
-       << bin;
+  os << "ColorHistogramFeature "
+  << window_size_x << " "
+  << window_size_y << " "
+  << bin;
 }
 
 void ColorHistogramFeature::clear ()

+ 34 - 37
features/fpfeatures/ColorHistogramFeature.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file ColorHistogramFeature.h
 * @brief simple color histograms
 * @author Erik Rodner
@@ -10,7 +10,7 @@
 
 #include "core/vector/VectorT.h"
 #include "core/vector/MatrixT.h"
- 
+
 #include "core/basics/Config.h"
 #include "vislearning/cbaselib/Feature.h"
 
@@ -21,44 +21,41 @@ namespace OBJREC {
 class ColorHistogramFeature : public Feature
 {
 
-    protected:
-
-	/** @{ feature parameter */
-	int window_size_x;
-	int window_size_y;
-
-	int bin;
-	/** @} */
-
-	/** @{ parameter for feature generation */
-	int numScales;
-	int numBins;
-	double scaleStep;
-	/** @} */
-
-    public:
-  
-	/** simple constructor */
-	ColorHistogramFeature( const NICE::Config *conf );
-
-	/** internally used by ColorHistogramFeature::explode */
-	ColorHistogramFeature () {};
-      
-	/** simple destructor */
-	virtual ~ColorHistogramFeature();
-     
-	double val( const Example *example ) const;
-	void explode ( FeaturePool & featurePool, bool variableWindow = true ) const;
-	Feature *clone() const;
-	Feature *generateFirstParameter () const;
-
-	void restore (std::istream & is, int format = 0);
-	void store (std::ostream & os, int format = 0) const;
-	void clear ();
-};
+  protected:
+
+    /** @{ feature parameter */
+    int window_size_x;
+    int window_size_y;
+
+    int bin;
+    /** @} */
+
+    /** @{ parameter for feature generation */
+    int numScales;
+    int numBins;
+    double scaleStep;
+    /** @} */
 
+  public:
 
+    /** simple constructor */
+    ColorHistogramFeature ( const NICE::Config *conf );
 
+    /** internally used by ColorHistogramFeature::explode */
+    ColorHistogramFeature () {};
+
+    /** simple destructor */
+    virtual ~ColorHistogramFeature();
+
+    double val ( const Example *example ) const;
+    void explode ( FeaturePool & featurePool, bool variableWindow = true ) const;
+    Feature *clone() const;
+    Feature *generateFirstParameter () const;
+
+    void restore ( std::istream & is, int format = 0 );
+    void store ( std::ostream & os, int format = 0 ) const;
+    void clear ();
+};
 
 } // namespace
 

+ 162 - 174
features/fpfeatures/EOHFeature.cpp

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file EOHFeature.cpp
 * @brief edge orientation histograms (Levi and Weiss 2004)
 * @author Erik Rodner
@@ -19,17 +19,17 @@ using namespace NICE;
 
 
 /** simple constructor */
-EOHFeature::EOHFeature( const Config *conf )
+EOHFeature::EOHFeature ( const Config *conf )
 {
-    window_size_x = conf->gI("EOHFeature", "window_size_x", 21 );
-    window_size_y = conf->gI("EOHFeature", "window_size_y", 21 );
-    scaleStep = conf->gD("EOHFeature", "scale_step", sqrt(2) );
-    numScales = conf->gI("EOHFeature", "num_scales", 5 );
-    numBins = conf->gI("EOHFeature", "num_bins", 9 );
-
-    bin  = 0;
-    bin2 = 0;
-    type = EOH_VALUE;
+  window_size_x = conf->gI ( "EOHFeature", "window_size_x", 21 );
+  window_size_y = conf->gI ( "EOHFeature", "window_size_y", 21 );
+  scaleStep = conf->gD ( "EOHFeature", "scale_step", sqrt ( 2 ) );
+  numScales = conf->gI ( "EOHFeature", "num_scales", 5 );
+  numBins = conf->gI ( "EOHFeature", "num_bins", 9 );
+
+  bin  = 0;
+  bin2 = 0;
+  type = EOH_VALUE;
 }
 
 /** simple destructor */
@@ -37,197 +37,185 @@ EOHFeature::~EOHFeature()
 {
 }
 
-double EOHFeature::val( const Example *example ) const
+double EOHFeature::val ( const Example *example ) const
 {
-    const NICE::MultiChannelImageT<double> & img = example->ce->getDChannel (
-	CachedExample::D_INTEGRALEOH );
-
-    int xsize;
-    int ysize;
-    example->ce->getImageSize ( xsize, ysize );
-    int tm_xsize = img.xsize;
-    int tm_ysize = img.ysize;
-
-#if 0
-    int xtl = example->x - window_size_x/2;
-    int ytl = example->y - window_size_y/2;
-    int xrb = example->x + window_size_x/2;
-    int yrb = example->y + window_size_y/2;
-
-    xtl = xtl * tm_xsize / xsize;
-    ytl = ytl * tm_ysize / ysize;
-    xrb = xrb * tm_xsize / xsize;
-    yrb = yrb * tm_ysize / ysize;
-#endif
-
-    
-    int wsx2, wsy2;
-    int xx, yy;
-
-    int exwidth = example->width;
-    if ( exwidth == 0 ) {
-	wsx2 = window_size_x * tm_xsize / (2*xsize);
-	wsy2 = window_size_y * tm_ysize / (2*ysize);
-    } else {
-	int exheight = example->height;
-	wsx2 = exwidth * tm_xsize / (2*xsize);
-	wsy2 = exheight * tm_ysize / (2*ysize);
-    }
-	
-    xx = ( example->x ) * tm_xsize / xsize;
-    yy = ( example->y ) * tm_ysize / ysize;
-    
-    int xtl = xx - wsx2;
-    int ytl = yy - wsy2;
-    int xrb = xx + wsx2;
-    int yrb = yy + wsy2;
+  const NICE::MultiChannelImageT<double> & img = example->ce->getDChannel (
+        CachedExample::D_INTEGRALEOH );
+
+  int xsize;
+  int ysize;
+  example->ce->getImageSize ( xsize, ysize );
+  int tm_xsize = img.width();
+  int tm_ysize = img.height();
+
+  int wsx2, wsy2;
+  int xx, yy;
+
+  int exwidth = example->width;
+  if ( exwidth == 0 ) {
+    wsx2 = window_size_x * tm_xsize / ( 2 * xsize );
+    wsy2 = window_size_y * tm_ysize / ( 2 * ysize );
+  } else {
+    int exheight = example->height;
+    wsx2 = exwidth * tm_xsize / ( 2 * xsize );
+    wsy2 = exheight * tm_ysize / ( 2 * ysize );
+  }
+
+  xx = ( example->x ) * tm_xsize / xsize;
+  yy = ( example->y ) * tm_ysize / ysize;
+
+  int xtl = xx - wsx2;
+  int ytl = yy - wsy2;
+  int xrb = xx + wsx2;
+  int yrb = yy + wsy2;
 
 #define BOUND(x,min,max) (((x)<(min))?(min):((x)>(max)?(max):(x)))
-    xtl = BOUND ( xtl, 0, tm_xsize - 1 );
-    ytl = BOUND ( ytl, 0, tm_ysize - 1 );
-    xrb = BOUND ( xrb, 0, tm_xsize - 1 );
-    yrb = BOUND ( yrb, 0, tm_ysize - 1 );
+  xtl = BOUND ( xtl, 0, tm_xsize - 1 );
+  ytl = BOUND ( ytl, 0, tm_ysize - 1 );
+  xrb = BOUND ( xrb, 0, tm_xsize - 1 );
+  yrb = BOUND ( yrb, 0, tm_ysize - 1 );
 #undef BOUND
 
-    double A,B,C,D;
-
-    assert ( bin < (int)img.numChannels );
-    assert ( img.data[bin] != NULL );
-
-    int kA = xtl + ytl * tm_xsize;
-    int kB = xrb + ytl * tm_xsize;
-    int kC = xtl + yrb * tm_xsize;
-    int kD = xrb + yrb * tm_xsize;
-    A = img.data[bin][ kA ];
-    B = img.data[bin][ kB ];
-    C = img.data[bin][ kC ];
-    D = img.data[bin][ kD ];
-
-    if ( type == EOH_VALUE ) { 
-	int area = (xrb - xtl)*(yrb - ytl);
-	
-	if ( area == 0 ) 
-	    return 0.0;
-	else {        
-	   /* A B 
-	      C D  */
-	    double value = (D - B - C + A) / area;
-
-	    return value;
-	}
-    } else if ( type == EOH_RATIO ) {
-	assert ( bin2 < (int)img.numChannels );
-
-	double val1 =  (D - B - C + A);
-	A = img.data[bin2][ kA ];
-	B = img.data[bin2][ kB ];
-	C = img.data[bin2][ kC ];
-	D = img.data[bin2][ kD ];
-
-	double val2 = ( D - B - C + A );
-
-	return ( val1 + epsilon ) / ( val2 + epsilon );
-    } else if ( type == EOH_DOMINANT_ORIENTATION ) {
-	double val1 =  (D - B - C + A);
-	double sum = val1;
-	for ( int b = 0 ; b < (int)img.numChannels ; b++)
-	{
-	    if ( b == bin ) continue;
-	    A = img.data[b][ kA ];
-	    B = img.data[b][ kB ];
-	    C = img.data[b][ kC ];
-	    D = img.data[b][ kD ];
-	    sum += ( D - B - C + A );
-	}
-
-	return ( val1 + epsilon ) / ( sum + epsilon );
+  double A, B, C, D;
+
+  assert ( bin < ( int ) img.channels() );
+
+  A = img.get ( xtl, ytl, bin );
+  B = img.get ( xrb, ytl, bin );
+  C = img.get ( xtl, yrb, bin );
+  D = img.get ( xrb, yrb, bin );
+
+  if ( type == EOH_VALUE )
+  {
+    int area = ( xrb - xtl ) * ( yrb - ytl );
+
+    if ( area == 0 )
+      return 0.0;
+    else {
+      /* A B
+         C D  */
+      double value = ( D - B - C + A ) / area;
+
+      return value;
+    }
+  }
+  else if ( type == EOH_RATIO )
+  {
+    assert ( bin2 < ( int ) img.channels() );
+
+    double val1 = ( D - B - C + A );
+    A = img.get ( xtl, ytl, bin2 );
+    B = img.get ( xrb, ytl, bin2 );
+    C = img.get ( xtl, yrb, bin2 );
+    D = img.get ( xrb, yrb, bin2 );
+
+    double val2 = ( D - B - C + A );
+
+    return ( val1 + epsilon ) / ( val2 + epsilon );
+  }
+  else if ( type == EOH_DOMINANT_ORIENTATION )
+  {
+    double val1 = ( D - B - C + A );
+    double sum = val1;
+    for ( int b = 0 ; b < ( int ) img.channels() ; b++ )
+    {
+      if ( b == bin ) 
+        continue;
+      A = img.get ( xtl, ytl, b );
+      B = img.get ( xrb, ytl, b );
+      C = img.get ( xtl, yrb, b );
+      D = img.get ( xrb, yrb, b );
+      sum += ( D - B - C + A );
     }
 
-    assert ( 1 == 0 );
+    return ( val1 + epsilon ) / ( sum + epsilon );
+  }
+
+  assert ( 1 == 0 );
 }
 
 void EOHFeature::explode ( FeaturePool & featurePool, bool variableWindow ) const
 {
-    int nScales = (variableWindow ? numScales : 1 );
+  int nScales = ( variableWindow ? numScales : 1 );
 
-    for ( int i = 0 ; i < nScales ; i++ )
+  for ( int i = 0 ; i < nScales ; i++ )
+  {
+    int wsy = window_size_y;
+    int wsx = window_size_x;
+    for ( int _type = 0 ; _type < EOH_NUMTYPES; _type++ )
     {
-	int wsy = window_size_y;
-	int wsx = window_size_x;
-	for ( int _type = 0 ; _type < EOH_NUMTYPES; _type++ )
-	{
-	    if ( (_type == EOH_VALUE) || (_type == EOH_DOMINANT_ORIENTATION) )
-	    {
-		for ( int _bin = 0 ; _bin < numBins ; _bin++ )
-		{
-		    EOHFeature *f = new EOHFeature();
-		    f->window_size_x = wsx;
-		    f->window_size_y = wsy;
-		    f->bin = _bin;
-		    f->type = _type;
-		    featurePool.addFeature ( f, 1.0 / ( EOH_NUMTYPES * numBins * nScales ) ); 
-		}
-	    }
-	    
-	    if ( (_type == EOH_RATIO) )
-	    {
-		for ( int _bin = 0 ; _bin < numBins ; _bin++ )
-		{
-		    for ( int _bin2 = 0 ; _bin2 < numBins ; _bin2++ )
-		    {
-			if ( bin == bin2 ) continue;
-
-			EOHFeature *f = new EOHFeature();
-			f->window_size_x = wsx;
-			f->window_size_y = wsy;
-			f->bin = _bin;
-			f->bin2 = _bin2;
-			f->type = _type;
-			featurePool.addFeature ( f, 1.0 / (EOH_NUMTYPES * (numBins - 1) * numBins * nScales ) ); 
-		    }
-		}
-	    }
-	}
-
-	wsx = (int) (scaleStep * wsx);
-	wsy = (int) (scaleStep * wsy);
+      if ( ( _type == EOH_VALUE ) || ( _type == EOH_DOMINANT_ORIENTATION ) )
+      {
+        for ( int _bin = 0 ; _bin < numBins ; _bin++ )
+        {
+          EOHFeature *f = new EOHFeature();
+          f->window_size_x = wsx;
+          f->window_size_y = wsy;
+          f->bin = _bin;
+          f->type = _type;
+          featurePool.addFeature ( f, 1.0 / ( EOH_NUMTYPES * numBins * nScales ) );
+        }
+      }
+
+      if ( ( _type == EOH_RATIO ) )
+      {
+        for ( int _bin = 0 ; _bin < numBins ; _bin++ )
+        {
+          for ( int _bin2 = 0 ; _bin2 < numBins ; _bin2++ )
+          {
+            if ( bin == bin2 ) continue;
+
+            EOHFeature *f = new EOHFeature();
+            f->window_size_x = wsx;
+            f->window_size_y = wsy;
+            f->bin = _bin;
+            f->bin2 = _bin2;
+            f->type = _type;
+            featurePool.addFeature ( f, 1.0 / ( EOH_NUMTYPES * ( numBins - 1 ) * numBins * nScales ) );
+          }
+        }
+      }
     }
+
+    wsx = ( int ) ( scaleStep * wsx );
+    wsy = ( int ) ( scaleStep * wsy );
+  }
 }
 
 Feature *EOHFeature::clone() const
 {
-    EOHFeature *f = new EOHFeature();
-    f->window_size_x = window_size_x;
-    f->window_size_y = window_size_y;
-    f->bin = bin;
-    f->bin2 = bin2;
-    f->type = type;
-
-    return f;
+  EOHFeature *f = new EOHFeature();
+  f->window_size_x = window_size_x;
+  f->window_size_y = window_size_y;
+  f->bin = bin;
+  f->bin2 = bin2;
+  f->type = type;
+
+  return f;
 }
 
 Feature *EOHFeature::generateFirstParameter () const
 {
-    return clone();
+  return clone();
 }
 
-void EOHFeature::restore (istream & is, int format)
+void EOHFeature::restore ( istream & is, int format )
 {
-    is >> window_size_x;
-    is >> window_size_y;
-    is >> type;
-    is >> bin;
-    is >> bin2;
+  is >> window_size_x;
+  is >> window_size_y;
+  is >> type;
+  is >> bin;
+  is >> bin2;
 }
 
-void EOHFeature::store (ostream & os, int format) const
+void EOHFeature::store ( ostream & os, int format ) const
 {
-    os << "EOHFEATURE "
-       << window_size_x << " "
-       << window_size_y << " "
-       << type << " "
-       << bin << " "
-       << bin2;
+  os << "EOHFEATURE "
+  << window_size_x << " "
+  << window_size_y << " "
+  << type << " "
+  << bin << " "
+  << bin2;
 }
 
 void EOHFeature::clear ()

+ 49 - 46
features/fpfeatures/EOHFeature.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file EOHFeature.h
 * @brief edge orientation histogram (Levi and Weiss, 2004)
 * @author Erik Rodner
@@ -10,7 +10,7 @@
 
 #include "core/vector/VectorT.h"
 #include "core/vector/MatrixT.h"
- 
+
 #include "core/basics/Config.h"
 #include "vislearning/cbaselib/Feature.h"
 
@@ -21,50 +21,53 @@ namespace OBJREC {
 class EOHFeature : public Feature
 {
 
-    protected:
-
-	enum {
-	    EOH_VALUE = 0,
-	    EOH_RATIO,
-	    EOH_DOMINANT_ORIENTATION,
-	    EOH_NUMTYPES
-	};
-
-	/** @{ feature parameter */
-	int window_size_x;
-	int window_size_y;
-	int bin;
-	int bin2; // used for EOH_RATIO
-	int type;
-	/** @} */
-
-
-	/** @{ parameter for feature generation */
-	int numScales;
-	int numBins;
-	double scaleStep;
-	int maxdepth;
-	/** @} */
-
-    public:
-  
-	/** simple constructor */
-	EOHFeature( const NICE::Config *conf );
-
-	/** internally used by EOHFeature::explode */
-	EOHFeature () { bin = bin2 = 0; type = EOH_VALUE; };
-      
-	/** simple destructor */
-	virtual ~EOHFeature();
-     
-	double val( const Example *example ) const;
-	void explode ( FeaturePool & featurePool, bool variableWindow = true ) const;
-	Feature *clone() const;
-	Feature *generateFirstParameter () const;
-
-	void restore (std::istream & is, int format = 0);
-	void store (std::ostream & os, int format = 0) const;
-	void clear ();
+  protected:
+
+    enum {
+      EOH_VALUE = 0,
+      EOH_RATIO,
+      EOH_DOMINANT_ORIENTATION,
+      EOH_NUMTYPES
+    };
+
+    /** @{ feature parameter */
+    int window_size_x;
+    int window_size_y;
+    int bin;
+    int bin2; // used for EOH_RATIO
+    int type;
+    /** @} */
+
+
+    /** @{ parameter for feature generation */
+    int numScales;
+    int numBins;
+    double scaleStep;
+    int maxdepth;
+    /** @} */
+
+  public:
+
+    /** simple constructor */
+    EOHFeature ( const NICE::Config *conf );
+
+    /** internally used by EOHFeature::explode */
+    EOHFeature () {
+      bin = bin2 = 0;
+      type = EOH_VALUE;
+    };
+
+    /** simple destructor */
+    virtual ~EOHFeature();
+
+    double val ( const Example *example ) const;
+    void explode ( FeaturePool & featurePool, bool variableWindow = true ) const;
+    Feature *clone() const;
+    Feature *generateFirstParameter () const;
+
+    void restore ( std::istream & is, int format = 0 );
+    void store ( std::ostream & os, int format = 0 ) const;
+    void clear ();
 };
 
 

+ 57 - 51
features/fpfeatures/FIGradients.cpp

@@ -8,67 +8,73 @@ using namespace NICE;
 using namespace std;
 
 void FIGradients::buildEOHMap ( CachedExample *ce,
-				int subsamplex, int subsampley,
-				int numBins, bool usesigned )
+                                int subsamplex, int subsampley,
+                                int numBins, bool usesigned )
 {
-    int xsize;
-    int ysize;
-    ce->getImageSize ( xsize, ysize );
-    int xsize_s = xsize / subsamplex;
-    int ysize_s = ysize / subsampley;
+  int xsize;
+  int ysize;
+  ce->getImageSize ( xsize, ysize );
+  int xsize_s = xsize / subsamplex;
+  int ysize_s = ysize / subsampley;
 
-    NICE::MultiChannelImageT<double> & eohimg = ce->getDChannel ( CachedExample::D_EOH );
-    eohimg.reInit ( xsize_s, ysize_s, numBins, true );
-    
-    double *gradient = new double[xsize*ysize];
-    int *dir = new int[xsize*ysize];
+  NICE::MultiChannelImageT<double> & eohimg = ce->getDChannel ( CachedExample::D_EOH );
+  eohimg.reInit ( xsize_s, ysize_s, numBins);
 
-    if ( ce->colorInformationAvailable() ) {
-	NICE::MultiChannelImageT<int> & colorimg = ce->getIChannel ( CachedExample::I_COLOR );
-	const int *r = colorimg.data[0];
-	const int *g = colorimg.data[1];
-	const int *b = colorimg.data[2];
-	FastFilter::calcColorGradient ( r,g,b,xsize,ysize,
-			    gradient, dir, numBins, usesigned );
-    } else {
-	NICE::MultiChannelImageT<int> & grayvalues = ce->getIChannel ( CachedExample::I_GRAYVALUES );
-	const int *gr = grayvalues.data[0];
-	FastFilter::calcGradient ( gr, xsize, ysize, gradient, dir, numBins, usesigned );
-    }
+  double *gradient = new double[xsize*ysize];
+  int *dir = new int[xsize*ysize];
+
+  if ( ce->colorInformationAvailable() ) {
+    NICE::MultiChannelImageT<int> & colorimg = ce->getIChannel ( CachedExample::I_COLOR );
+    int **data = colorimg.getDataPointer();
+    const int *r = data[0];
+    const int *g = data[1];
+    const int *b = data[2];
+    FastFilter::calcColorGradient ( r, g, b, xsize, ysize,
+                                    gradient, dir, numBins, usesigned );
+  } else {
+    NICE::MultiChannelImageT<int> & grayvalues = ce->getIChannel ( CachedExample::I_GRAYVALUES );
+    int **data = grayvalues.getDataPointer();
+    const int *gr = data[0];
+    FastFilter::calcGradient ( gr, xsize, ysize, gradient, dir, numBins, usesigned );
+  }
 
-    eohimg.setAll ( 0 );
+  eohimg.setAll ( 0 );
+  double **data = eohimg.getDataPointer();
+  long korig = 0;
+  for ( int y = 0 ; y < ysize ; y++ )
+    for ( int x = 0 ; x < xsize ; x++, korig++ )
+    {
+      int xs = x / subsamplex;
+      int ys = y / subsampley;
 
-    long korig = 0;
-    for ( int y = 0 ; y < ysize ; y++ )
-	for ( int x = 0 ; x < xsize ; x++,korig++ )
-	{
-	    int xs = x / subsamplex;
-	    int ys = y / subsampley;
+      if ( xs >= xsize_s ) xs = xsize_s - 1;
+      if ( xs < 0 ) xs = 0;
+      if ( ys >= ysize_s ) ys = ysize_s - 1;
+      if ( ys < 0 ) ys = 0;
+      int k = xs + ys * xsize_s;
+      int val = dir[korig];
+      double strength = gradient[korig];
 
-	    if ( xs >= xsize_s ) xs = xsize_s-1;
-	    if ( xs < 0 ) xs = 0;
-	    if ( ys >= ysize_s ) ys = ysize_s-1;
-	    if ( ys < 0 ) ys = 0;
-	    int k = xs + ys*xsize_s;
-	    int val = dir[korig];
-	    double strength = gradient[korig];
+      assert ( val < eohimg.channels() );
 
-	    assert ( val < eohimg.numChannels );
-	    eohimg.data[val][k] += strength;
+      data[val][k] += strength;
 
-	    if ( !finite(eohimg.data[val][k]) ) {
-		fprintf (stderr, "EOH Image failed: %f\n", eohimg.data[val][k]);
-		exit(-1);
-	    }
-	}
+      if ( !finite ( data[val][k] ) ) {
+        fprintf ( stderr, "EOH Image failed: %f\n", data[val][k] );
+        exit ( -1 );
+      }
+    }
 
-    delete [] gradient;
-    delete [] dir;
+  delete [] gradient;
+  delete [] dir;
 
-    NICE::MultiChannelImageT<double> & eohintimg = ce->getDChannel ( CachedExample::D_INTEGRALEOH );
-    eohintimg.reInit ( xsize_s, ysize_s, numBins, true );
-    for ( uint i = 0 ; i < (uint)numBins ; i++ )
-	GenericImageTools::calcIntegralImage ( eohintimg.data[i], eohimg.data[i], xsize_s, ysize_s );
+  NICE::MultiChannelImageT<double> & eohintimg = ce->getDChannel ( CachedExample::D_INTEGRALEOH );
+  eohintimg.reInit ( xsize_s, ysize_s, numBins );
+  for ( uint i = 0 ; i < ( uint ) numBins ; i++ )
+  {
+    ImageT<double> tmp = eohimg[i];
+    GenericImageTools::calcIntegralImage ( tmp, tmp, xsize_s, ysize_s );
+  }
 
 }
 

+ 8 - 8
features/fpfeatures/FIGradients.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file FIGradients.h
 * @brief feature images storing gradient information
 * @author Erik Rodner
@@ -15,14 +15,14 @@ namespace OBJREC {
 
 class FIGradients {
 
-    public:
+  public:
 
-    static void buildEOHMap ( 
-	    CachedExample *ce,
-	    int subsamplex, 
-	    int subsampley,
-	    int numBins, 
-	    bool usesigned );
+    static void buildEOHMap (
+      CachedExample *ce,
+      int subsamplex,
+      int subsampley,
+      int numBins,
+      bool usesigned );
 
 };
 

+ 80 - 80
features/fpfeatures/FIHistograms.cpp

@@ -9,102 +9,102 @@ using namespace OBJREC;
 using namespace NICE;
 using namespace std;
 
-void FIHistograms::buildHSVMap ( 
-	    CachedExample *ce,
-	    int subsamplex, 
-	    int subsampley,
-	    int numBinsH, 
-	    int numBinsS,
-	    int numBinsV )
+void FIHistograms::buildHSVMap (
+  CachedExample *ce,
+  int subsamplex,
+  int subsampley,
+  int numBinsH,
+  int numBinsS,
+  int numBinsV )
 {
-    // build HSV image
-    // discrete !!
-    // build integral images
-
-    int numBins = numBinsH*numBinsS*numBinsV;
-    int xsize;
-    int ysize;
-    ce->getImageSize ( xsize, ysize );
-    
-    int xsize_s = xsize / subsamplex;
-    int ysize_s = ysize / subsampley;
-
-    if ( ! ce->colorInformationAvailable() ) {
-	fprintf (stderr, "FIHistograms: No color information available !\n");
-	exit(-1);
-    }
-
-    NICE::MultiChannelImageT<int> & colorimg = ce->getIChannel ( CachedExample::I_COLOR );
-    assert ( colorimg.numChannels == 3 );
-
-    NICE::MultiChannelImageT<double> hsvimg ( xsize, ysize, colorimg.numChannels, true );
+  // build HSV image
+  // discrete !!
+  // build integral images
 
-    ColorSpace::convert ( hsvimg, colorimg, 
-			  ColorSpace::COLORSPACE_HSL, 
-			  ColorSpace::COLORSPACE_RGB,
-			  1.0, 255.0 );
+  int numBins = numBinsH * numBinsS * numBinsV;
+  int xsize;
+  int ysize;
+  ce->getImageSize ( xsize, ysize );
 
-    int *discretecolor = new int [ xsize * ysize ];
+  int xsize_s = xsize / subsamplex;
+  int ysize_s = ysize / subsampley;
 
-    long k = 0;
-    for ( int y = 0 ; y < hsvimg.ysize ; y++ )
-	for ( int x = 0 ; x < hsvimg.xsize ; x++,k++ )
-	{
-	    double h = hsvimg.data[0][k];
-	    double s = hsvimg.data[1][k];
-	    double v = hsvimg.data[2][k];
+  if ( ! ce->colorInformationAvailable() ) {
+    fprintf ( stderr, "FIHistograms: No color information available !\n" );
+    exit ( -1 );
+  }
 
-	    int hbin = (int)(numBinsH * h);
-	    if ( hbin >= numBinsH ) hbin = numBinsH - 1;
-	    int sbin = (int)(numBinsS * s);
-	    if ( sbin >= numBinsS ) sbin = numBinsS - 1;
-	    int vbin = (int)(numBinsV * v);
-	    if ( vbin >= numBinsV ) vbin = numBinsV - 1;
+  NICE::MultiChannelImageT<int> & colorimg = ce->getIChannel ( CachedExample::I_COLOR );
+  assert ( colorimg.channels() == 3 );
 
-	    int bin = ( hbin*numBinsS + sbin )*numBinsV + vbin;
+  NICE::MultiChannelImageT<double> hsvimg ( xsize, ysize, colorimg.channels() );
 
-	    discretecolor[k] = bin;
-	}
+  ColorSpace::convert ( hsvimg, colorimg,
+                        ColorSpace::COLORSPACE_HSL,
+                        ColorSpace::COLORSPACE_RGB,
+                        1.0, 255.0 );
 
-    hsvimg.freeData();
+  int *discretecolor = new int [ xsize * ysize ];
 
-    NICE::MultiChannelImageT<double> & colorhist = ce->getDChannel ( CachedExample::D_INTEGRALCOLOR );
-    colorhist.reInit ( xsize_s, ysize_s, numBins, true );
-    colorhist.setAll ( 0 );
+  long k = 0;
+  for ( int y = 0 ; y < hsvimg.height() ; y++ )
+    for ( int x = 0 ; x < hsvimg.width() ; x++, k++ )
+    {
+      double h = hsvimg.get(x,y,0);
+      double s = hsvimg.get(x,y,1);
+      double v = hsvimg.get(x,y,2);
 
-    long korig = 0;
-    for ( int y = 0 ; y < ysize ; y++ )
-	for ( int x = 0 ; x < xsize ; x++,korig++ )
-	{
-	    int xs = x / subsamplex;
-	    int ys = y / subsampley;
+      int hbin = ( int ) ( numBinsH * h );
+      if ( hbin >= numBinsH ) hbin = numBinsH - 1;
+      int sbin = ( int ) ( numBinsS * s );
+      if ( sbin >= numBinsS ) sbin = numBinsS - 1;
+      int vbin = ( int ) ( numBinsV * v );
+      if ( vbin >= numBinsV ) vbin = numBinsV - 1;
 
-	    if ( xs >= xsize_s ) xs = xsize_s-1;
-	    if ( xs < 0 ) xs = 0;
-	    if ( ys >= ysize_s ) ys = ysize_s-1;
-	    if ( ys < 0 ) ys = 0;
-	    int k = xs + ys*xsize_s;
-	    int val = discretecolor[korig];
+      int bin = ( hbin * numBinsS + sbin ) * numBinsV + vbin;
 
-	    if ( val >= colorhist.numChannels )
-	    {
-		fprintf (stderr, "v %d nc %d\n", val, colorhist.numChannels );
-	    }
-	    colorhist.data[val][k] += 1;
+      discretecolor[k] = bin;
+    }
 
-	    if ( !finite(colorhist.data[val][k]) ) {
-		fprintf (stderr, "EOH Image failed: %f\n", colorhist.data[val][k]);
-		exit(-1);
-	    }
-	}
+  hsvimg.freeData();
+
+  NICE::MultiChannelImageT<double> & colorhist = ce->getDChannel ( CachedExample::D_INTEGRALCOLOR );
+  colorhist.reInit ( xsize_s, ysize_s, numBins);
+  colorhist.setAll ( 0 );
+
+  long korig = 0;
+  for ( int y = 0 ; y < ysize ; y++ )
+    for ( int x = 0 ; x < xsize ; x++, korig++ )
+    {
+      int xs = x / subsamplex;
+      int ys = y / subsampley;
+
+      if ( xs >= xsize_s ) xs = xsize_s - 1;
+      if ( xs < 0 ) xs = 0;
+      if ( ys >= ysize_s ) ys = ysize_s - 1;
+      if ( ys < 0 ) ys = 0;
+      int k = xs + ys * xsize_s;
+      int val = discretecolor[korig];
+
+      if ( val >= colorhist.channels() )
+      {
+        fprintf ( stderr, "v %d nc %d\n", val, colorhist.channels() );
+      }
+      colorhist[val](x,y) += 1;
+
+      if ( !finite ( colorhist[val](x,y) ) ) {
+        fprintf ( stderr, "EOH Image failed: %f\n", colorhist[val](x,y) );
+        exit ( -1 );
+      }
+    }
 
-    delete [] discretecolor;
+  delete [] discretecolor;
 
-    fprintf (stderr, "Calculating Integral Images\n");
+  fprintf ( stderr, "Calculating Integral Images\n" );
 
-    for ( uint i = 0 ; i < colorhist.numChannels ; i++ )
-	colorhist.calcIntegral ( i );
+  for ( uint i = 0 ; i < colorhist.channels() ; i++ )
+    colorhist.calcIntegral ( i );
 
-    fprintf (stderr, "FIGradients: finished\n");
+  fprintf ( stderr, "FIGradients: finished\n" );
 
 }

+ 191 - 187
features/fpfeatures/HOGFeature.cpp

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file HOGFeature.cpp
 * @brief histogram of oriented gradients ( dalal and triggs )
 * @author Erik Rodner
@@ -19,17 +19,17 @@ using namespace NICE;
 const double epsilon = 10e-8;
 
 /** simple constructor */
-HOGFeature::HOGFeature( const Config *conf )
+HOGFeature::HOGFeature ( const Config *conf )
 {
-    window_size_x = conf->gI("HOGFeature", "window_size_x", 21 );
-    window_size_y = conf->gI("HOGFeature", "window_size_y", 21 );
-    scaleStep = conf->gD("HOGFeature", "scale_step", sqrt(2) );
-    numScales = conf->gI("HOGFeature", "num_scales", 5 );
-    flexibleGrid = conf->gB("HOGFeature", "flexible_grid", false );
-
-    numBins = conf->gI("HOGFeature", "num_bins", 9 );
-    cellcountx = conf->gI("HOGFeature", "cellcountx", 10 );
-    cellcounty = conf->gI("HOGFeature", "cellcounty", 10 );
+  window_size_x = conf->gI ( "HOGFeature", "window_size_x", 21 );
+  window_size_y = conf->gI ( "HOGFeature", "window_size_y", 21 );
+  scaleStep = conf->gD ( "HOGFeature", "scale_step", sqrt ( 2 ) );
+  numScales = conf->gI ( "HOGFeature", "num_scales", 5 );
+  flexibleGrid = conf->gB ( "HOGFeature", "flexible_grid", false );
+
+  numBins = conf->gI ( "HOGFeature", "num_bins", 9 );
+  cellcountx = conf->gI ( "HOGFeature", "cellcountx", 10 );
+  cellcounty = conf->gI ( "HOGFeature", "cellcounty", 10 );
 }
 
 /** simple destructor */
@@ -37,207 +37,211 @@ HOGFeature::~HOGFeature()
 {
 }
 
-double HOGFeature::val( const Example *example ) const
+double HOGFeature::val ( const Example *example ) const
 {
-    const NICE::MultiChannelImageT<double> & img = 
-	example->ce->getDChannel ( CachedExample::D_INTEGRALEOH );
-    int tm_xsize = img.xsize;
-    int tm_ysize = img.ysize;
-
-    int xsize;
-    int ysize;
-    example->ce->getImageSize ( xsize, ysize );
-
-    /** without overlap: normalized cell and bin **/
-
-    int wsx2, wsy2;
-    int exwidth = example->width;
-    if ( exwidth == 0 ) {
-	wsx2 = window_size_x * tm_xsize / (2*xsize);
-	wsy2 = window_size_y * tm_ysize / (2*ysize);
-    } else {
-	int exheight = example->height;
-	wsx2 = exwidth * tm_xsize / (2*xsize);
-	wsy2 = exheight * tm_ysize / (2*ysize);
-    }
-	
-    int xx, yy;
-    xx = ( example->x ) * tm_xsize / xsize;
-    yy = ( example->y ) * tm_ysize / ysize;
-
-    assert ( (wsx2 > 0) && (wsy2 > 0) );
-
-    int xtl = xx - wsx2;
-    int ytl = yy - wsy2;
-    int xrb = xx + wsx2;
-    int yrb = yy + wsy2;
+  const NICE::MultiChannelImageT<double> & img =
+    example->ce->getDChannel ( CachedExample::D_INTEGRALEOH );
+  int tm_xsize = img.width();
+  int tm_ysize = img.height();
+
+  int xsize;
+  int ysize;
+  example->ce->getImageSize ( xsize, ysize );
+
+  /** without overlap: normalized cell and bin **/
+
+  int wsx2, wsy2;
+  int exwidth = example->width;
+  if ( exwidth == 0 ) 
+  {
+    wsx2 = window_size_x * tm_xsize / ( 2 * xsize );
+    wsy2 = window_size_y * tm_ysize / ( 2 * ysize );
+  } 
+  else 
+  {
+    int exheight = example->height;
+    wsx2 = exwidth * tm_xsize / ( 2 * xsize );
+    wsy2 = exheight * tm_ysize / ( 2 * ysize );
+  }
+
+  int xx, yy;
+  xx = ( example->x ) * tm_xsize / xsize;
+  yy = ( example->y ) * tm_ysize / ysize;
+
+  assert ( ( wsx2 > 0 ) && ( wsy2 > 0 ) );
+
+  int xtl = xx - wsx2;
+  int ytl = yy - wsy2;
+  int xrb = xx + wsx2;
+  int yrb = yy + wsy2;
 
 #define BOUND(x,min,max) (((x)<(min))?(min):((x)>(max)?(max):(x)))
-    xtl = BOUND ( xtl, 0, tm_xsize - 1 );
-    ytl = BOUND ( ytl, 0, tm_ysize - 1 );
-    xrb = BOUND ( xrb, 0, tm_xsize - 1 );
-    yrb = BOUND ( yrb, 0, tm_ysize - 1 );
+  xtl = BOUND ( xtl, 0, tm_xsize - 1 );
+  ytl = BOUND ( ytl, 0, tm_ysize - 1 );
+  xrb = BOUND ( xrb, 0, tm_xsize - 1 );
+  yrb = BOUND ( yrb, 0, tm_ysize - 1 );
 #undef BOUND
 
-    double stepx = (xrb - xtl) / (double)( cellcountx );
-    double stepy = (yrb - ytl) / (double)( cellcounty );
-    int cxtl = (int)(xtl + stepx*cellx1);
-    int cytl = (int)(ytl + stepy*celly1);
-    int cxrb = (int)(xtl + stepx*cellx2);
-    int cyrb = (int)(ytl + stepy*celly2);
-
-    if ( cxrb <= cxtl ) cxrb = cxtl+1;
-    if ( cyrb <= cytl ) cyrb = cytl+1;
-
-    double A,B,C,D;
-
-    assert ( bin < (int)img.numChannels );
-    assert ( img.data[bin] != NULL );
-
-    if ( (cxtl < 0) || (cxtl >= tm_xsize) )
-    {
-	fprintf (stderr, "cellcountx %d cellcounty %d\n", cellcountx, cellcounty );
-	fprintf (stderr, "cxtl %d tm_xsize %d xsize %d\n", cxtl, tm_xsize, xsize );
-	fprintf (stderr, "cellx1 %d stepx %f xtl %d xrb %d\n", cellx1, stepx, xtl, xrb );
-    }
-    if ( (cxrb < 0) || (cxrb >= tm_xsize) )
-    {
-	fprintf (stderr, "cellcountx %d cellcounty %d\n", cellcountx, cellcounty );
-	fprintf (stderr, "cxrb %d tm_xsize %d xsize %d\n", cxrb, tm_xsize, xsize );
-	fprintf (stderr, "cellx1 %d stepx %f xtl %d xrb %d\n", cellx1, stepx, xtl, xrb );
-    }
-    if ( (cytl < 0) || (cytl >= tm_ysize) )
-    {
-	fprintf (stderr, "cellcountx %d cellcounty %d\n", cellcountx, cellcounty );
-	fprintf (stderr, "cytl %d tm_ysize %d ysize %d\n", cytl, tm_ysize, ysize );
-	fprintf (stderr, "celly1 %d stepy %f ytl %d yrb %d\n", celly1, stepy, ytl, yrb );
-    }
-    if ( (cyrb < 0) || (cyrb >= tm_ysize) )
-    {
-	fprintf (stderr, "cellcountx %d cellcounty %d\n", cellcountx, cellcounty );
-	fprintf (stderr, "cyrb %d tm_ysize %d ysize %d\n", cyrb, tm_ysize, ysize );
-	fprintf (stderr, "celly1 %d stepy %f ytl %d yrb %d\n", celly1, stepy, ytl, yrb );
-    }
-
-    long kA = cxtl + cytl * tm_xsize;
-    long kB = cxrb + cytl * tm_xsize;
-    long kC = cxtl + cyrb * tm_xsize;
-    long kD = cxrb + cyrb * tm_xsize;
-    A = img.data[bin][ kA ];
-    B = img.data[bin][ kB ];
-    C = img.data[bin][ kC ];
-    D = img.data[bin][ kD ];
-
-    double val1 =  (D - B - C + A);
-    double sum = val1*val1;
-	for ( int b = 0 ; b < (int)img.numChannels ; b++)
-	{
-		if ( b == bin ) continue;
-		A = img.data[b][ kA ];
-		B = img.data[b][ kB ];
-		C = img.data[b][ kC ];
-		D = img.data[b][ kD ];
-		double val = ( D - B - C + A );
-		sum += val*val;
-	}
-    // FIXME: maybe L_1 normalization is sufficient
-    sum = sqrt(sum);
-    return ( val1 + epsilon ) / ( sum + epsilon );
+  double stepx = ( xrb - xtl ) / ( double ) ( cellcountx );
+  double stepy = ( yrb - ytl ) / ( double ) ( cellcounty );
+  int cxtl = ( int ) ( xtl + stepx * cellx1 );
+  int cytl = ( int ) ( ytl + stepy * celly1 );
+  int cxrb = ( int ) ( xtl + stepx * cellx2 );
+  int cyrb = ( int ) ( ytl + stepy * celly2 );
+
+  if ( cxrb <= cxtl ) cxrb = cxtl + 1;
+  if ( cyrb <= cytl ) cyrb = cytl + 1;
+
+  double A, B, C, D;
+
+  assert ( bin < ( int ) img.channels() );
+
+  if ( ( cxtl < 0 ) || ( cxtl >= tm_xsize ) )
+  {
+    fprintf ( stderr, "cellcountx %d cellcounty %d\n", cellcountx, cellcounty );
+    fprintf ( stderr, "cxtl %d tm_xsize %d xsize %d\n", cxtl, tm_xsize, xsize );
+    fprintf ( stderr, "cellx1 %d stepx %f xtl %d xrb %d\n", cellx1, stepx, xtl, xrb );
+  }
+  if ( ( cxrb < 0 ) || ( cxrb >= tm_xsize ) )
+  {
+    fprintf ( stderr, "cellcountx %d cellcounty %d\n", cellcountx, cellcounty );
+    fprintf ( stderr, "cxrb %d tm_xsize %d xsize %d\n", cxrb, tm_xsize, xsize );
+    fprintf ( stderr, "cellx1 %d stepx %f xtl %d xrb %d\n", cellx1, stepx, xtl, xrb );
+  }
+  if ( ( cytl < 0 ) || ( cytl >= tm_ysize ) )
+  {
+    fprintf ( stderr, "cellcountx %d cellcounty %d\n", cellcountx, cellcounty );
+    fprintf ( stderr, "cytl %d tm_ysize %d ysize %d\n", cytl, tm_ysize, ysize );
+    fprintf ( stderr, "celly1 %d stepy %f ytl %d yrb %d\n", celly1, stepy, ytl, yrb );
+  }
+  if ( ( cyrb < 0 ) || ( cyrb >= tm_ysize ) )
+  {
+    fprintf ( stderr, "cellcountx %d cellcounty %d\n", cellcountx, cellcounty );
+    fprintf ( stderr, "cyrb %d tm_ysize %d ysize %d\n", cyrb, tm_ysize, ysize );
+    fprintf ( stderr, "celly1 %d stepy %f ytl %d yrb %d\n", celly1, stepy, ytl, yrb );
+  }
+
+  long kA = cxtl + cytl * tm_xsize;
+  long kB = cxrb + cytl * tm_xsize;
+  long kC = cxtl + cyrb * tm_xsize;
+  long kD = cxrb + cyrb * tm_xsize;
+
+  A = img.get ( cxtl, cytl, bin );
+  B = img.get ( cxrb, cytl, bin );
+  C = img.get ( cxtl, cyrb, bin );
+  D = img.get ( cxrb, cyrb, bin );
+
+  double val1 = ( D - B - C + A );
+  double sum = val1 * val1;
+  for ( int b = 0 ; b < ( int ) img.channels() ; b++ )
+  {
+    if ( b == bin ) 
+      continue;
+    A = img.get ( cxtl, cytl, b );
+    B = img.get ( cxrb, cytl, b );
+    C = img.get ( cxtl, cyrb, b );
+    D = img.get ( cxrb, cyrb, b );
+    double val = ( D - B - C + A );
+    sum += val * val;
+  }
+  // FIXME: maybe L_1 normalization is sufficient
+  sum = sqrt ( sum );
+  return ( val1 + epsilon ) / ( sum + epsilon );
 }
 
 void HOGFeature::explode ( FeaturePool & featurePool, bool variableWindow ) const
 {
-    int nScales = (variableWindow ? numScales : 1 );
-
-    double weight = 1.0 / ( numBins * nScales );
-
-    if ( flexibleGrid ) 
-	weight *= 4.0 / ( cellcountx * (cellcountx - 1) * (cellcounty - 1) * cellcounty );
-    else
-	weight *= 1.0 / (cellcountx * cellcounty);
-
-    for ( int i = 0 ; i < nScales ; i++ )
-    {
-	int wsy = window_size_y;
-	int wsx = window_size_x;
-	for ( int _cellx1 = 0 ; _cellx1 < cellcountx ; _cellx1++ )
-	    for ( int _celly1 = 0 ; _celly1 < cellcounty ; _celly1++ )
-		for ( int _cellx2 = _cellx1+1 ; 
-			  _cellx2 < (flexibleGrid ? cellcountx : _cellx1+2) ; 
-			  _cellx2++ )
-		    for ( int _celly2 = _celly1+1 ; 
-			      _celly2 < (flexibleGrid ? cellcounty : 
-			      _celly1+2) ; _celly2++ )
-			for ( int _bin = 0 ; _bin < numBins ; _bin++ )
-			{
-			    HOGFeature *f = new HOGFeature();
-			    f->window_size_x = wsx;
-			    f->window_size_y = wsy;
-			    f->bin = _bin;
-			    f->cellx1 = _cellx1;
-			    f->celly1 = _celly1;
-			    f->cellx2 = _cellx2;
-			    f->celly2 = _celly2;
-			    f->cellcountx = cellcountx;
-			    f->cellcounty = cellcounty;
-			    featurePool.addFeature ( f, weight ); 
-			}
-	wsx = (int) (scaleStep * wsx);
-	wsy = (int) (scaleStep * wsy);
-    }
+  int nScales = ( variableWindow ? numScales : 1 );
+
+  double weight = 1.0 / ( numBins * nScales );
+
+  if ( flexibleGrid )
+    weight *= 4.0 / ( cellcountx * ( cellcountx - 1 ) * ( cellcounty - 1 ) * cellcounty );
+  else
+    weight *= 1.0 / ( cellcountx * cellcounty );
+
+  for ( int i = 0 ; i < nScales ; i++ )
+  {
+    int wsy = window_size_y;
+    int wsx = window_size_x;
+    for ( int _cellx1 = 0 ; _cellx1 < cellcountx ; _cellx1++ )
+      for ( int _celly1 = 0 ; _celly1 < cellcounty ; _celly1++ )
+        for ( int _cellx2 = _cellx1 + 1 ;
+              _cellx2 < ( flexibleGrid ? cellcountx : _cellx1 + 2 ) ;
+              _cellx2++ )
+          for ( int _celly2 = _celly1 + 1 ;
+                _celly2 < ( flexibleGrid ? cellcounty :
+                            _celly1 + 2 ) ; _celly2++ )
+            for ( int _bin = 0 ; _bin < numBins ; _bin++ )
+            {
+              HOGFeature *f = new HOGFeature();
+              f->window_size_x = wsx;
+              f->window_size_y = wsy;
+              f->bin = _bin;
+              f->cellx1 = _cellx1;
+              f->celly1 = _celly1;
+              f->cellx2 = _cellx2;
+              f->celly2 = _celly2;
+              f->cellcountx = cellcountx;
+              f->cellcounty = cellcounty;
+              featurePool.addFeature ( f, weight );
+            }
+    wsx = ( int ) ( scaleStep * wsx );
+    wsy = ( int ) ( scaleStep * wsy );
+  }
 }
 
 Feature *HOGFeature::clone() const
 {
-    HOGFeature *f = new HOGFeature();
-    f->window_size_x = window_size_x;
-    f->window_size_y = window_size_y;
-    f->bin = bin;
-    f->cellx1 = cellx1;
-    f->celly1 = celly1;
-    f->cellx2 = cellx2;
-    f->celly2 = celly2;
-    f->cellcountx = cellcountx;
-    f->cellcounty = cellcounty;
-    f->flexibleGrid = flexibleGrid;
-
-    return f;
+  HOGFeature *f = new HOGFeature();
+  f->window_size_x = window_size_x;
+  f->window_size_y = window_size_y;
+  f->bin = bin;
+  f->cellx1 = cellx1;
+  f->celly1 = celly1;
+  f->cellx2 = cellx2;
+  f->celly2 = celly2;
+  f->cellcountx = cellcountx;
+  f->cellcounty = cellcounty;
+  f->flexibleGrid = flexibleGrid;
+
+  return f;
 }
 
 Feature *HOGFeature::generateFirstParameter () const
 {
-    return clone();
+  return clone();
 }
 
-void HOGFeature::restore (istream & is, int format)
+void HOGFeature::restore ( istream & is, int format )
 {
-    is >> window_size_x;
-    is >> window_size_y;
-    is >> bin;
-    is >> cellx1;
-    is >> celly1;
+  is >> window_size_x;
+  is >> window_size_y;
+  is >> bin;
+  is >> cellx1;
+  is >> celly1;
 
-    is >> cellx2;
-    is >> celly2;
+  is >> cellx2;
+  is >> celly2;
 
-    is >> cellcountx;
-    is >> cellcounty;
+  is >> cellcountx;
+  is >> cellcounty;
 }
 
-void HOGFeature::store (ostream & os, int format) const
+void HOGFeature::store ( ostream & os, int format ) const
 {
-    os << "HOGFEATURE "
-       << window_size_x << " "
-       << window_size_y << " "
-       << bin << " "
-       << cellx1 << " "
-       << celly1 << " ";
-
-   os << cellx2 << " "
-      << celly2 << " ";
-
-    os << cellcountx << " "
-       << cellcounty;
+  os << "HOGFEATURE "
+  << window_size_x << " "
+  << window_size_y << " "
+  << bin << " "
+  << cellx1 << " "
+  << celly1 << " ";
+
+  os << cellx2 << " "
+  << celly2 << " ";
+
+  os << cellcountx << " "
+  << cellcounty;
 }
 
 void HOGFeature::clear ()

+ 8 - 4
features/fpfeatures/HaarFeature.cpp

@@ -89,9 +89,9 @@ double HaarFeature::val ( const Example *example ) const
 {
   const NICE::MultiChannelImageT<long> & img = example->ce->getLChannel ( CachedExample::L_INTEGRALIMAGE );
 
-  const long *integralImage = img.data[0];
-  int xsize = img.xsize;
-  int ysize = img.ysize;
+  //const long *integralImage = img.data[0];
+  int xsize = img.width();
+  int ysize = img.height();
 
   int x = example->x;
   int y = example->y;
@@ -127,6 +127,7 @@ double HaarFeature::val ( const Example *example ) const
   assert ( pos1 >= 0 );
   assert ( pos2 >= 0 );
 
+#if 0
   double value;
   if ( type == HaarFeature::HAARTYPE_HORIZONTAL )
   {
@@ -193,7 +194,10 @@ double HaarFeature::val ( const Example *example ) const
   }
 
   assert ( finite ( value ) );
-
+#else
+  throw("not yet adapted for new MultiChannelImageT!");
+  double value = 0.0;
+#endif
   return value;
 }
 

+ 163 - 168
features/fpfeatures/HistFeature.cpp

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file HistFeature.cpp
 * @brief histogram integral feature
 * @author Erik Rodner
@@ -21,22 +21,22 @@ using namespace NICE;
 const double epsilon = 10e-8;
 
 /** simple constructor */
-HistFeature::HistFeature( const Config *conf, 
-			  const std::string & section, 
-			  int _histtype,
-			  int _numBins )
+HistFeature::HistFeature ( const Config *conf,
+                           const std::string & section,
+                           int _histtype,
+                           int _numBins )
 {
-    window_size_x = conf->gI(section, "window_size_x", 21 );
-    window_size_y = conf->gI(section, "window_size_y", 21 );
-    scaleStep = conf->gD(section, "scale_step", sqrt(2) );
-    numScales = conf->gI(section, "num_scales", 5 );
+  window_size_x = conf->gI ( section, "window_size_x", 21 );
+  window_size_y = conf->gI ( section, "window_size_y", 21 );
+  scaleStep = conf->gD ( section, "scale_step", sqrt ( 2 ) );
+  numScales = conf->gI ( section, "num_scales", 5 );
 
-    flexibleGrid = conf->gB(section, "flexible_grid", false );
+  flexibleGrid = conf->gB ( section, "flexible_grid", false );
 
-    cellcountx = conf->gI(section, "cellcountx", 10 );
-    cellcounty = conf->gI(section, "cellcounty", 10 );
+  cellcountx = conf->gI ( section, "cellcountx", 10 );
+  cellcounty = conf->gI ( section, "cellcounty", 10 );
 
-    histtype = _histtype;
+  histtype = _histtype;
 }
 
 /** simple destructor */
@@ -44,185 +44,180 @@ HistFeature::~HistFeature()
 {
 }
 
-double HistFeature::val( const Example *example ) const
+double HistFeature::val ( const Example *example ) const
 {
-    const NICE::MultiChannelImageT<double> & img = example->ce->getDChannel ( histtype );
-    int tm_xsize = img.xsize;
-    int tm_ysize = img.ysize;
-
-    int xsize;
-    int ysize;
-    example->ce->getImageSize ( xsize, ysize );
-
-    /** without overlap: normalized cell and bin **/
-
-    int wsx2, wsy2;
-    int exwidth = example->width;
-    if ( exwidth == 0 ) {
-	wsx2 = window_size_x * tm_xsize / (2*xsize);
-	wsy2 = window_size_y * tm_ysize / (2*ysize);
-    } else {
-	int exheight = example->height;
-	wsx2 = exwidth * tm_xsize / (2*xsize);
-	wsy2 = exheight * tm_ysize / (2*ysize);
-    }
-	
-    int xx, yy;
-    xx = ( example->x ) * tm_xsize / xsize;
-    yy = ( example->y ) * tm_ysize / ysize;
-
-    assert ( (wsx2 > 0) && (wsy2 > 0) );
-
-    int xtl = xx - wsx2;
-    int ytl = yy - wsy2;
-    int xrb = xx + wsx2;
-    int yrb = yy + wsy2;
+  const NICE::MultiChannelImageT<double> & img = example->ce->getDChannel ( histtype );
+  int tm_xsize = img.width();
+  int tm_ysize = img.height();
+
+  int xsize;
+  int ysize;
+  example->ce->getImageSize ( xsize, ysize );
+
+  /** without overlap: normalized cell and bin **/
+
+  int wsx2, wsy2;
+  int exwidth = example->width;
+  if ( exwidth == 0 ) {
+    wsx2 = window_size_x * tm_xsize / ( 2 * xsize );
+    wsy2 = window_size_y * tm_ysize / ( 2 * ysize );
+  } else {
+    int exheight = example->height;
+    wsx2 = exwidth * tm_xsize / ( 2 * xsize );
+    wsy2 = exheight * tm_ysize / ( 2 * ysize );
+  }
+
+  int xx, yy;
+  xx = ( example->x ) * tm_xsize / xsize;
+  yy = ( example->y ) * tm_ysize / ysize;
+
+  assert ( ( wsx2 > 0 ) && ( wsy2 > 0 ) );
+
+  int xtl = xx - wsx2;
+  int ytl = yy - wsy2;
+  int xrb = xx + wsx2;
+  int yrb = yy + wsy2;
 
 #define BOUND(x,min,max) (((x)<(min))?(min):((x)>(max)?(max):(x)))
-    xtl = BOUND ( xtl, 0, tm_xsize - 1 );
-    ytl = BOUND ( ytl, 0, tm_ysize - 1 );
-    xrb = BOUND ( xrb, 0, tm_xsize - 1 );
-    yrb = BOUND ( yrb, 0, tm_ysize - 1 );
+  xtl = BOUND ( xtl, 0, tm_xsize - 1 );
+  ytl = BOUND ( ytl, 0, tm_ysize - 1 );
+  xrb = BOUND ( xrb, 0, tm_xsize - 1 );
+  yrb = BOUND ( yrb, 0, tm_ysize - 1 );
 #undef BOUND
 
-    double stepx = (xrb - xtl) / (double)( cellcountx );
-    double stepy = (yrb - ytl) / (double)( cellcounty );
-    int cxtl = (int)(xtl + stepx*cellx1);
-    int cytl = (int)(ytl + stepy*celly1);
-    int cxrb = (int)(xtl + stepx*cellx2);
-    int cyrb = (int)(ytl + stepy*celly2);
-
-    if ( cxrb <= cxtl ) cxrb = cxtl+1;
-    if ( cyrb <= cytl ) cyrb = cytl+1;
-
-    double A,B,C,D;
-
-    assert ( bin < (int)img.numChannels );
-    assert ( img.data[bin] != NULL );
-
-    long kA = cxtl + cytl * tm_xsize;
-    long kB = cxrb + cytl * tm_xsize;
-    long kC = cxtl + cyrb * tm_xsize;
-    long kD = cxrb + cyrb * tm_xsize;
-    A = img.data[bin][ kA ];
-    B = img.data[bin][ kB ];
-    C = img.data[bin][ kC ];
-    D = img.data[bin][ kD ];
-
-    double val1 =  (D - B - C + A);
-    double sum = val1*val1;
-    for ( int b = 0 ; b < (int)img.numChannels ; b++)
-    {
-	if ( b == bin ) continue;
-	A = img.data[b][ kA ];
-	B = img.data[b][ kB ];
-	C = img.data[b][ kC ];
-	D = img.data[b][ kD ];
-	double val = ( D - B - C + A );
-
-	if ( normalizationMethod == HISTFEATURE_NORMMETHOD_L2 )
-	    sum += val*val;
-	else if ( normalizationMethod == HISTFEATURE_NORMMETHOD_L1 )
-	    sum += val;
-    }
-    if ( normalizationMethod == HISTFEATURE_NORMMETHOD_L2 )
-	sum = sqrt(sum);
+  double stepx = ( xrb - xtl ) / ( double ) ( cellcountx );
+  double stepy = ( yrb - ytl ) / ( double ) ( cellcounty );
+  int cxtl = ( int ) ( xtl + stepx * cellx1 );
+  int cytl = ( int ) ( ytl + stepy * celly1 );
+  int cxrb = ( int ) ( xtl + stepx * cellx2 );
+  int cyrb = ( int ) ( ytl + stepy * celly2 );
+
+  if ( cxrb <= cxtl ) cxrb = cxtl + 1;
+  if ( cyrb <= cytl ) cyrb = cytl + 1;
+
+  double A, B, C, D;
+
+  assert ( bin < ( int ) img.channels() );
 
-    return ( val1 + epsilon ) / ( sum + epsilon );
+  A = img.get ( cxtl, cytl, bin );
+  B = img.get ( cxrb, cytl, bin );
+  C = img.get ( cxtl, cyrb, bin );
+  D = img.get ( cxrb, cyrb, bin );
+
+  double val1 = ( D - B - C + A );
+  double sum = val1 * val1;
+  for ( int b = 0 ; b < ( int ) img.channels() ; b++ )
+  {
+    if ( b == bin ) continue;
+    A = img.get ( cxtl, cytl, b );
+    B = img.get ( cxrb, cytl, b );
+    C = img.get ( cxtl, cyrb, b );
+    D = img.get ( cxrb, cyrb, b );
+    double val = ( D - B - C + A );
+
+    if ( normalizationMethod == HISTFEATURE_NORMMETHOD_L2 )
+      sum += val * val;
+    else if ( normalizationMethod == HISTFEATURE_NORMMETHOD_L1 )
+      sum += val;
+  }
+  if ( normalizationMethod == HISTFEATURE_NORMMETHOD_L2 )
+    sum = sqrt ( sum );
+
+  return ( val1 + epsilon ) / ( sum + epsilon );
 }
 
 void HistFeature::explode ( FeaturePool & featurePool, bool variableWindow ) const
 {
-    int nScales = (variableWindow ? numScales : 1 );
-
-    double weight = 1.0 / ( numBins * nScales );
-
-    if ( flexibleGrid ) 
-	weight *= 4.0 / ( cellcountx * (cellcountx - 1) * (cellcounty - 1) * cellcounty );
-    else
-	weight *= 1.0 / (cellcountx * cellcounty);
-
-    for ( int i = 0 ; i < nScales ; i++ )
-    {
-	int wsy = window_size_y;
-	int wsx = window_size_x;
-	for ( int _cellx1 = 0 ; _cellx1 < cellcountx ; _cellx1++ )
-	    for ( int _celly1 = 0 ; _celly1 < cellcounty ; _celly1++ )
-		for ( int _cellx2 = _cellx1+1 ; 
-			  _cellx2 < (flexibleGrid ? cellcountx : _cellx1+2) ; 
-			  _cellx2++ )
-		    for ( int _celly2 = _celly1+1 ; 
-			      _celly2 < (flexibleGrid ? cellcounty : 
-			      _celly1+2) ; _celly2++ )
-			for ( int _bin = 0 ; _bin < numBins ; _bin++ )
-			{
-			    HistFeature *f = new HistFeature();
-			    f->histtype = histtype;
-			    f->window_size_x = wsx;
-			    f->window_size_y = wsy;
-			    f->bin = _bin;
-			    f->cellx1 = _cellx1;
-			    f->celly1 = _celly1;
-			    f->cellx2 = _cellx2;
-			    f->celly2 = _celly2;
-			    f->cellcountx = cellcountx;
-			    f->cellcounty = cellcounty;
-			    featurePool.addFeature ( f, weight ); 
-			}
-	wsx = (int) (scaleStep * wsx);
-	wsy = (int) (scaleStep * wsy);
-    }
+  int nScales = ( variableWindow ? numScales : 1 );
+
+  double weight = 1.0 / ( numBins * nScales );
+
+  if ( flexibleGrid )
+    weight *= 4.0 / ( cellcountx * ( cellcountx - 1 ) * ( cellcounty - 1 ) * cellcounty );
+  else
+    weight *= 1.0 / ( cellcountx * cellcounty );
+
+  for ( int i = 0 ; i < nScales ; i++ )
+  {
+    int wsy = window_size_y;
+    int wsx = window_size_x;
+    for ( int _cellx1 = 0 ; _cellx1 < cellcountx ; _cellx1++ )
+      for ( int _celly1 = 0 ; _celly1 < cellcounty ; _celly1++ )
+        for ( int _cellx2 = _cellx1 + 1 ;
+              _cellx2 < ( flexibleGrid ? cellcountx : _cellx1 + 2 ) ;
+              _cellx2++ )
+          for ( int _celly2 = _celly1 + 1 ;
+                _celly2 < ( flexibleGrid ? cellcounty :
+                            _celly1 + 2 ) ; _celly2++ )
+            for ( int _bin = 0 ; _bin < numBins ; _bin++ )
+            {
+              HistFeature *f = new HistFeature();
+              f->histtype = histtype;
+              f->window_size_x = wsx;
+              f->window_size_y = wsy;
+              f->bin = _bin;
+              f->cellx1 = _cellx1;
+              f->celly1 = _celly1;
+              f->cellx2 = _cellx2;
+              f->celly2 = _celly2;
+              f->cellcountx = cellcountx;
+              f->cellcounty = cellcounty;
+              featurePool.addFeature ( f, weight );
+            }
+    wsx = ( int ) ( scaleStep * wsx );
+    wsy = ( int ) ( scaleStep * wsy );
+  }
 }
 
 Feature *HistFeature::clone() const
 {
-    HistFeature *f = new HistFeature();
-    f->histtype = histtype;
-    f->window_size_x = window_size_x;
-    f->window_size_y = window_size_y;
-    f->bin = bin;
-    f->cellx1 = cellx1;
-    f->celly1 = celly1;
-    f->cellx2 = cellx2;
-    f->celly2 = celly2;
-    f->cellcountx = cellcountx;
-    f->cellcounty = cellcounty;
-
-    return f;
+  HistFeature *f = new HistFeature();
+  f->histtype = histtype;
+  f->window_size_x = window_size_x;
+  f->window_size_y = window_size_y;
+  f->bin = bin;
+  f->cellx1 = cellx1;
+  f->celly1 = celly1;
+  f->cellx2 = cellx2;
+  f->celly2 = celly2;
+  f->cellcountx = cellcountx;
+  f->cellcounty = cellcounty;
+
+  return f;
 }
 
 Feature *HistFeature::generateFirstParameter () const
 {
-    return clone();
+  return clone();
 }
 
-void HistFeature::restore (istream & is, int format)
+void HistFeature::restore ( istream & is, int format )
 {
-    is >> histtype;
-    is >> window_size_x;
-    is >> window_size_y;
-    is >> bin;
-    is >> cellx1;
-    is >> celly1;
-    is >> cellx2;
-    is >> celly2;
-    is >> cellcountx;
-    is >> cellcounty;
+  is >> histtype;
+  is >> window_size_x;
+  is >> window_size_y;
+  is >> bin;
+  is >> cellx1;
+  is >> celly1;
+  is >> cellx2;
+  is >> celly2;
+  is >> cellcountx;
+  is >> cellcounty;
 }
 
-void HistFeature::store (ostream & os, int format) const
+void HistFeature::store ( ostream & os, int format ) const
 {
-    os << "HistFeature "
-       << histtype << " "
-       << window_size_x << " "
-       << window_size_y << " "
-       << bin << " "
-       << cellx1 << " "
-       << celly1 << " "
-       << cellx2 << " "
-       << celly2 << " "
-       << cellcountx << " "
-       << cellcounty;
+  os << "HistFeature "
+  << histtype << " "
+  << window_size_x << " "
+  << window_size_y << " "
+  << bin << " "
+  << cellx1 << " "
+  << celly1 << " "
+  << cellx2 << " "
+  << celly2 << " "
+  << cellcountx << " "
+  << cellcounty;
 }
 
 void HistFeature::clear ()

+ 53 - 58
features/fpfeatures/HistFeature.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file HistFeature.h
 * @brief histogram integral feature
 * @author Erik Rodner
@@ -10,7 +10,7 @@
 
 #include "core/vector/VectorT.h"
 #include "core/vector/MatrixT.h"
- 
+
 #include "core/basics/Config.h"
 #include "vislearning/cbaselib/Feature.h"
 
@@ -21,65 +21,60 @@ namespace OBJREC {
 class HistFeature : public Feature
 {
 
-    protected:
-
-	enum {
-	    HISTFEATURE_NORMMETHOD_L1 = 0,
-	    HISTFEATURE_NORMMETHOD_L2
-	};
-
-	/** @{ feature parameter */
-	int window_size_x;
-	int window_size_y;
-
-	int histtype;
-	int bin;
-	int cellx1;
-	int celly1;
-	int cellx2;
-	int celly2;
-	int cellcountx;
-	int cellcounty;
-	int normalizationMethod;
-
-	bool flexibleGrid;
-
-	/** @} */
-
-	/** @{ parameter for feature generation */
-	int numScales;
-	int numBins;
-	double scaleStep;
-	/** @} */
-
-    public:
-  
-	/** simple constructor */
-	HistFeature( const NICE::Config *conf, 
-		     // refactor-nice.pl: check this substitution
-		     // old: const std::string & section, 
-		     const std::string & section, 
-		     int _histtype,
-		     int _numBins);
-
-	/** internally used by HistFeature::explode */
-	HistFeature () {};
-      
-	/** simple destructor */
-	virtual ~HistFeature();
-     
-	double val( const Example *example ) const;
-	void explode ( FeaturePool & featurePool, bool variableWindow = true ) const;
-	Feature *clone() const;
-	Feature *generateFirstParameter () const;
-
-	void restore (std::istream & is, int format = 0);
-	void store (std::ostream & os, int format = 0) const;
-	void clear ();
-};
+  protected:
+
+    enum {
+      HISTFEATURE_NORMMETHOD_L1 = 0,
+      HISTFEATURE_NORMMETHOD_L2
+    };
+
+    /** @{ feature parameter */
+    int window_size_x;
+    int window_size_y;
+
+    int histtype;
+    int bin;
+    int cellx1;
+    int celly1;
+    int cellx2;
+    int celly2;
+    int cellcountx;
+    int cellcounty;
+    int normalizationMethod;
+
+    bool flexibleGrid;
 
+    /** @} */
 
+    /** @{ parameter for feature generation */
+    int numScales;
+    int numBins;
+    double scaleStep;
+    /** @} */
 
+  public:
+
+    /** simple constructor */
+    HistFeature ( const NICE::Config *conf,
+                  const std::string & section,
+                  int _histtype,
+                  int _numBins );
+
+    /** internally used by HistFeature::explode */
+    HistFeature () {};
+
+    /** simple destructor */
+    virtual ~HistFeature();
+
+    double val ( const Example *example ) const;
+    void explode ( FeaturePool & featurePool, bool variableWindow = true ) const;
+    Feature *clone() const;
+    Feature *generateFirstParameter () const;
+
+    void restore ( std::istream & is, int format = 0 );
+    void store ( std::ostream & os, int format = 0 ) const;
+    void clear ();
+};
 
 } // namespace
 

+ 180 - 173
features/fpfeatures/PixelPairFeature.cpp

@@ -14,219 +14,226 @@ const int lastColorchannel = 2;
 
 void PixelPairFeature::explode ( FeaturePool & featurePool, bool variableWindow ) const
 {
-	PixelPairFeature *f = new PixelPairFeature ( *this );
-	int firstchannel = ( imagetype == CachedExample::I_COLOR ) ? firstColorchannel : 0;
-	int lastchannel = ( imagetype == CachedExample::I_COLOR ) ? lastColorchannel : 0;
-
-	int wsx = window_size_x / 2;
-	int wsy = window_size_y / 2;
-	
-	int numberOfPairFeatures = (lastchannel - firstchannel + 1) * 
-		(2*wsx / step_x) * (2*wsy / step_y);
-
-	numberOfPairFeatures *= numberOfPairFeatures;
-
-	for ( int _type = PPTYPE_DIFF ; _type < PPTYPE_VALUE ; _type++ )
-	for ( int _x1 = -wsx ; _x1 < wsx ; _x1 += step_x )
-	for ( int _y1 = -wsy ; _y1 < wsy ; _y1 += step_y )
-	for ( int _b1 = firstchannel ; _b1 <= lastchannel ; _b1++ ) 
-	for ( int _x2 = -wsx ; _x2 < wsx ; _x2 += step_x )
-	for ( int _y2 = -wsy ; _y2 < wsy ; _y2 += step_y )
-	for ( int _b2 = firstchannel ; _b2 <= lastchannel ; _b2++ ) 
-	{
-		if ( (_b1 == _b2) && (_x1 == _x2) && (_y1 == _y2) ) continue;
-		f->x1 = _x1; f->y1 = _y1; f->b1 = _b1;
-		f->x2 = _x2; f->y2 = _y2; f->b2 = _b2;
-		f->type = _type;
-		featurePool.addFeature ( f->clone(), 1.0 / ((PPTYPE_VALUE - PPTYPE_DIFF) * numberOfPairFeatures) );
-	}
-
-	f->type = PPTYPE_VALUE;
-	for ( int _x1 = -wsx ; _x1 < wsx ; _x1 += step_x )
-	for ( int _y1 = -wsy ; _y1 < wsy ; _y1 += step_y )
-	for ( int _b1 = firstchannel ; _b1 <= lastchannel ; _b1++ ) 
-	{
-		f->x1 = _x1; f->y1 = _y1; f->b1 = _b1;
-		featurePool.addFeature ( f->clone(), 1.0 / numberOfPairFeatures );
-	}
-
-	delete f;
+  PixelPairFeature *f = new PixelPairFeature ( *this );
+  int firstchannel = ( imagetype == CachedExample::I_COLOR ) ? firstColorchannel : 0;
+  int lastchannel = ( imagetype == CachedExample::I_COLOR ) ? lastColorchannel : 0;
+
+  int wsx = window_size_x / 2;
+  int wsy = window_size_y / 2;
+
+  int numberOfPairFeatures = ( lastchannel - firstchannel + 1 ) *
+                             ( 2 * wsx / step_x ) * ( 2 * wsy / step_y );
+
+  numberOfPairFeatures *= numberOfPairFeatures;
+
+  for ( int _type = PPTYPE_DIFF ; _type < PPTYPE_VALUE ; _type++ )
+    for ( int _x1 = -wsx ; _x1 < wsx ; _x1 += step_x )
+      for ( int _y1 = -wsy ; _y1 < wsy ; _y1 += step_y )
+        for ( int _b1 = firstchannel ; _b1 <= lastchannel ; _b1++ )
+          for ( int _x2 = -wsx ; _x2 < wsx ; _x2 += step_x )
+            for ( int _y2 = -wsy ; _y2 < wsy ; _y2 += step_y )
+              for ( int _b2 = firstchannel ; _b2 <= lastchannel ; _b2++ )
+              {
+                if ( ( _b1 == _b2 ) && ( _x1 == _x2 ) && ( _y1 == _y2 ) ) continue;
+                f->x1 = _x1;
+                f->y1 = _y1;
+                f->b1 = _b1;
+                f->x2 = _x2;
+                f->y2 = _y2;
+                f->b2 = _b2;
+                f->type = _type;
+                featurePool.addFeature ( f->clone(), 1.0 / ( ( PPTYPE_VALUE - PPTYPE_DIFF ) * numberOfPairFeatures ) );
+              }
+
+  f->type = PPTYPE_VALUE;
+  for ( int _x1 = -wsx ; _x1 < wsx ; _x1 += step_x )
+    for ( int _y1 = -wsy ; _y1 < wsy ; _y1 += step_y )
+      for ( int _b1 = firstchannel ; _b1 <= lastchannel ; _b1++ )
+      {
+        f->x1 = _x1;
+        f->y1 = _y1;
+        f->b1 = _b1;
+        featurePool.addFeature ( f->clone(), 1.0 / numberOfPairFeatures );
+      }
+
+  delete f;
 }
 
 
 Feature *PixelPairFeature::clone() const
 {
-    PixelPairFeature *fp =  new PixelPairFeature(*this);
-    return fp;
+  PixelPairFeature *fp =  new PixelPairFeature ( *this );
+  return fp;
 }
 
 
 /************* PixelPairFeature **************/
-PixelPairFeature::PixelPairFeature( const Config *conf )
+PixelPairFeature::PixelPairFeature ( const Config *conf )
 {
-    window_size_x = conf->gI("PixelPairFeatures", "window_size_x", 24 );
-    window_size_y = conf->gI("PixelPairFeatures", "window_size_y", 24 );
-    step_x = conf->gI("PixelPairFeatures", "step_x", 1 );
-    step_y = conf->gI("PixelPairFeatures", "step_y", 1 );
-    bool use_color = conf->gB("PixelPairFeatures", "use_color", true );
-
-    if ( use_color ) {
-	imagetype = CachedExample::I_COLOR;
-    } else {
-	imagetype = CachedExample::I_GRAYVALUES;
-    }
+  window_size_x = conf->gI ( "PixelPairFeatures", "window_size_x", 24 );
+  window_size_y = conf->gI ( "PixelPairFeatures", "window_size_y", 24 );
+  step_x = conf->gI ( "PixelPairFeatures", "step_x", 1 );
+  step_y = conf->gI ( "PixelPairFeatures", "step_y", 1 );
+  bool use_color = conf->gB ( "PixelPairFeatures", "use_color", true );
+
+  if ( use_color ) {
+    imagetype = CachedExample::I_COLOR;
+  } else {
+    imagetype = CachedExample::I_GRAYVALUES;
+  }
 }
 
-PixelPairFeature::PixelPairFeature ( int _window_size_x,	
-			   int _window_size_y,
-			   int _step_x,
-			   int _step_y,
-			   int _imagetype )
+PixelPairFeature::PixelPairFeature ( int _window_size_x,
+                                     int _window_size_y,
+                                     int _step_x,
+                                     int _step_y,
+                                     int _imagetype )
 {
-    window_size_x = _window_size_x;
-    window_size_y = _window_size_y;
-    x1 = 0; y1 = 0; b1 = firstColorchannel;
-    x2 = 1; y1 = 0; b2 = firstColorchannel;
-    step_x = _step_x;
-    step_y = _step_y;
-    type = PixelPairFeature::PPTYPE_DIFF;
-    imagetype = _imagetype;
+  window_size_x = _window_size_x;
+  window_size_y = _window_size_y;
+  x1 = 0;
+  y1 = 0;
+  b1 = firstColorchannel;
+  x2 = 1;
+  y1 = 0;
+  b2 = firstColorchannel;
+  step_x = _step_x;
+  step_y = _step_y;
+  type = PixelPairFeature::PPTYPE_DIFF;
+  imagetype = _imagetype;
 }
 
 PixelPairFeature::~PixelPairFeature()
 {
 }
 
-double PixelPairFeature::val( const Example *example ) const
+double PixelPairFeature::val ( const Example *example ) const
 {
-    int xl = example->x;
-    int yl = example->y;
-    NICE::MultiChannelImageT<int> & img = example->ce->getIChannel ( imagetype );
-
-    int xx1 = x1;
-    int yy1 = y1;
-    int xx2 = x1;
-    int yy2 = x2;
-    int exwidth = example->width;
-    if ( exwidth != 0 )
-    {
-	int exheight = example->height;
-	xx1 = xx1 * exwidth / window_size_x;	
-	yy1 = yy1 * exheight / window_size_y;	
-	xx2 = xx2 * exwidth / window_size_x;	
-	yy2 = yy2 * exheight / window_size_y;	
-    }
-
-    int xsize = img.xsize;
-    int ysize = img.ysize;
-
-    const int *channel1 = img.data[b1];
-    int p1x = BOUND ( xl + xx1, 0, xsize-1 );
-    int p1y = BOUND ( yl + yy1, 0, ysize-1 );
-    long off1 = p1x + p1y*xsize;
-    int v1 = channel1[off1];
+  int xl = example->x;
+  int yl = example->y;
+  NICE::MultiChannelImageT<int> & img = example->ce->getIChannel ( imagetype );
+
+  int xx1 = x1;
+  int yy1 = y1;
+  int xx2 = x1;
+  int yy2 = x2;
+  int exwidth = example->width;
+  if ( exwidth != 0 )
+  {
+    int exheight = example->height;
+    xx1 = xx1 * exwidth / window_size_x;
+    yy1 = yy1 * exheight / window_size_y;
+    xx2 = xx2 * exwidth / window_size_x;
+    yy2 = yy2 * exheight / window_size_y;
+  }
+
+  int xsize = img.width();
+  int ysize = img.height();
+
+  int p1x = BOUND ( xl + xx1, 0, xsize - 1 );
+  int p1y = BOUND ( yl + yy1, 0, ysize - 1 );
+
+  int v1 = img.get(p1x,p1y,b1);
+
+  if ( type != PPTYPE_VALUE )
+  {
+    int p2x = BOUND ( xl + xx2, 0, xsize - 1 );
+    int p2y = BOUND ( yl + yy2, 0, ysize - 1 );
     
-    if ( type != PPTYPE_VALUE ) 
-    {
-	const int *channel2 = img.data[b2];
-
-	int p2x = BOUND ( xl + xx2, 0, xsize-1 );
-	int p2y = BOUND ( yl + yy2, 0, ysize-1 );
-	long off2 = p2x + p2y*xsize;
-	int v2 = channel2[off2];
-	
-	if ( type == PPTYPE_DIFF ) 
-	    return v1 - v2;
-	else if ( type == PPTYPE_ABSDIFF )
-	    return fabs(v1-v2);
-	else if ( type == PPTYPE_SUM )
-	    return v1 + v2;
-	else
-	    exit(-1);
-
-    } else {
-	return v1;
-    }
+    int v2 = img.get(p2x,p2y,b2);
+
+    if ( type == PPTYPE_DIFF )
+      return v1 - v2;
+    else if ( type == PPTYPE_ABSDIFF )
+      return fabs ( v1 -v2 );
+    else if ( type == PPTYPE_SUM )
+      return v1 + v2;
+    else
+      exit ( -1 );
+
+  } else {
+    return v1;
+  }
 }
 
-void PixelPairFeature::restore (istream & is, int format)
+void PixelPairFeature::restore ( istream & is, int format )
 {
-    is >> type;
-    is >> imagetype;
-    is >> window_size_x;
-    is >> window_size_y;
-    is >> x1;
-    is >> y1;
-    is >> b1;
-    is >> x2;
-    is >> y2;
-    is >> b2;
+  is >> type;
+  is >> imagetype;
+  is >> window_size_x;
+  is >> window_size_y;
+  is >> x1;
+  is >> y1;
+  is >> b1;
+  is >> x2;
+  is >> y2;
+  is >> b2;
 }
 
-void PixelPairFeature::store (ostream & os, int format) const
+void PixelPairFeature::store ( ostream & os, int format ) const
 {
-    os << "PIXELPAIRFEATURE" << " " << type << " " 
-       << imagetype << " "
-       << window_size_x << " " << window_size_y << " "
-       << " " << x1 << " " << y1 << " " << b1
-       << " " << x2 << " " << y2 << " " << b2;
+  os << "PIXELPAIRFEATURE" << " " << type << " "
+  << imagetype << " "
+  << window_size_x << " " << window_size_y << " "
+  << " " << x1 << " " << y1 << " " << b1
+  << " " << x2 << " " << y2 << " " << b2;
 }
 
 void PixelPairFeature::clear ()
 {
-    // nothing to do in my opinion
+  // nothing to do in my opinion
 }
 
 #if 0
 void PixelPairFeature::calcFeatureValues ( const Examples & examples,
-				    vector<int> & examples_selection,
-				    FeatureValuesUnsorted & values ) const
+    vector<int> & examples_selection,
+    FeatureValuesUnsorted & values ) const
 {
-    for ( vector<int>::const_iterator si = examples_selection.begin();
-				   si != examples_selection.end();
-				   si++ )
+  for ( vector<int>::const_iterator si = examples_selection.begin();
+        si != examples_selection.end();
+        si++ )
+  {
+    int index = *si;
+    const pair<int, Example> & p = examples[index];
+    int classno = p.first;
+    const Example & example = p.second;
+    double value = 0.0;
+
+    int xsize, ysize;
+    int xl = example.x - window_size_x / 2;
+    int yl = example.y - window_size_y / 2;
+
+    const double *channel1 = example.ce->getChannel ( b1, xsize, ysize );
+    int p1x = BOUND ( xl + x1, 0, xsize - 1 );
+    int p1y = BOUND ( yl + y1, 0, ysize - 1 );
+    long off1 = p1x + p1y * xsize;
+    double v1 = channel1[off1];
+
+
+    if ( type != PPTYPE_VALUE )
     {
-	int index = *si;
-	const pair<int, Example> & p = examples[index];
-	int classno = p.first;
-	const Example & example = p.second;
-	double value = 0.0;
-
-	int xsize, ysize;
-	int xl = example.x - window_size_x/2;
-        int yl = example.y - window_size_y/2;
-
-	const double *channel1 = example.ce->getChannel ( b1, xsize, ysize );
-	int p1x = BOUND ( xl + x1, 0, xsize-1 );
-	int p1y = BOUND ( yl + y1, 0, ysize-1 );
-	long off1 = p1x + p1y*xsize;
-	double v1 = channel1[off1];
-    
+      const double *channel2 = example.ce->getChannel ( b2, xsize, ysize );
+
+      int p2x = BOUND ( xl + x2, 0, xsize - 1 );
+      int p2y = BOUND ( yl + y2, 0, ysize - 1 );
+      long off2 = p2x + p2y * xsize;
+      double v2 = channel2[off2];
 
-	if ( type != PPTYPE_VALUE ) 
-	{
-	    const double *channel2 = example.ce->getChannel ( b2, xsize, ysize );
-
-	    int p2x = BOUND ( xl + x2, 0, xsize-1 );
-	    int p2y = BOUND ( yl + y2, 0, ysize-1 );
-	    long off2 = p2x + p2y*xsize;
-	    double v2 = channel2[off2];
-	    
-	    
-	    if ( type == PPTYPE_DIFF ) 
-		value = v1 - v2;
-	    else if ( type == PPTYPE_ABSDIFF )
-		value = fabs(v1-v2);
-	    else if ( type == PPTYPE_SUM )
-		value = v1 + v2;
-	} else {
-	    value = v1;
-	}
-
-	values.push_back ( quadruplet<double, int, int, double> ( 
-	    value, classno, index, example.weight ) );
+
+      if ( type == PPTYPE_DIFF )
+        value = v1 - v2;
+      else if ( type == PPTYPE_ABSDIFF )
+        value = fabs ( v1 - v2 );
+      else if ( type == PPTYPE_SUM )
+        value = v1 + v2;
+    } else {
+      value = v1;
     }
 
+    values.push_back ( quadruplet<double, int, int, double> (
+                         value, classno, index, example.weight ) );
+  }
+
 }
 #endif
 

+ 53 - 53
features/fpfeatures/PixelPairFeature.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file PixelPairFeature.h
 * @brief like in Shotton paper
 * @author Erik Rodner
@@ -22,60 +22,60 @@ namespace OBJREC {
 class PixelPairFeature : public Feature
 {
 
-    protected:
-	enum {
-	    PPTYPE_DIFF = 0,
-	    PPTYPE_ABSDIFF,
-	    PPTYPE_SUM,
-	    PPTYPE_VALUE
-	};
-
-	int type;
-	int imagetype;
-
-	int x1;
-	int y1;
-	int b1;
-
-	int x2;
-	int y2;
-	int b2;
-
-	int step_x;
-	int step_y;
-
-	int window_size_x;
-	int window_size_y;
-
-    public:
-  
-	/** simple constructor */
-	PixelPairFeature( const NICE::Config *conf );
-      
-	/** without memory wasting config */
-	PixelPairFeature ( int window_size_x,	
-		      int window_size_y,
-		      int step_x,
-		      int step_y,
-		      int imagetype );
-
-	/** simple destructor */
-	virtual ~PixelPairFeature();
-     
-	double val( const Example *example ) const;
-
-	void explode ( FeaturePool & featurePool, bool variableWindow = true ) const;
-
-	Feature *clone() const;
-	
-	void restore (std::istream & is, int format = 0);
-	void store (std::ostream & os, int format = 0) const;
-	void clear ();
+  protected:
+    enum {
+      PPTYPE_DIFF = 0,
+      PPTYPE_ABSDIFF,
+      PPTYPE_SUM,
+      PPTYPE_VALUE
+    };
+
+    int type;
+    int imagetype;
+
+    int x1;
+    int y1;
+    int b1;
+
+    int x2;
+    int y2;
+    int b2;
+
+    int step_x;
+    int step_y;
+
+    int window_size_x;
+    int window_size_y;
+
+  public:
+
+    /** simple constructor */
+    PixelPairFeature ( const NICE::Config *conf );
+
+    /** without memory wasting config */
+    PixelPairFeature ( int window_size_x,
+                       int window_size_y,
+                       int step_x,
+                       int step_y,
+                       int imagetype );
+
+    /** simple destructor */
+    virtual ~PixelPairFeature();
+
+    double val ( const Example *example ) const;
+
+    void explode ( FeaturePool & featurePool, bool variableWindow = true ) const;
+
+    Feature *clone() const;
+
+    void restore ( std::istream & is, int format = 0 );
+    void store ( std::ostream & os, int format = 0 ) const;
+    void clear ();
 
 #if 0
-	void calcFeatureValues ( const Examples & examples,
-				    std::vector<int> & examples_selection,
-				    FeatureValuesUnsorted & values ) const;
+    void calcFeatureValues ( const Examples & examples,
+                             std::vector<int> & examples_selection,
+                             FeatureValuesUnsorted & values ) const;
 #endif
 
 };

+ 121 - 117
features/fpfeatures/SemanticFeature.cpp

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file SemanticFeature.cpp
 * @brief texton feature similar to jamie shottons idea
 * @author Erik Rodner
@@ -18,26 +18,26 @@ using namespace NICE;
 
 
 /** simple constructor */
-SemanticFeature::SemanticFeature( const Config *conf, 
-				  const set<int> *_possibleClassNos )
+SemanticFeature::SemanticFeature ( const Config *conf,
+                                   const set<int> *_possibleClassNos )
     : possibleClassNos ( _possibleClassNos )
 {
-    window_size_x = conf->gI("SemanticFeature", "window_size_x", 21 );
-    window_size_y = conf->gI("SemanticFeature", "window_size_y", 21 );
-    scaleStep = conf->gD("SemanticFeature", "scale_step", sqrt(2) );
-    numScales = conf->gI("SemanticFeature", "num_scales", 5 );
-    end_shiftx = conf->gI("SemanticFeature", "end_shift_x", 40 );
-    end_shifty = conf->gI("SemanticFeature", "end_shift_y", 40 );
-    step_shiftx = conf->gI("SemanticFeature", "step_shift_x", 5 );
-    step_shifty = conf->gI("SemanticFeature", "step_shift_y", 5 );
-
-    shiftx = 0;
-    shifty = 0;
+  window_size_x = conf->gI ( "SemanticFeature", "window_size_x", 21 );
+  window_size_y = conf->gI ( "SemanticFeature", "window_size_y", 21 );
+  scaleStep = conf->gD ( "SemanticFeature", "scale_step", sqrt ( 2 ) );
+  numScales = conf->gI ( "SemanticFeature", "num_scales", 5 );
+  end_shiftx = conf->gI ( "SemanticFeature", "end_shift_x", 40 );
+  end_shifty = conf->gI ( "SemanticFeature", "end_shift_y", 40 );
+  step_shiftx = conf->gI ( "SemanticFeature", "step_shift_x", 5 );
+  step_shifty = conf->gI ( "SemanticFeature", "step_shift_y", 5 );
+
+  shiftx = 0;
+  shifty = 0;
 }
 
-SemanticFeature::SemanticFeature( const Config *conf )
+SemanticFeature::SemanticFeature ( const Config *conf )
 {
-    SemanticFeature ( conf, NULL );
+  SemanticFeature ( conf, NULL );
 }
 
 /** simple destructor */
@@ -45,137 +45,141 @@ SemanticFeature::~SemanticFeature()
 {
 }
 
-double SemanticFeature::val( const Example *example ) const
+double SemanticFeature::val ( const Example *example ) const
 {
-    const NICE::MultiChannelImageT<double> & img = example->ce->getDChannel (
-	CachedExample::D_INTEGRALPRIOR );
+  const NICE::MultiChannelImageT<double> & img = example->ce->getDChannel (
+        CachedExample::D_INTEGRALPRIOR );
 
-    int xsize;
-    int ysize;
-    example->ce->getImageSize ( xsize, ysize );
-    int tm_xsize = img.xsize;
-    int tm_ysize = img.ysize;
+  int xsize;
+  int ysize;
+  example->ce->getImageSize ( xsize, ysize );
+  int tm_xsize = img.width();
+  int tm_ysize = img.height();
 
 #if 0
-    int xtl = example->x - window_size_x/2;
-    int ytl = example->y - window_size_y/2;
-    int xrb = example->x + window_size_x/2;
-    int yrb = example->y + window_size_y/2;
-
-    xtl = xtl * tm_xsize / xsize;
-    ytl = ytl * tm_ysize / ysize;
-    xrb = xrb * tm_xsize / xsize;
-    yrb = yrb * tm_ysize / ysize;
+  int xtl = example->x - window_size_x / 2;
+  int ytl = example->y - window_size_y / 2;
+  int xrb = example->x + window_size_x / 2;
+  int yrb = example->y + window_size_y / 2;
+
+  xtl = xtl * tm_xsize / xsize;
+  ytl = ytl * tm_ysize / ysize;
+  xrb = xrb * tm_xsize / xsize;
+  yrb = yrb * tm_ysize / ysize;
 #endif
 
-    int wsx2 = window_size_x * tm_xsize / (2*xsize);
-    int wsy2 = window_size_y * tm_ysize / (2*ysize);
-    int xx = ( example->x + shiftx ) * tm_xsize / xsize;
-    int yy = ( example->y + shifty ) * tm_ysize / ysize;
-    int xtl = xx - wsx2;
-    int ytl = yy - wsy2;
-    int xrb = xx + wsx2;
-    int yrb = yy + wsy2;
+  int wsx2 = window_size_x * tm_xsize / ( 2 * xsize );
+  int wsy2 = window_size_y * tm_ysize / ( 2 * ysize );
+  int xx = ( example->x + shiftx ) * tm_xsize / xsize;
+  int yy = ( example->y + shifty ) * tm_ysize / ysize;
+  int xtl = xx - wsx2;
+  int ytl = yy - wsy2;
+  int xrb = xx + wsx2;
+  int yrb = yy + wsy2;
 
 #define BOUND(x,min,max) (((x)<(min))?(min):((x)>(max)?(max):(x)))
-    xtl = BOUND ( xtl, 0, tm_xsize - 1 );
-    ytl = BOUND ( ytl, 0, tm_ysize - 1 );
-    xrb = BOUND ( xrb, 0, tm_xsize - 1 );
-    yrb = BOUND ( yrb, 0, tm_ysize - 1 );
+  xtl = BOUND ( xtl, 0, tm_xsize - 1 );
+  ytl = BOUND ( ytl, 0, tm_ysize - 1 );
+  xrb = BOUND ( xrb, 0, tm_xsize - 1 );
+  yrb = BOUND ( yrb, 0, tm_ysize - 1 );
 #undef BOUND
 
-    double A,B,C,D;
-
-    A = img.data[classno][ xtl + ytl * tm_xsize ];
-    B = img.data[classno][ xrb + ytl * tm_xsize ];
-    C = img.data[classno][ xtl + yrb * tm_xsize ];
-    D = img.data[classno][ xrb + yrb * tm_xsize ];
-
-    int area = (xrb - xtl)*(yrb - ytl);
-    
-    /*******************************
-	    BE CAREFUL
-	THIS INCORPORATES POSTION
-	INFORMATION INDIRECTLY
-    ********************************/
-    
-    if ( area == 0 ) 
-	return 0.0;
-    else        
-       /* A B 
-	  C D  */
-	return (D - B - C + A) / area;
+  double A, B, C, D;
+
+  A = img.get(xtl,ytl,classno);
+  B = img.get(xrb,ytl,classno); 
+  C = img.get(xtl,yrb,classno);
+  D = img.get(xrb,yrb,classno);
+
+  int area = ( xrb - xtl ) * ( yrb - ytl );
+
+  /*******************************
+   BE CAREFUL
+  THIS INCORPORATES POSTION
+  INFORMATION INDIRECTLY
+  ********************************/
+
+  if ( area == 0 )
+  {
+    return 0.0;
+  }
+  else
+  {
+    /* A B
+    C D  */
+    return ( D - B - C + A ) / area;
+  }
 }
 
 void SemanticFeature::explode ( FeaturePool & featurePool, bool variableWindow ) const
 {
-    if ( possibleClassNos == NULL )
+  if ( possibleClassNos == NULL )
+  {
+    fprintf ( stderr, "SemanticFeature::explode: no classno set given !\n" );
+    exit ( -1 );
+  }
+  // use leaf nodes only !!
+  for ( set<int>::const_iterator k = possibleClassNos->begin();
+        k != possibleClassNos->end();
+        k++ )
+  {
+    for ( int sy = 0 ; sy <= end_shifty ; sy += step_shifty )
     {
-	fprintf (stderr, "SemanticFeature::explode: no classno set given !\n");
-	exit(-1);
-    }
-    // use leaf nodes only !!
-    for ( set<int>::const_iterator k = possibleClassNos->begin();
-				   k != possibleClassNos->end();
-				   k++ )
-    {
-	for ( int sy = 0 ; sy <= end_shifty ; sy += step_shifty )
-	{
-	    for ( int sx = 0 ; sx <= end_shiftx ; sx += step_shiftx )
-	    {
-		int wsy = window_size_y;
-		int wsx = window_size_x;
-		for ( int i = 0 ; i < numScales ; i++ )
-		{
-		    SemanticFeature *f = new SemanticFeature();
-		    f->classno = *k;
-		    f->window_size_x = wsx;
-		    f->window_size_y = wsy;
-		    f->shiftx = sx;
-		    f->shifty = sy;
-		    featurePool.addFeature ( f, step_shiftx * step_shifty / (double)( end_shiftx * end_shifty * possibleClassNos->size() ) ); 
-		    wsx = (int) (scaleStep * wsx);
-		    wsy = (int) (scaleStep * wsy);
-		}
-	    }
-	}
+      for ( int sx = 0 ; sx <= end_shiftx ; sx += step_shiftx )
+      {
+        int wsy = window_size_y;
+        int wsx = window_size_x;
+        for ( int i = 0 ; i < numScales ; i++ )
+        {
+          SemanticFeature *f = new SemanticFeature();
+          f->classno = *k;
+          f->window_size_x = wsx;
+          f->window_size_y = wsy;
+          f->shiftx = sx;
+          f->shifty = sy;
+          featurePool.addFeature ( f, step_shiftx * step_shifty / ( double ) ( end_shiftx * end_shifty * possibleClassNos->size() ) );
+          wsx = ( int ) ( scaleStep * wsx );
+          wsy = ( int ) ( scaleStep * wsy );
+        }
+      }
     }
+  }
 }
 
 Feature *SemanticFeature::clone() const
 {
-    SemanticFeature *f = new SemanticFeature();
-    f->window_size_x = window_size_x;
-    f->window_size_y = window_size_y;
-    f->classno = classno;
-    f->shiftx = shiftx;
-    f->shifty = shifty;
-
-    return f;
+  SemanticFeature *f = new SemanticFeature();
+  f->window_size_x = window_size_x;
+  f->window_size_y = window_size_y;
+  f->classno = classno;
+  f->shiftx = shiftx;
+  f->shifty = shifty;
+
+  return f;
 }
 
 Feature *SemanticFeature::generateFirstParameter () const
 {
-    return clone();
+  return clone();
 }
 
-void SemanticFeature::restore (istream & is, int format)
+void SemanticFeature::restore ( istream & is, int format )
 {
-    is >> window_size_x;
-    is >> window_size_y;
-    is >> shiftx;
-    is >> shifty;
-    is >> classno;
+  is >> window_size_x;
+  is >> window_size_y;
+  is >> shiftx;
+  is >> shifty;
+  is >> classno;
 }
 
-void SemanticFeature::store (ostream & os, int format) const
+void SemanticFeature::store ( ostream & os, int format ) const
 {
-    os << "SemanticFeature "
-       << window_size_x << " "
-       << window_size_y << " "
-       << shiftx << " "
-       << shifty << " "
-       << classno;
+  os << "SemanticFeature "
+  << window_size_x << " "
+  << window_size_y << " "
+  << shiftx << " "
+  << shifty << " "
+  << classno;
 }
 
 void SemanticFeature::clear ()

+ 47 - 47
features/fpfeatures/SemanticFeature.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file SemanticFeature.h
 * @brief texton feature similar to jamie shottons idea
 * @author Erik Rodner
@@ -21,52 +21,52 @@ namespace OBJREC {
 class SemanticFeature : public Feature
 {
 
-    protected:
-	/** @{ feature parameter */
-	int window_size_x;
-	int window_size_y;
-	int shiftx;
-	int shifty;
-	int classno;
-	/** @} */
-
-
-	/** @{ parameter for feature generation */
-	int numScales;
-	double scaleStep;
-	int maxdepth;
-
-	int end_shiftx;
-	int end_shifty;
-	int step_shiftx;
-	int step_shifty;
-	/** @} */
-
-	const std::set<int> *possibleClassNos;
-
-    public:
-  
-	/** simple constructor */
-	SemanticFeature( const NICE::Config *conf, 
-			 const std::set<int> *_possibleClassNos );
-
-	/** simple constructor */
-	SemanticFeature( const NICE::Config *conf );
-
-	/** internally used by SemanticFeature::explode */
-	SemanticFeature () {};
-      
-	/** simple destructor */
-	virtual ~SemanticFeature();
-     
-	double val( const Example *example ) const;
-	void explode ( FeaturePool & featurePool, bool variableWindow = true ) const;
-	Feature *clone() const;
-	Feature *generateFirstParameter () const;
-
-	void restore (std::istream & is, int format = 0);
-	void store (std::ostream & os, int format = 0) const;
-	void clear ();
+  protected:
+    /** @{ feature parameter */
+    int window_size_x;
+    int window_size_y;
+    int shiftx;
+    int shifty;
+    int classno;
+    /** @} */
+
+
+    /** @{ parameter for feature generation */
+    int numScales;
+    double scaleStep;
+    int maxdepth;
+
+    int end_shiftx;
+    int end_shifty;
+    int step_shiftx;
+    int step_shifty;
+    /** @} */
+
+    const std::set<int> *possibleClassNos;
+
+  public:
+
+    /** simple constructor */
+    SemanticFeature ( const NICE::Config *conf,
+                      const std::set<int> *_possibleClassNos );
+
+    /** simple constructor */
+    SemanticFeature ( const NICE::Config *conf );
+
+    /** internally used by SemanticFeature::explode */
+    SemanticFeature () {};
+
+    /** simple destructor */
+    virtual ~SemanticFeature();
+
+    double val ( const Example *example ) const;
+    void explode ( FeaturePool & featurePool, bool variableWindow = true ) const;
+    Feature *clone() const;
+    Feature *generateFirstParameter () const;
+
+    void restore ( std::istream & is, int format = 0 );
+    void store ( std::ostream & os, int format = 0 ) const;
+    void clear ();
 
 };
 

+ 221 - 221
features/localfeatures/LFColorSande.cpp

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file LFColorSande.cpp
 * @brief interface to ColorSande implementation
 * @author Erik Rodner
@@ -28,40 +28,40 @@ using namespace NICE;
 
 
 
-LFColorSande::LFColorSande( const Config *conf, std::string section )
+LFColorSande::LFColorSande ( const Config *conf, std::string section )
 {
-    c_binaryExecutable = conf->gS( section, "binaryExecutable", "/home/bachi/libs/van_de_sande/x86_64-linux-gcc/colorDescriptor" );
-    c_params = conf->gS(section, "params", "--descriptor opponentsift");
-	scales = conf->gS(section, "scales", "1+1.5+3.0+4.5+6");
-	
-	descriptor_size = conf->gI(section, "descriptor_size", -1 );
-    
-	usegrid = conf->gB(section, "usegrid", false);
-	
-	int g = conf->gI( section, "grid", 5);
-	std::ostringstream temp;
-	temp << g;
-	gridsize = temp.str();
-	
-    if ( descriptor_size <= 0 ) 
-    {
-		fprintf (stderr, "LFColorSande::LFColorSande: No descriptor size found in config -> self test\n");
-		/** get feature dimension **/
-		NICE::Image testimg (DESCSIZE_DUMMY);
-		VVector features;
-		VVector positions;
-		extractFeatures ( testimg, features, positions );
-		if ( features.size() <= 0 )
-			fthrow( Exception, "No features found in " << DESCSIZE_DUMMY << " picture.");
-		descriptor_size = features[0].size();
-
-		fprintf (stderr, "LFColorSande::LFColorSande Self Test features:%d dimension:%d\n", (int)features.size(), descriptor_size );
-    }
-
-    if ( descriptor_size != conf->gI("features", "descriptor_size", descriptor_size) )
-    {
-		cerr << "Warning: LFColorSande: descriptor sizes do not match !!!" << endl;
-	}
+  c_binaryExecutable = conf->gS ( section, "binaryExecutable", "/home/bachi/libs/van_de_sande/x86_64-linux-gcc/colorDescriptor" );
+  c_params = conf->gS ( section, "params", "--descriptor opponentsift" );
+  scales = conf->gS ( section, "scales", "1+1.5+3.0+4.5+6" );
+
+  descriptor_size = conf->gI ( section, "descriptor_size", -1 );
+
+  usegrid = conf->gB ( section, "usegrid", false );
+
+  int g = conf->gI ( section, "grid", 5 );
+  std::ostringstream temp;
+  temp << g;
+  gridsize = temp.str();
+
+  if ( descriptor_size <= 0 )
+  {
+    fprintf ( stderr, "LFColorSande::LFColorSande: No descriptor size found in config -> self test\n" );
+    /** get feature dimension **/
+    NICE::Image testimg ( DESCSIZE_DUMMY );
+    VVector features;
+    VVector positions;
+    extractFeatures ( testimg, features, positions );
+    if ( features.size() <= 0 )
+      fthrow ( Exception, "No features found in " << DESCSIZE_DUMMY << " picture." );
+    descriptor_size = features[0].size();
+
+    fprintf ( stderr, "LFColorSande::LFColorSande Self Test features:%d dimension:%d\n", ( int ) features.size(), descriptor_size );
+  }
+
+  if ( descriptor_size != conf->gI ( "features", "descriptor_size", descriptor_size ) )
+  {
+    cerr << "Warning: LFColorSande: descriptor sizes do not match !!!" << endl;
+  }
 }
 
 LFColorSande::~LFColorSande()
@@ -70,199 +70,199 @@ LFColorSande::~LFColorSande()
 
 int LFColorSande::getDescSize () const
 {
-    return descriptor_size;
+  return descriptor_size;
 }
 
-int LFColorSande::extractFeatures ( const NICE::Image & img, VVector & features, 
-				     VVector & positions ) const
+int LFColorSande::extractFeatures ( const NICE::Image & img, VVector & features,
+                                    VVector & positions ) const
 {
-	cerr << "Warning: LFColorSande is a color local feature implementation, but you are calling the gray-image version of extractFeatures" << endl;
-	NICE::ColorImage colorimg;
-	NICE::grayToRGB (img, &colorimg);
-	extractFeatures( colorimg, features, positions);
+  cerr << "Warning: LFColorSande is a color local feature implementation, but you are calling the gray-image version of extractFeatures" << endl;
+  NICE::ColorImage colorimg;
+  NICE::grayToRGB ( img, &colorimg );
+  extractFeatures ( colorimg, features, positions );
 
-	return 0;
+  return 0;
 }
 
 int LFColorSande::extractFeatures ( const NICE::ColorImage & img, VVector & features, VVector & positions ) const
 {
-	if(features.size() != positions.size())
-	{
-		positions.clear();
-	}
-	
-	bool delete_imgfile = false;
-	std::string imgfile = Globals::getCurrentImgFN();
-
-	fprintf (stderr, "imgfile: %s\n", imgfile.c_str());
-	if ( (imgfile.size() <= 0) || (( !StringTools::regexMatch ( imgfile, ".[Jj][pP][Gg]$" ) ) 
-		     && ( !StringTools::regexMatch ( imgfile, ".[Pp][Nn][Gg]$" ))))
-	{
-		
-		if ( imgfile.size() <= 0 )
-		{
-			imgfile = FileMgt::createTempFile ( "/tmp/osl_lfColorSande_input_%s.png" );
-			fprintf (stderr, "LFColorSande: write image to %s (write image)\n", imgfile.c_str() );
-			ImageFile imgf ( imgfile );
-			imgf.writer ( &img );
-		} else {
-			std::string tmpfile = FileMgt::createTempFile ( "/tmp/osl_lfColorSande_input_%s.png" );
-			fprintf (stderr, "LFColorSande: write image to %s (convert)\n", tmpfile.c_str() );
-
-			std::string convertcall = "convert " + imgfile + " " + tmpfile;
-			cerr << "convert call: " << convertcall << endl;
-			system ( convertcall.c_str() );
-
-			imgfile = tmpfile;
-		}
-	    
-		delete_imgfile = true;
-	}
-    
-	std::string outputfn  = FileMgt::createTempFile ( "/tmp/osl_lfColorSande_output_%s" ) ;
-
-	std::string gridparams ="";
-	
-	if(usegrid)
-		gridparams = " --detector densesampling --ds_spacing " + gridsize +" --ds_scales "+scales;
-	
-	std::string call = c_binaryExecutable + " " +
-			   imgfile            + " " +   
-			   c_params           +
-			   gridparams         +
-			   " -output "        + outputfn;
-
-	cerr << "LFColorSande: parameters: <" << c_params+gridparams << ">" << endl;
-	clog << "Systemcall: " << call << endl;
-
-	
-	const int buffersize = 65536;
-	char *buffer = new char [buffersize];
-	FILE *f = popen ( call.c_str(), "r" );
-	if ( f == NULL )
-	{
-		fthrow(Exception, "Unable to run the implementation of van de Sande: " << call << endl << strerror(errno) );
-	}
-
-	while ( ! feof(f) ) 
-	{
-		if ( fgets ( buffer, buffersize, f ) <= 0 )
-		{
-			break;
-		} else {
-			fprintf (stderr, "LFColorSande::extractFeatures: [INFO] %s", buffer );
-		}
-	}
- 
-
-	pclose(f);
-
-	f = fopen ( outputfn.c_str(), "r" );
-	if ( f == NULL )
-	{
-		fthrow( Exception, "Unable to read output of van de Sande implementation\n");
-	}
-
-	if ( fgets ( buffer, buffersize, f ) <= 0 )
-	{
-		fprintf (stderr, "LFColorSande::extractFeatures: output is empty !\n");
-		fprintf (stderr, "img %s out %s\n", imgfile.c_str(), outputfn.c_str() );
-		fprintf (stderr, "call %s\n", call.c_str() );
-
-		exit(-1);
-	}
-
-	if ( ! strcmp(buffer, "KOEN1" ) ) 
-	{
-		fprintf (stderr, "LFColorSande::extractFeatures: wrong file format\n");
-		fprintf (stderr, "img %s out %s\n", imgfile.c_str(), outputfn.c_str() );
-		fprintf (stderr, "call %s\n", call.c_str() );
-
-		exit(-1);
-	}
-    
-    
-	fgets ( buffer, buffersize, f );
-	int dimension = atoi (buffer);
-	fprintf (stderr, "LFColorSande: descriptor dimension = %d\n", dimension );
-
-	if ( (descriptor_size > 0) && (dimension != descriptor_size) )
-	{
-		fprintf (stderr, "LFColorSande::extractFeatures: dimensions do not match %d -> %d!\n",
-			 dimension, descriptor_size);
-		fprintf (stderr, "img %s out %s\n", imgfile.c_str(), outputfn.c_str() );
-		fprintf (stderr, "call %s\n", call.c_str() );
-		fprintf (stderr, "dimension std::string buffer: \"%s\"", buffer );
-		exit(-1);
-	}
-
-	fgets ( buffer, buffersize, f );
-	int noDesc = atoi (buffer);
-
-	fprintf (stderr, "LFColorSande::extractFeatures: no. of descriptors = %d\n", noDesc );
- 
-	NICE::Vector x;
-	while ( ! feof(f) ) 
-	{
-	// <CIRCLE 119 307 1.26134 0 0.00014763>; 0 0 6 2 0 6 25 7 9 4 4 0 0 4 20 36 78 4 5 0 0 
-		if ( fgets(buffer, buffersize, f) == NULL )
-			break;
-
-		const char *buffer_data = strchr ( buffer, ';' );
-		if ( strlen(buffer_data) <= 0 )
-		{
-			fprintf (stderr, "LFColorSande::extractFeatures: it seems you forget to specify a descriptor\n");
-			exit(-1);
-		}
-
-		const char *buffer_key_start = strchr ( buffer, ' ' );
-		const char *buffer_key_end = strchr ( buffer, '>' );
-		buffer_key_start++;
-		int keylen = buffer_key_end - buffer_key_start;
-		char *key = new char [keylen+1];
-		strncpy ( key, buffer_key_start, keylen );
-		key[keylen] = '\0';
-
-		buffer_data+=2;
-
-		std::string buffer_data_s (buffer_data);
-
-		//clog << "[log] buffer = " << buffer_data_s << endl;		
-		
-		StringTools::splitVector ( buffer_data_s, ' ', x );
-		if ( (int)x.size() != dimension ) 
-		{
-			cerr << "Line = " << buffer_data_s << endl;
-			cerr << "Vector = " << x << endl;
-			cerr << "dimension = " << dimension << endl;
-			cerr << "x.size() = " << x.size() << endl;
-			fprintf (stderr, "LFColorSande::extractFeatures: error parsing output !!\n");
-			exit(-1);
-		} else {
-			NICE::Vector pos;
-
-			StringTools::splitVector ( key, ' ', pos );
-
-			if ( pos.size() != 5 ) {
-				fprintf (stderr, "LFColorSande::extractFeatures: dimension mismatch (position information)\n");
-				exit(-1);
-			}
-			// Van De Sande verwendet MatLab-Darstellung der Koordinaten. Diese fangen bei 1 an und nicht bei 0.
-			pos[0] --;
-			pos[1] --;
-			positions.push_back( pos );
-			features.push_back ( x );
-		}
-	}
-
-	fclose (f);
-
-	if ( delete_imgfile )
-		FileMgt::deleteTempFile ( imgfile );
-
-	FileMgt::deleteTempFile ( outputfn );
-
-	delete [] buffer;
-
-	return 0;
+  if ( features.size() != positions.size() )
+  {
+    positions.clear();
+  }
+
+  bool delete_imgfile = false;
+  std::string imgfile = Globals::getCurrentImgFN();
+
+  fprintf ( stderr, "imgfile: %s\n", imgfile.c_str() );
+  if ( ( imgfile.size() <= 0 ) || ( ( !StringTools::regexMatch ( imgfile, ".[Jj][pP][Gg]$" ) )
+                                    && ( !StringTools::regexMatch ( imgfile, ".[Pp][Nn][Gg]$" ) ) ) )
+  {
+
+    if ( imgfile.size() <= 0 )
+    {
+      imgfile = FileMgt::createTempFile ( "/tmp/osl_lfColorSande_input_%s.png" );
+      fprintf ( stderr, "LFColorSande: write image to %s (write image)\n", imgfile.c_str() );
+      ImageFile imgf ( imgfile );
+      imgf.writer ( &img );
+    } else {
+      std::string tmpfile = FileMgt::createTempFile ( "/tmp/osl_lfColorSande_input_%s.png" );
+      fprintf ( stderr, "LFColorSande: write image to %s (convert)\n", tmpfile.c_str() );
+
+      std::string convertcall = "convert " + imgfile + " " + tmpfile;
+      cerr << "convert call: " << convertcall << endl;
+      system ( convertcall.c_str() );
+
+      imgfile = tmpfile;
+    }
+
+    delete_imgfile = true;
+  }
+
+  std::string outputfn  = FileMgt::createTempFile ( "/tmp/osl_lfColorSande_output_%s" ) ;
+
+  std::string gridparams = "";
+
+  if ( usegrid )
+    gridparams = " --detector densesampling --ds_spacing " + gridsize + " --ds_scales " + scales;
+
+  std::string call = c_binaryExecutable + " " +
+                     imgfile            + " " +
+                     c_params           +
+                     gridparams         +
+                     " -output "        + outputfn;
+
+  cerr << "LFColorSande: parameters: <" << c_params + gridparams << ">" << endl;
+  clog << "Systemcall: " << call << endl;
+
+
+  const int buffersize = 65536;
+  char *buffer = new char [buffersize];
+  FILE *f = popen ( call.c_str(), "r" );
+  if ( f == NULL )
+  {
+    fthrow ( Exception, "Unable to run the implementation of van de Sande: " << call << endl << strerror ( errno ) );
+  }
+
+  while ( ! feof ( f ) )
+  {
+    if ( fgets ( buffer, buffersize, f ) <= 0 )
+    {
+      break;
+    } else {
+      fprintf ( stderr, "LFColorSande::extractFeatures: [INFO] %s", buffer );
+    }
+  }
+
+
+  pclose ( f );
+
+  f = fopen ( outputfn.c_str(), "r" );
+  if ( f == NULL )
+  {
+    fthrow ( Exception, "Unable to read output of van de Sande implementation\n" );
+  }
+
+  if ( fgets ( buffer, buffersize, f ) <= 0 )
+  {
+    fprintf ( stderr, "LFColorSande::extractFeatures: output is empty !\n" );
+    fprintf ( stderr, "img %s out %s\n", imgfile.c_str(), outputfn.c_str() );
+    fprintf ( stderr, "call %s\n", call.c_str() );
+
+    exit ( -1 );
+  }
+
+  if ( ! strcmp ( buffer, "KOEN1" ) )
+  {
+    fprintf ( stderr, "LFColorSande::extractFeatures: wrong file format\n" );
+    fprintf ( stderr, "img %s out %s\n", imgfile.c_str(), outputfn.c_str() );
+    fprintf ( stderr, "call %s\n", call.c_str() );
+
+    exit ( -1 );
+  }
+
+
+  fgets ( buffer, buffersize, f );
+  int dimension = atoi ( buffer );
+  fprintf ( stderr, "LFColorSande: descriptor dimension = %d\n", dimension );
+
+  if ( ( descriptor_size > 0 ) && ( dimension != descriptor_size ) )
+  {
+    fprintf ( stderr, "LFColorSande::extractFeatures: dimensions do not match %d -> %d!\n",
+              dimension, descriptor_size );
+    fprintf ( stderr, "img %s out %s\n", imgfile.c_str(), outputfn.c_str() );
+    fprintf ( stderr, "call %s\n", call.c_str() );
+    fprintf ( stderr, "dimension std::string buffer: \"%s\"", buffer );
+    exit ( -1 );
+  }
+
+  fgets ( buffer, buffersize, f );
+  int noDesc = atoi ( buffer );
+
+  fprintf ( stderr, "LFColorSande::extractFeatures: no. of descriptors = %d\n", noDesc );
+
+  NICE::Vector x;
+  while ( ! feof ( f ) )
+  {
+    // <CIRCLE 119 307 1.26134 0 0.00014763>; 0 0 6 2 0 6 25 7 9 4 4 0 0 4 20 36 78 4 5 0 0
+    if ( fgets ( buffer, buffersize, f ) == NULL )
+      break;
+
+    const char *buffer_data = strchr ( buffer, ';' );
+    if ( strlen ( buffer_data ) <= 0 )
+    {
+      fprintf ( stderr, "LFColorSande::extractFeatures: it seems you forget to specify a descriptor\n" );
+      exit ( -1 );
+    }
+
+    const char *buffer_key_start = strchr ( buffer, ' ' );
+    const char *buffer_key_end = strchr ( buffer, '>' );
+    buffer_key_start++;
+    int keylen = buffer_key_end - buffer_key_start;
+    char *key = new char [keylen+1];
+    strncpy ( key, buffer_key_start, keylen );
+    key[keylen] = '\0';
+
+    buffer_data += 2;
+
+    std::string buffer_data_s ( buffer_data );
+
+    //clog << "[log] buffer = " << buffer_data_s << endl;
+
+    StringTools::splitVector ( buffer_data_s, ' ', x );
+    if ( ( int ) x.size() != dimension )
+    {
+      cerr << "Line = " << buffer_data_s << endl;
+      cerr << "Vector = " << x << endl;
+      cerr << "dimension = " << dimension << endl;
+      cerr << "x.size() = " << x.size() << endl;
+      fprintf ( stderr, "LFColorSande::extractFeatures: error parsing output !!\n" );
+      exit ( -1 );
+    } else {
+      NICE::Vector pos;
+
+      StringTools::splitVector ( key, ' ', pos );
+
+      if ( pos.size() != 5 ) {
+        fprintf ( stderr, "LFColorSande::extractFeatures: dimension mismatch (position information)\n" );
+        exit ( -1 );
+      }
+      // Van De Sande verwendet MatLab-Darstellung der Koordinaten. Diese fangen bei 1 an und nicht bei 0.
+      pos[0] --;
+      pos[1] --;
+      positions.push_back ( pos );
+      features.push_back ( x );
+    }
+  }
+
+  fclose ( f );
+
+  if ( delete_imgfile )
+    FileMgt::deleteTempFile ( imgfile );
+
+  FileMgt::deleteTempFile ( outputfn );
+
+  delete [] buffer;
+
+  return 0;
 }

+ 49 - 49
features/localfeatures/LFColorSande.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file LFColorSande.h
 * @brief interface to ColorSande implementation
 * @author Erik Rodner
@@ -14,7 +14,7 @@
 
 #include "LocalFeatureRepresentation.h"
 #include "core/basics/Config.h"
-  
+
 
 namespace OBJREC {
 
@@ -22,53 +22,53 @@ namespace OBJREC {
 class LFColorSande : public LocalFeatureRepresentation
 {
 
-    protected:
-		std::string c_binaryExecutable;
-		std::string c_params;
-		double c_minScale;
-		
-		//! size of the descriptor
-		int descriptor_size;
-		
-		//! use grid for SIFT Positions
-		bool usegrid;
-	
-		//! size of the grid
-		std::string gridsize;
-	
-		//! used scales
-		std::string scales;
-		
-    public:
-  
-		/** simple constructor */
-		LFColorSande( const NICE::Config *conf, std::string section = "LFColorSande" );
-		  
-		/** simple destructor */
-		virtual ~LFColorSande();
-		
-		int getDescSize () const;
-		
-		/**
-		 * get the colorSIFT features
-		 * @param img grayvalue input image
-		 * @param features features (output)
-		 * @param positions position of the features
-		 * @return 
-		 */
-		int extractFeatures ( const NICE::Image & img, NICE::VVector & features, 
-					  NICE::VVector & positions ) const;
-		
-		/**
-		 * get the colorSIFT features
-		 * @param img color input image
-		 * @param features features (output)
-		 * @param positions position of the features
-		 * @return 
-		 */
-		int extractFeatures ( const NICE::ColorImage & img, NICE::VVector & features, 
-					  NICE::VVector & positions ) const;
-		 
+  protected:
+    std::string c_binaryExecutable;
+    std::string c_params;
+    double c_minScale;
+
+    //! size of the descriptor
+    int descriptor_size;
+
+    //! use grid for SIFT Positions
+    bool usegrid;
+
+    //! size of the grid
+    std::string gridsize;
+
+    //! used scales
+    std::string scales;
+
+  public:
+
+    /** simple constructor */
+    LFColorSande ( const NICE::Config *conf, std::string section = "LFColorSande" );
+
+    /** simple destructor */
+    virtual ~LFColorSande();
+
+    int getDescSize () const;
+
+    /**
+     * get the colorSIFT features
+     * @param img grayvalue input image
+     * @param features features (output)
+     * @param positions position of the features
+     * @return
+     */
+    int extractFeatures ( const NICE::Image & img, NICE::VVector & features,
+                          NICE::VVector & positions ) const;
+
+    /**
+     * get the colorSIFT features
+     * @param img color input image
+     * @param features features (output)
+     * @param positions position of the features
+     * @return
+     */
+    int extractFeatures ( const NICE::ColorImage & img, NICE::VVector & features,
+                          NICE::VVector & positions ) const;
+
 };
 
 

+ 16 - 1
features/localfeatures/LFColorWeijer.cpp

@@ -438,6 +438,21 @@ void LFColorWeijer::visualizeFeatures( const NICE::ColorImage & cimg, NICE::Colo
   }
 
   getDescriptors( cimg, pos, feats );
+  
+  //heatmap for a special class
+  /*ofstream fout("out.txt");
+  
+  int counter = 0;
+  for ( int y = 0; y < cimg.height(); y++ )
+  {
+    for ( int x = 0; x < cimg.width(); x++, counter++ )
+    {
+      fout << feats[counter][8] << " ";
+    }
+  }
+  cout << "counter: " << counter << " feats.size(): " << feats.size() << endl;
+  
+  fout.close();*/
 
   out.resize( cimg.width(), cimg.height() );
   out.set( 0, 0, 0 );
@@ -462,7 +477,7 @@ void LFColorWeijer::getFeats( const ColorImage &img, MultiChannelImageT<double>
 {
   int width = ( int )img.width();
   int height = ( int )img.height();
-  feats.reInit( width, height, hist.size(), true );
+  feats.reInit( width, height, hist.size());
 
   NICE::MultiChannelImageT<double> genimg, imglab;
 

+ 19 - 19
features/localfeatures/progs/testColorWeijer.cpp

@@ -11,24 +11,24 @@ using namespace NICE;
 using namespace OBJREC;
 
 int main(int argc, char **argv)
-{	
-	if(argc < 1)
-	{
-		cerr << "Bitte Bild angeben" << endl;
-		return -1;
-	}
-	
-	Config *conf = new Config();
-	LFColorWeijer lfc(conf);
-		
-	//! testen
-	ColorImage cimg(argv[1]);
-	ColorImage out;
-	lfc.visualizeFeatures (cimg,out);
-	
-	cimg.writePPM("org.ppm");
-	out.writePPM("out.ppm");
-	
-	return 0;
+{
+  if (argc < 1)
+  {
+    cerr << "Bitte Bild angeben" << endl;
+    return -1;
+  }
+
+  Config *conf = new Config();
+  LFColorWeijer lfc(conf);
+
+  //! testen
+  ColorImage cimg(argv[1]);
+  ColorImage out;
+  lfc.visualizeFeatures (cimg, out);
+
+  cimg.writePPM("org.ppm");
+  out.writePPM("out.ppm");
+
+  return 0;
 }
 

+ 2 - 5
image/GenericImageTools.h

@@ -3,14 +3,12 @@
 * @brief simple filter stuff
 * @author Erik Rodner
 * @date 07/30/2008
-
 */
 #ifndef GENERICIMAGETOOLSINCLUDE
 #define GENERICIMAGETOOLSINCLUDE
 
 #include "core/image/MultiChannelImageT.h"
 
-
 namespace OBJREC {
 
 /** simple filter stuff */
@@ -19,15 +17,14 @@ class GenericImageTools
     public:
 
     template <class PixelValueDst, class PixelValueSrc>
-    static void calcIntegralImage ( PixelValueDst *integral, const PixelValueSrc *image, int xsize, int ysize );
+    static void calcIntegralImage ( NICE::ImageT<PixelValueDst> &integralImage, const NICE::ImageT<PixelValueSrc> &image, int xsize, int ysize );
 
     template <class PixelValueDst, class PixelValueSrc>
-    static void nonMaximumSuppression ( PixelValueDst *dst, const PixelValueSrc *src, int xsize, int ysize, bool useEightConnectivity = true );
+    static void nonMaximumSuppression ( NICE::ImageT<PixelValueDst> &dst, const NICE::ImageT<PixelValueSrc> &src, int xsize, int ysize, bool useEightConnectivity = true );
 
 };
 
 #include "GenericImageTools.tcc"
- 
 
 } // namespace
 

+ 66 - 48
image/GenericImageTools.tcc

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file GenericImageTools.cpp
 * @brief simple filter stuff
 * @author Erik Rodner
@@ -10,65 +10,83 @@
 #include "GenericImageTools.h"
 
 template <class PixelValueDst, class PixelValueSrc>
-void GenericImageTools::calcIntegralImage ( PixelValueDst *integralImage, const PixelValueSrc *image, int xsize, int ysize )
+void GenericImageTools::calcIntegralImage ( NICE::ImageT<PixelValueDst> &integralImage, const NICE::ImageT<PixelValueSrc> &image, int xsize, int ysize )
 {
-    integralImage[0] = image[0];
+  integralImage ( 0, 0 ) = ( PixelValueDst ) image ( 0, 0 );;
 
-    int k = xsize;
-    for ( int y = 1 ; y < ysize; y++, k+=xsize )
-	integralImage[k] = (PixelValueDst)(integralImage[k-xsize] + image[k]);
+  for ( int y = 1 ; y < ysize; y++ )
+    integralImage ( 0, y ) += image ( 0, y - 1 );
 
-    k = 1;
-    for ( int x = 1 ; x < xsize; x++, k++ )
-	integralImage[k] = (PixelValueDst)(integralImage[k-1] + image[k]);
+  for ( int x = 1 ; x < xsize; x++ )
+    integralImage ( x, 0 ) += image ( x - 1, 0 );
 
-    k = xsize + 1;
-    for ( int y = 1 ; y < ysize ; y++,k++ )
-	for ( int x = 1 ; x < xsize ; x++,k++ )
-	{
-	    integralImage[k] = (PixelValueDst)image[k];
-	    integralImage[k] += integralImage[k-1]; 
-	    integralImage[k] += integralImage[k - xsize];
-	    integralImage[k] -= integralImage[k - xsize - 1];
-	}
+  for ( int y = 1 ; y < ysize ; y++ )
+    for ( int x = 1 ; x < xsize ; x++ )
+    {
+      integralImage ( x, y ) = ( PixelValueDst ) image ( x, y );
+      integralImage ( x, y ) += integralImage ( x, y - 1 );
+      integralImage ( x, y ) += integralImage ( x - 1, y );
+      integralImage ( x, y ) -= integralImage ( x - 1, y - 1 );
+    }
 }
 
 template <class PixelValueDst, class PixelValueSrc>
-void GenericImageTools::nonMaximumSuppression ( PixelValueDst *dst, const PixelValueSrc *src,
-    int xsize, int ysize, bool useEightConnectivity )
+void GenericImageTools::nonMaximumSuppression ( NICE::ImageT<PixelValueDst> &dst, const NICE::ImageT<PixelValueSrc> &src, int xsize, int ysize, bool useEightConnectivity )
 {
-    long k = 0;
-    for ( int y = 0 ; y < ysize ; y++ )
-	for ( int x = 0 ; x < xsize ; x++,k++ )
-	{
-	    if ( x != 0 )
-	    {
-			if ( src[k-1] > src[k] ) { dst[k] = 0; continue; };
-			if ( useEightConnectivity ) {
-				if ( ( y != 0 ) && ( src[k-xsize-1] > src[k] ) ) { dst[k] = 0; continue; };
-				if ( ( y != ysize-1 ) && ( src[k+xsize-1] > src[k] ) ) { dst[k] = 0; continue; };
-			}
-	    }
+  for ( int y = 0 ; y < ysize ; y++ )
+    for ( int x = 0 ; x < xsize ; x++ )
+    {
+      if ( x != 0 )
+      {
+        if ( src ( x - 1, y ) > src ( x, y ) ) {
+          dst ( x, y ) = 0;
+          continue;
+        };
+        if ( useEightConnectivity ) {
+          if ( ( y != 0 ) && ( src ( x, y - 1 ) > src ( x, y ) ) ) {
+            dst ( x, y ) = 0;
+            continue;
+          };
+          if ( ( y != ysize - 1 ) && ( src ( x - 1, y + 1 ) > src ( x, y ) ) ) {
+            dst ( x, y ) = 0;
+            continue;
+          };
+        }
+      }
 
-	    if ( x != xsize-1 ) 
-	    {
-			if ( src[k+1] > src[k] ) { dst[k] = 0; continue; };
-			if ( useEightConnectivity ) {
-				if ( ( y != 0 ) && ( src[k-xsize+1] > src[k] ) ) { dst[k] = 0; continue; };
-				if ( ( y != ysize-1 ) && ( src[k+xsize+1] > src[k] ) ) { dst[k] = 0; continue; };
-			}
-	    }
+      if ( x != xsize - 1 )
+      {
+        if ( src ( x + 1, y ) > src ( x, y ) ) {
+          dst ( x, y ) = 0;
+          continue;
+        };
+        if ( useEightConnectivity ) {
+          if ( ( y != 0 ) && ( src ( x + 1, y - 1 ) > src ( x, y ) ) ) {
+            dst ( x, y ) = 0;
+            continue;
+          };
+          if ( ( y != ysize - 1 ) && ( src ( x + 1, y + 1 ) > src ( x, y ) ) ) {
+            dst ( x, y ) = 0;
+            continue;
+          };
+        }
+      }
 
-	    // CHANGE THIS to dst <-> src !!
+      // CHANGE THIS to dst <-> src !!
 
-	    if ( y != 0 ) 
-			if ( src[k-xsize] > src[k] ) { dst[k] = 0; continue; };
-	    
-	    if ( y != ysize-1 ) 
-			if ( src[k+xsize] > src[k] ) { dst[k] = 0; continue; };
+      if ( y != 0 )
+        if ( src ( x, y - 1 ) > src ( x, y ) ) {
+          dst ( x, y ) = 0;
+          continue;
+        };
 
-	    dst[k] = src[k];
-	}
+      if ( y != ysize - 1 )
+        if ( src ( x, y + 1 ) > src ( x, y ) ) {
+          dst ( x, y ) = 0;
+          continue;
+        };
 
+      dst ( x, y ) = src ( x, y );
+    }
 }
 

+ 54 - 54
math/pdf/tests/TestPDF.cpp

@@ -25,35 +25,35 @@
 #include "core/vector/VVector.h"
 #include "vislearning/math/pdf/PDFGaussian.h"
 
-#include "vislearning/nice_nonvis.h"
+#include "objrec/nice_nonvis.h"
 
 using namespace std;
 using namespace NICE;
 using namespace OBJREC;
 
-Matrix computeCovariance(const VVector & vecs)
+Matrix computeCovariance ( const VVector & vecs )
 {
-	Vector mean(vecs[0].size(), 0.0);
+  Vector mean ( vecs[0].size(), 0.0 );
 
-    for (unsigned int i = 0; i < vecs.size(); ++i)
-		mean += vecs[i];
-    
-	mean *= 1.0 / vecs.size();
+  for ( unsigned int i = 0; i < vecs.size(); ++i )
+    mean += vecs[i];
 
-    Matrix cov(vecs[0].size(), vecs[0].size(), 0.0);
+  mean *= 1.0 / vecs.size();
 
-    for (unsigned int i = 0; i < vecs.size(); ++i)
-    {
-        Vector diff = vecs[i] - mean;
-        cov.addTensorProduct ( 1.0, diff, diff );
-    }
+  Matrix cov ( vecs[0].size(), vecs[0].size(), 0.0 );
+
+  for ( unsigned int i = 0; i < vecs.size(); ++i )
+  {
+    Vector diff = vecs[i] - mean;
+    cov.addTensorProduct ( 1.0, diff, diff );
+  }
 
-    cov *= 1.0 / ( vecs.size() );
+  cov *= 1.0 / ( vecs.size() );
 
-    return cov;
+  return cov;
 }
 
-CPPUNIT_TEST_SUITE_REGISTRATION(TestPDF);
+CPPUNIT_TEST_SUITE_REGISTRATION ( TestPDF );
 
 
 
@@ -67,42 +67,42 @@ void TestPDF::tearDown()
 
 void TestPDF::TestPDFComputation()
 {
-    uint dim = 3;
-    bool init_random = true ;
-    uint samples = dim*500;
-
-    NICE::Matrix C(dim, dim);
-    NICE::Vector mean(dim, 0.0);
-    VVector samplevectors;
-    C.set(0.0);
-	cerr << "Sample from Gaussian" << endl;
-    //init random
-    if (init_random)
-        srand48(time(NULL));
-
-    // generate random symmetric matrix
-    for (uint i = 0 ; i < dim ; i++)
-        for (uint j = i ; j < dim ; j++)
-        {
-            C(i, j) = drand48();
-            C(j, i) = C(i, j);
-        }
-	C=C*C.transpose();
-    cerr << "Ground-Truth covariance" << endl;
-    cerr << C << endl;
-    //initialize GaussPDF
-    PDFGaussian pdf_gauss(C, mean);
-    
-	//draw samples
-    pdf_gauss.sample(samplevectors, samples);
-    Matrix Cov_test = computeCovariance(samplevectors);
-    cerr << "Estimated covariance" << endl;
-    cerr<<Cov_test<<endl;
-        
-	NICE::Matrix diff = C-Cov_test;
-	double frobNorm = diff.frobeniusNorm();
-
-	cerr << "Frobenius norm: " << frobNorm << endl;
-	CPPUNIT_ASSERT_DOUBLES_EQUAL_NOT_NAN(0.0, frobNorm, 0.1);
-     
+  uint dim = 3;
+  bool init_random = true ;
+  uint samples = dim * 500;
+
+  NICE::Matrix C ( dim, dim );
+  NICE::Vector mean ( dim, 0.0 );
+  VVector samplevectors;
+  C.set ( 0.0 );
+  cerr << "Sample from Gaussian" << endl;
+  //init random
+  if ( init_random )
+    srand48 ( time ( NULL ) );
+
+  // generate random symmetric matrix
+  for ( uint i = 0 ; i < dim ; i++ )
+    for ( uint j = i ; j < dim ; j++ )
+    {
+      C ( i, j ) = drand48();
+      C ( j, i ) = C ( i, j );
+    }
+  C = C * C.transpose();
+  cerr << "Ground-Truth covariance" << endl;
+  cerr << C << endl;
+  //initialize GaussPDF
+  PDFGaussian pdf_gauss ( C, mean );
+
+  //draw samples
+  pdf_gauss.sample ( samplevectors, samples );
+  Matrix Cov_test = computeCovariance ( samplevectors );
+  cerr << "Estimated covariance" << endl;
+  cerr << Cov_test << endl;
+
+  NICE::Matrix diff = C - Cov_test;
+  double frobNorm = diff.frobeniusNorm();
+
+  cerr << "Frobenius norm: " << frobNorm << endl;
+  CPPUNIT_ASSERT_DOUBLES_EQUAL_NOT_NAN ( 0.0, frobNorm, 0.1 );
+
 }

+ 4 - 0
progs/libdepend.inc

@@ -0,0 +1,4 @@
+$(call PKG_DEPEND_EXT,OPENMP)
+$(call PKG_DEPEND_EXT,OPENCV)
+$(call PKG_DEPEND_INT,objrec/iclassifier)
+$(call PKG_DEPEND_INT,vislearning/classifier)