Ver código fonte

simplifications and bugfixes

Sven Sickert 11 anos atrás
pai
commit
57dc441e2e

+ 2 - 10
semseg/SemSegContextTree.cpp

@@ -182,13 +182,6 @@ SemSegContextTree::SemSegContextTree ( const Config *conf, const MultiDataset *m
   opOverview = vector<int> ( NBOPERATIONS, 0 );
   contextOverview = vector<vector<double> > ( maxDepth, vector<double> ( 2, 0.0 ) );
 
-  calcVal.push_back ( new MCImageAccess() );
-  calcVal.push_back ( new MCImageAccess() );
-  calcVal.push_back ( new MCImageAccess() );
-  calcVal.push_back ( new MCImageAccess() );
-  calcVal.push_back ( new ClassificationResultAccess() );
-
-
   classnames = md->getClassNames ( "train" );
 
 }
@@ -369,8 +362,8 @@ double SemSegContextTree::getBestSplit (
     int o = ( int ) ( rand() % ops[ft].size() );
     
     Operation *op = ops[ft][o]->clone();
-    op->set ( x1, y1, z1, x2, y2, z2, f1, f2, calcVal[ft] );
-    op->setFeatType ( ft );
+    op->set ( x1, y1, z1, x2, y2, z2, f1, f2, ft );
+//    op->setFeatType ( ft );
 
     if ( ft == 3 || ft == 4 )
       op->setContext ( true );
@@ -2159,7 +2152,6 @@ void SemSegContextTree::restore ( std::istream & is, int format )
   is >> trees;
   forest.clear();
 
-
   for ( int t = 0; t < trees; t++ )
   {
     vector<TreeNode> tmptree;

+ 0 - 2
semseg/SemSegContextTree.h

@@ -80,8 +80,6 @@ private:
   /** prototype operations for pairwise features */
   std::vector<std::vector<Operation*> > ops;
 
-  std::vector<ValueAccess*> calcVal;
-
   /** use alternative calculation for information gain */
   bool useShannonEntropy;
 

+ 201 - 125
semseg/operations/Operations.cpp

@@ -6,11 +6,11 @@ using namespace NICE;
 
 Operation::Operation()
 {
-  values = NULL;
   maxtypes = 1000;
+  init = false;
 }
 
-void Operation::set ( int _x1, int _y1, int _z1, int _x2, int _y2, int _z2, int _channel1, int _channel2, ValueAccess *_values )
+void Operation::set ( int _x1, int _y1, int _z1, int _x2, int _y2, int _z2, int _channel1, int _channel2, int ftype )
 {
   x1 = _x1;
   y1 = _y1;
@@ -20,7 +20,8 @@ void Operation::set ( int _x1, int _y1, int _z1, int _x2, int _y2, int _z2, int
 	z2 = _z2;
   channel1 = _channel1;
   channel2 = _channel2;
-  values = _values;
+  setFeatType(ftype);
+  init = true;
 }
 
 void Operation::setContext ( bool _context )
@@ -54,10 +55,15 @@ void Operation::getXYZ ( const Features &feats, int &xsize, int &ysize, int &zsi
 void Operation::store ( std::ostream & os )
 {
   os << x1 << " " << x2 << " " << y1 << " " << y2 << " " << z1 << " " << z2 << " " << channel1 << " " << channel2 << " " << featType << std::endl;
-  if ( values == NULL )
+  if ( !init )
     os << -1 << std::endl;
   else
-    os << values->getType() << std::endl;
+  {
+    if (featType == 4)
+      os << CONTEXT << std::endl;
+    else
+      os << RAWFEAT << std::endl;
+  }
 }
 
 void Operation::restore ( std::istream &is )
@@ -77,13 +83,9 @@ void Operation::restore ( std::istream &is )
 
   if ( tmp >= 0 )
   {
-    if ( tmp == RAWFEAT )
-    {
-      values = new MCImageAccess();
-    }
-    else if ( tmp == CONTEXT )
+    if ( tmp == RAWFEAT || tmp == CONTEXT )
     {
-      values = new ClassificationResultAccess();
+      init = true;
     }
     else
     {
@@ -92,7 +94,7 @@ void Operation::restore ( std::istream &is )
   }
   else
   {
-    values = NULL;
+    init = false;
   }
 }
 
@@ -103,46 +105,103 @@ std::string Operation::writeInfos()
   return ss.str();
 }
 
+
+
+
+//############################## region feature ###############################
+
+
 double RegionFeat::getVal ( const Features &feats, const int &x, const int &y, const int &z )
 {
   return (*feats.rProbs)[(*feats.feats)(x,y,z,channel1)][channel2];
 }
 
+
+
+
+//############################# two gray values ###############################
+
+
 double Minus::getVal ( const Features &feats, const int &x, const int &y, const int &z )
 {
   int xsize, ysize, zsize;
   getXYZ ( feats, xsize, ysize, zsize );
-  double v1 = values->getVal ( feats, BOUND ( x + x1, 0, xsize - 1 ), BOUND ( y + y1, 0, ysize - 1 ), BOUND ( z + z1, 0, zsize - 1 ), channel1 );
-  double v2 = values->getVal ( feats, BOUND ( x + x2, 0, xsize - 1 ), BOUND ( y + y2, 0, ysize - 1 ), BOUND ( z + z2, 0, zsize - 1 ), channel2 );
-  return v1 -v2;
+
+  double v1,v2;
+  if (featType == 4)
+  {
+    v1 = ( *feats.tree ) [feats.nIndices->get ( BOUND ( x + x1, 0, xsize - 1 ), BOUND ( y + y1, 0, ysize - 1 ), BOUND ( z + z1, 0, zsize - 1 ), feats.cTree ) ].dist[channel1];
+    v2 = ( *feats.tree ) [feats.nIndices->get ( BOUND ( x + x2, 0, xsize - 1 ), BOUND ( y + y2, 0, ysize - 1 ), BOUND ( z + z2, 0, zsize - 1 ), feats.cTree ) ].dist[channel2];
+  }
+  else
+  {
+    v1 = feats.feats->get ( BOUND ( x + x1, 0, xsize - 1 ), BOUND ( y + y1, 0, ysize - 1 ), BOUND ( z + z1, 0, zsize - 1 ), channel1 );
+    v2 = feats.feats->get ( BOUND ( x + x2, 0, xsize - 1 ), BOUND ( y + y2, 0, ysize - 1 ), BOUND ( z + z2, 0, zsize - 1 ), channel2 );
+  }
+  return v1-v2;
 }
 
 double MinusAbs::getVal ( const Features &feats, const int &x, const int &y, const int &z )
 {
   int xsize, ysize, zsize;
   getXYZ ( feats, xsize, ysize, zsize );
-  double v1 = values->getVal ( feats, BOUND ( x + x1, 0, xsize - 1 ), BOUND ( y + y1, 0, ysize - 1 ), BOUND ( z + z1, 0, zsize - 1 ), channel1 );
-  double v2 = values->getVal ( feats, BOUND ( x + x2, 0, xsize - 1 ), BOUND ( y + y2, 0, ysize - 1 ), BOUND ( z + z2, 0, zsize - 1 ), channel2 );
-  return abs ( v1 -v2 );
+  double v1,v2;
+  if (featType == 4)
+  {
+    v1 = ( *feats.tree ) [feats.nIndices->get ( BOUND ( x + x1, 0, xsize - 1 ), BOUND ( y + y1, 0, ysize - 1 ), BOUND ( z + z1, 0, zsize - 1 ), feats.cTree ) ].dist[channel1];
+    v2 = ( *feats.tree ) [feats.nIndices->get ( BOUND ( x + x2, 0, xsize - 1 ), BOUND ( y + y2, 0, ysize - 1 ), BOUND ( z + z2, 0, zsize - 1 ), feats.cTree ) ].dist[channel2];
+  }
+  else
+  {
+    v1 = feats.feats->get ( BOUND ( x + x1, 0, xsize - 1 ), BOUND ( y + y1, 0, ysize - 1 ), BOUND ( z + z1, 0, zsize - 1 ), channel1 );
+    v2 = feats.feats->get ( BOUND ( x + x2, 0, xsize - 1 ), BOUND ( y + y2, 0, ysize - 1 ), BOUND ( z + z2, 0, zsize - 1 ), channel2 );
+  }
+  return abs(v1-v2);
 }
 
 double Addition::getVal ( const Features &feats, const int &x, const int &y, const int &z )
 {
   int xsize, ysize, zsize;
   getXYZ ( feats, xsize, ysize, zsize );
-  double v1 = values->getVal ( feats, BOUND ( x + x1, 0, xsize - 1 ), BOUND ( y + y1, 0, ysize - 1 ), BOUND ( z + z1, 0, zsize - 1 ), channel1 );
-  double v2 = values->getVal ( feats, BOUND ( x + x2, 0, xsize - 1 ), BOUND ( y + y2, 0, ysize - 1 ), BOUND ( z + z2, 0, zsize - 1 ), channel2 );
-  return v1 + v2;
+  double v1,v2;
+  if (featType == 4)
+  {
+    v1 = ( *feats.tree ) [feats.nIndices->get ( BOUND ( x + x1, 0, xsize - 1 ), BOUND ( y + y1, 0, ysize - 1 ), BOUND ( z + z1, 0, zsize - 1 ), feats.cTree ) ].dist[channel1];
+    v2 = ( *feats.tree ) [feats.nIndices->get ( BOUND ( x + x2, 0, xsize - 1 ), BOUND ( y + y2, 0, ysize - 1 ), BOUND ( z + z2, 0, zsize - 1 ), feats.cTree ) ].dist[channel2];
+  }
+  else
+  {
+    v1 = feats.feats->get ( BOUND ( x + x1, 0, xsize - 1 ), BOUND ( y + y1, 0, ysize - 1 ), BOUND ( z + z1, 0, zsize - 1 ), channel1 );
+    v2 = feats.feats->get ( BOUND ( x + x2, 0, xsize - 1 ), BOUND ( y + y2, 0, ysize - 1 ), BOUND ( z + z2, 0, zsize - 1 ), channel2 );
+  }
+  return v1+v2;
 }
 
+
+
+
+//############################## one gray value ###############################
+
+
 double Only1::getVal ( const Features &feats, const int &x, const int &y, const int &z )
 {
   int xsize, ysize, zsize;
   getXYZ ( feats, xsize, ysize, zsize );
-  double v1 = values->getVal ( feats, BOUND ( x + x1, 0, xsize - 1 ), BOUND ( y + y1, 0, ysize - 1 ), BOUND ( z + z1, 0, zsize - 1 ), channel1 );
+  double v1;
+  if (featType == 4)
+    v1 = ( *feats.tree ) [feats.nIndices->get ( BOUND ( x + x1, 0, xsize - 1 ), BOUND ( y + y1, 0, ysize - 1 ), BOUND ( z + z1, 0, zsize - 1 ), feats.cTree ) ].dist[channel1];
+  else
+    v1 = feats.feats->get ( BOUND ( x + x1, 0, xsize - 1 ), BOUND ( y + y1, 0, ysize - 1 ), BOUND ( z + z1, 0, zsize - 1 ), channel1 );
+
   return v1;
 }
 
+
+
+
+//############################ relative positions #############################
+
+
 double RelativeXPosition::getVal ( const Features &feats, const int &x, const int &y, const int &z )
 {
   int xsize, ysize, zsize;
@@ -164,10 +223,13 @@ double RelativeZPosition::getVal ( const Features &feats, const int &x, const in
   return ( double ) z / ( double ) zsize;
 }
 
-double IntegralOps::getVal ( const Features &feats, const int &x, const int &y, const int &z )
-{
-  return feats.feats->getIntegralValue(x + x1, y + y1, z + z1, x + x2, y + y2, z + z2, channel1);
-}
+
+
+
+
+//########################### integral operations #############################
+
+
 
 double GlobalFeats::getVal ( const Features &feats, const int &x, const int &y, const int &z )
 {
@@ -176,165 +238,179 @@ double GlobalFeats::getVal ( const Features &feats, const int &x, const int &y,
   return feats.feats->getIntegralValue( 0, 0, 0, xsize - 1, ysize - 1, zsize - 1, channel1 );
 }
 
+void IntegralOps::set ( int _x1, int _y1, int _z1, int _x2, int _y2, int _z2, int _channel1, int _channel2, int ftype )
+{
+  x1 = std::min ( _x1, _x2 );
+  y1 = std::min ( _y1, _y2 );
+  z1 = std::min ( _z1, _z2 );
+  x2 = std::max ( _x1, _x2 );
+  y2 = std::max ( _y1, _y2 );
+  z2 = std::max ( _z1, _z2 );
+  channel1 = _channel1;
+  channel2 = _channel2;
+  setFeatType(ftype);
+}
+
+double IntegralOps::getVal ( const Features &feats, const int &x, const int &y, const int &z )
+{
+  return feats.feats->getIntegralValue(x + x1, y + y1, z + z1, x + x2, y + y2, z + z2, channel1);
+}
+
+void IntegralCenteredOps::set ( int _x1, int _y1, int _z1, int _x2, int _y2, int _z2, int _channel1, int _channel2, int ftype )
+{
+  x1 = abs ( _x1 );
+  y1 = abs ( _y1 );
+  z1 = abs ( _z1 );
+  x2 = abs ( _x2 );
+  y2 = abs ( _y2 );
+  z2 = abs ( _z2 );
+  channel1 = _channel1;
+  channel2 = _channel2;
+  setFeatType(ftype);
+}
+
 double IntegralCenteredOps::getVal ( const Features &feats, const int &x, const int &y, const int &z )
 {
   return feats.feats->getIntegralValue(x - x1, y - y1, z - z1, x + x1, y + y1, z + z1, channel1);
 }
 
+void BiIntegralCenteredOps::set ( int _x1, int _y1, int _z1, int _x2, int _y2, int _z2, int _channel1, int _channel2, int ftype )
+{
+  x1 = std::min ( abs ( _x1 ), abs ( _x2 ) );
+  y1 = std::min ( abs ( _y1 ), abs ( _y2 ) );
+  z1 = std::min ( abs ( _z1 ), abs ( _z2 ) );
+  x2 = std::max ( abs ( _x1 ), abs ( _x2 ) );
+  y2 = std::max ( abs ( _y1 ), abs ( _y2 ) );
+  z2 = std::max ( abs ( _z1 ), abs ( _z2 ) );
+  channel1 = _channel1;
+  channel2 = _channel2;
+  setFeatType(ftype);
+}
+
 double BiIntegralCenteredOps::getVal ( const Features &feats, const int &x, const int &y, const int &z )
 {
   return feats.feats->getIntegralValue(x - x1, y - y1, z - z1, x + x1, y + y1, z + z1, channel1 ) - feats.feats->getIntegralValue(x - x2, y - y2, z - z2, x + x2, y + y2, z + z2, channel1);
 }
 
+
+
+
+
+
+//############################ Haar-like features #############################
+
+
+
 double HaarHorizontal::getVal ( const Features &feats, const int &x, const int &y, const int &z )
 {
-  int tlx = x - x1;
-  int tly = y - y1;
-	int tlz = z - z1;
-  int lrx = x + x1;
-  int lry = y + y1;
-	int lrz = z + z1;
+  int tlx = x - abs(x1);
+  int tly = y - abs(y1);
+  int tlz = z - abs(z1);
+  int lrx = x + abs(x1);
+  int lry = y + abs(y1);
+  int lrz = z + abs(z1);
 
   return feats.feats->getIntegralValue(tlx, tly, tlz, lrx, y, lrz, channel1 ) - feats.feats->getIntegralValue(tlx, y, tlz, lrx, lry, lrz, channel1);
 }
 
 double HaarVertical::getVal ( const Features &feats, const int &x, const int &y, const int &z )
 {
-  int tlx = x - x1;
-  int tly = y - y1;
-	int tlz = z - z1;
-  int lrx = x + x1;
-  int lry = y + y1;
-	int lrz = z + z1;
+  int tlx = x - abs(x1);
+  int tly = y - abs(y1);
+  int tlz = z - abs(z1);
+  int lrx = x + abs(x1);
+  int lry = y + abs(y1);
+  int lrz = z + abs(z1);
 
   return feats.feats->getIntegralValue(tlx, tly, tlz, x, lry, lrz, channel1) - feats.feats->getIntegralValue(x, tly, tlz, lrx, lry, lrz, channel1);
 }
 
 double HaarStacked::getVal ( const Features &feats, const int &x, const int &y, const int &z )
 {
-  int tlx = x - x1;
-  int tly = y - y1;
-	int tlz = z - z1;
-  int lrx = x + x1;
-  int lry = y + y1;
-	int lrz = z + z1;
+  int tlx = x - abs(x1);
+  int tly = y - abs(y1);
+  int tlz = z - abs(z1);
+  int lrx = x + abs(x1);
+  int lry = y + abs(y1);
+  int lrz = z + abs(z1);
 
   return feats.feats->getIntegralValue(tlx, tly, tlz, lrx, lry, z, channel1) - feats.feats->getIntegralValue(tlx, tly, z, lrx, lry, lrz, channel1);
 }
 
 double HaarDiagXY::getVal ( const Features &feats, const int &x, const int &y, const int &z )
 {
-  int tlx = x - x1;
-  int tly = y - y1;
-	int tlz = z - z1;
-  int lrx = x + x1;
-  int lry = y + y1;
-	int lrz = z + z1;
+  int tlx = x - abs(x1);
+  int tly = y - abs(y1);
+  int tlz = z - abs(z1);
+  int lrx = x + abs(x1);
+  int lry = y + abs(y1);
+  int lrz = z + abs(z1);
 
   return feats.feats->getIntegralValue(tlx, tly, tlz, x, y, lrz, channel1) + feats.feats->getIntegralValue(x, y, tlz, lrx, lry, lrz, channel1) - feats.feats->getIntegralValue(tlx, y, tlz, x, lry, lrz, channel1) - feats.feats->getIntegralValue(x, tly, tlz, lrx, y, lrz, channel1);
 }
 
 double HaarDiagXZ::getVal ( const Features &feats, const int &x, const int &y, const int &z )
 {
-  int tlx = x - x1;
-  int tly = y - y1;
-	int tlz = z - z1;
-  int lrx = x + x1;
-  int lry = y + y1;
-	int lrz = z + z1;
+  int tlx = x - abs(x1);
+  int tly = y - abs(y1);
+  int tlz = z - abs(z1);
+  int lrx = x + abs(x1);
+  int lry = y + abs(y1);
+  int lrz = z + abs(z1);
 
   return feats.feats->getIntegralValue(tlx, tly, tlz, x, lry, z, channel1) + feats.feats->getIntegralValue(x, tly, z, lrx, lry, lrz, channel1) - feats.feats->getIntegralValue(tlx, tly, z, x, lry, lrz, channel1) - feats.feats->getIntegralValue(x, tly, tlz, lrx, lry, z, channel1);
 }
 
 double HaarDiagYZ::getVal ( const Features &feats, const int &x, const int &y, const int &z )
 {
-  int tlx = x - x1;
-  int tly = y - y1;
-	int tlz = z - z1;
-  int lrx = x + x1;
-  int lry = y + y1;
-	int lrz = z + z1;
+  int tlx = x - abs(x1);
+  int tly = y - abs(y1);
+  int tlz = z - abs(z1);
+  int lrx = x + abs(x1);
+  int lry = y + abs(y1);
+  int lrz = z + abs(z1);
 
   return feats.feats->getIntegralValue(tlx, tly, tlz, lrx, y, z, channel1) + feats.feats->getIntegralValue(tlx, y, z, lrx, lry, lrz, channel1) - feats.feats->getIntegralValue(tlx, tly, z, lrx, y, lrz, channel1) - feats.feats->getIntegralValue(tlx, y, tlz, lrx, lry, z, channel1);
 }
 
 double Haar3Horiz::getVal ( const Features &feats, const int &x, const int &y, const int &z )
 {
-  int tlx = x - x2;
-  int tly = y - y2;
-	int tlz = z - z2;
-  int mtly = y - y1;
-  int mlry = y + y1;
-  int lrx = x + x2;
-  int lry = y + y2;
-	int lrz = z + z2;
+  int tlx = x - abs(x1);
+  int tly = y - abs(y1);
+  int tlz = z - abs(z1);
+  int lrx = x + abs(x1);
+  int lry = y + abs(y1);
+  int lrz = z + abs(z1);
+  int mtly = y - abs(y1);
+  int mlry = y + abs(y1);
 
   return feats.feats->getIntegralValue(tlx, tly, tlz, lrx, mtly, lrz, channel1) - feats.feats->getIntegralValue(tlx, mtly, tlz, lrx, mlry, lrz, channel1) + feats.feats->getIntegralValue(tlx, mlry, tlz, lrx, lry, lrz, channel1);
 }
 
 double Haar3Vert::getVal ( const Features &feats, const int &x, const int &y, const int &z )
 {
-  int tlx = x - x2;
-  int tly = y - y2;
-	int tlz = z - z2;
-  int mtlx = x - x1;
-  int mlrx = x + x1;
-  int lrx = x + x2;
-  int lry = y + y2;
-	int lrz = z + z2;
+  int tlx = x - abs(x1);
+  int tly = y - abs(y1);
+  int tlz = z - abs(z1);
+  int lrx = x + abs(x1);
+  int lry = y + abs(y1);
+  int lrz = z + abs(z1);
+  int mtlx = x - abs(x1);
+  int mlrx = x + abs(x1);
 
   return feats.feats->getIntegralValue(tlx, tly, tlz, mtlx, lry, lrz, channel1) - feats.feats->getIntegralValue(mtlx, tly, tlz, mlrx, lry, lrz, channel1) + feats.feats->getIntegralValue(mlrx, tly, tlz, lrx, lry, lrz, channel1);
 }
 
 double Haar3Stack::getVal ( const Features &feats, const int &x, const int &y, const int &z )
 {
-  int tlx = x - x2;
-  int tly = y - y2;
-	int tlz = z - z2;
-  int mtlz = z - z1;
-  int mlrz = z + z1;
-  int lrx = x + x2;
-  int lry = y + y2;
-	int lrz = z + z2;
+  int tlx = x - abs(x1);
+  int tly = y - abs(y1);
+  int tlz = z - abs(z1);
+  int lrx = x + abs(x1);
+  int lry = y + abs(y1);
+  int lrz = z + abs(z1);
+  int mtlz = z - abs(z1);
+  int mlrz = z + abs(z1);
 
   return feats.feats->getIntegralValue(tlx, tly, tlz, lrx, lry, mtlz, channel1) - feats.feats->getIntegralValue(tlx, tly, mtlz, lrx, lry, mlrz, channel1) + feats.feats->getIntegralValue(tlx, tly, mlrz, lrx, lry, lrz, channel1);
 }
-
-void IntegralOps::set ( int _x1, int _y1, int _z1, int _x2, int _y2, int _z2, int _channel1, int _channel2, ValueAccess *_values )
-{
-  x1 = std::min ( _x1, _x2 );
-  y1 = std::min ( _y1, _y2 );
-	z1 = std::min ( _z1, _z2 );
-  x2 = std::max ( _x1, _x2 );
-  y2 = std::max ( _y1, _y2 );
-	z2 = std::max ( _z1, _z2 );
-  channel1 = _channel1;
-  channel2 = _channel2;
-  values = _values;
-}
-
-void IntegralCenteredOps::set ( int _x1, int _y1, int _z1, int _x2, int _y2, int _z2, int _channel1, int _channel2, ValueAccess *_values )
-{
-  x1 = abs ( _x1 );
-  y1 = abs ( _y1 );
-	z1 = abs ( _z1 );
-  x2 = abs ( _x2 );
-  y2 = abs ( _y2 );
-	z2 = abs ( _z2 );
-  channel1 = _channel1;
-  channel2 = _channel2;
-  values = _values;
-}
-
-void BiIntegralCenteredOps::set ( int _x1, int _y1, int _z1, int _x2, int _y2, int _z2, int _channel1, int _channel2, ValueAccess *_values )
-{
-  x1 = std::min ( abs ( _x1 ), abs ( _x2 ) );
-  y1 = std::min ( abs ( _y1 ), abs ( _y2 ) );
-	z1 = std::min ( abs ( _z1 ), abs ( _z2 ) );
-  x2 = std::max ( abs ( _x1 ), abs ( _x2 ) );
-  y2 = std::max ( abs ( _y1 ), abs ( _y2 ) );
-	z2 = std::max ( abs ( _z1 ), abs ( _z2 ) );
-  channel1 = _channel1;
-  channel2 = _channel2;
-  values = _values;
-}

+ 70 - 51
semseg/operations/Operations.h

@@ -21,9 +21,7 @@ class Operation;
 enum ValueTypes
 {
   RAWFEAT,
-  CONTEXT,
-  SPARSE,
-  NBVALUETYPES
+  CONTEXT
 };
 
 /**
@@ -129,6 +127,7 @@ struct Features {
   std::vector<std::vector<double> > *rProbs;
 };
 
+#if 0
 /**
  * @brief abstract values access class
  **/
@@ -244,7 +243,7 @@ class ClassificationResultAccess: public ValueAccess
     }
 };
 
-#if 0
+
 /**
  * @brief not finished yet, do we really need sparse feature representation or ClassificationResultAccess sufficient
  **/
@@ -304,7 +303,7 @@ class Operation
     /** type of feature */
     int featType;
     
-    ValueAccess *values;
+    bool init;
 
     bool context;
 
@@ -323,10 +322,10 @@ class Operation
 		 * @param _z2 position 2
      * @param _channel1 channel 1
      * @param _channel2 channel 2
-     * @param _values value extraction method
+     * @param _ftype feature type
      * @return void nothing
      **/
-    virtual void set ( int _x1, int _y1, int _z1, int _x2, int _y2, int _z2, int _channel1, int _channel2, ValueAccess *_values );
+    virtual void set ( int _x1, int _y1, int _z1, int _x2, int _y2, int _z2, int _channel1, int _channel2, int ftype );
 
     /**
      * @brief set whether it is a context feature or not
@@ -388,7 +387,7 @@ class Operation
     inline void getXYZ ( const Features &feats, int &xsize, int &ysize, int &zsize );
 
     /**
-     * @brief return operation type (for store and restor)
+     * @brief return operation type (for store and restore)
      * @return OperationTypes
      **/
     virtual OperationTypes getOps() = 0;
@@ -440,14 +439,18 @@ class RegionFeat: public Operation
     {
       std::string out = "RegionFeat";
 
-      if ( values != NULL )
-        out += values->writeInfos();
-
+      if (init)
+      {
+        if ( featType == 4 )
+          out += "context";
+        else
+          out += "raw";
+      }
       return out + Operation::writeInfos();
     }
 
     /**
-     * @brief return operation type (for store and restor)
+     * @brief return operation type (for store and restore)
      * @return OperationTypes
      **/
     virtual OperationTypes getOps()
@@ -488,14 +491,18 @@ class Minus: public Operation
     {
       std::string out = "Minus";
 
-      if ( values != NULL )
-        out += values->writeInfos();
-
+      if (init)
+      {
+        if ( featType == 4 )
+          out += "context";
+        else
+          out += "raw";
+      }
       return out + Operation::writeInfos();
     }
 
     /**
-     * @brief return operation type (for store and restor)
+     * @brief return operation type (for store and restore)
      * @return OperationTypes
      **/
     virtual OperationTypes getOps()
@@ -527,7 +534,7 @@ class MinusAbs: public Operation
     virtual Operation* clone()
     {
       return new MinusAbs();
-    };
+    }
 
     /**
      * @brief print some infos about operation extraction type
@@ -537,14 +544,18 @@ class MinusAbs: public Operation
     {
       std::string out = "MinusAbs";
 
-      if ( values != NULL )
-        out += values->writeInfos();
-
+      if (init)
+      {
+        if ( featType == 4 )
+          out += "context";
+        else
+          out += "raw";
+      }
       return out;
     }
 
     /**
-     * @brief return operation type (for store and restor)
+     * @brief return operation type (for store and restore)
      * @return OperationTypes
      **/
     virtual OperationTypes getOps()
@@ -586,14 +597,18 @@ class Addition: public Operation
     {
       std::string out = "Addition";
 
-      if ( values != NULL )
-        out += values->writeInfos();
-
+      if (init)
+      {
+        if ( featType == 4 )
+          out += "context";
+        else
+          out += "raw";
+      }
       return out + Operation::writeInfos();
     }
 
     /**
-     * @brief return operation type (for store and restor)
+     * @brief return operation type (for store and restore)
      * @return OperationTypes
      **/
     virtual OperationTypes getOps()
@@ -634,14 +649,18 @@ class Only1: public Operation
     {
       std::string out = "Only1";
 
-      if ( values != NULL )
-        out += values->writeInfos();
-
+      if (init)
+      {
+        if ( featType == 4 )
+          out += "context";
+        else
+          out += "raw";
+      }
       return out + Operation::writeInfos();
     }
 
     /**
-     * @brief return operation type (for store and restor)
+     * @brief return operation type (for store and restore)
      * @return OperationTypes
      **/
     virtual OperationTypes getOps()
@@ -684,7 +703,7 @@ class RelativeXPosition: public Operation
     }
 
     /**
-     * @brief return operation type (for store and restor)
+     * @brief return operation type (for store and restore)
      * @return OperationTypes
      **/
     virtual OperationTypes getOps()
@@ -727,7 +746,7 @@ class RelativeYPosition: public Operation
     }
 
     /**
-     * @brief return operation type (for store and restor)
+     * @brief return operation type (for store and restore)
      * @return OperationTypes
      **/
     virtual OperationTypes getOps()
@@ -770,7 +789,7 @@ class RelativeZPosition: public Operation
     }
 
     /**
-     * @brief return operation type (for store and restor)
+     * @brief return operation type (for store and restore)
      * @return OperationTypes
      **/
     virtual OperationTypes getOps()
@@ -795,10 +814,10 @@ class IntegralOps: public Operation
 		 * @param _z2 position 2
      * @param _channel1 channel 1
      * @param _channel2 channel 2
-     * @param _values value extraction method
+     * @param _ftype feature type
      * @return void nothing
      **/
-    virtual void set ( int _x1, int _y1, int _z1, int _x2, int _y2, int _z2, int _channel1, int _channel2, ValueAccess *_values );
+    virtual void set ( int _x1, int _y1, int _z1, int _x2, int _y2, int _z2, int _channel1, int _channel2, int _ftype );
 
     /**
      * @brief interface for feature computation
@@ -828,7 +847,7 @@ class IntegralOps: public Operation
     }
 
     /**
-     * @brief return operation type (for store and restor)
+     * @brief return operation type (for store and restore)
      * @return OperationTypes
      **/
     virtual OperationTypes getOps()
@@ -873,7 +892,7 @@ class GlobalFeats: public IntegralOps
     }
 
     /**
-     * @brief return operation type (for store and restor)
+     * @brief return operation type (for store and restore)
      * @return OperationTypes
      **/
     virtual OperationTypes getOps()
@@ -898,10 +917,10 @@ class IntegralCenteredOps: public IntegralOps
 		 * @param _z2 position 2
      * @param _channel1 channel 1
      * @param _channel2 channel 2
-     * @param _values value extraction method
+     * @param _ftype feature type
      * @return void nothing
      **/
-    virtual void set ( int _x1, int _y1, int _z1, int _x2, int _y2, int _z2, int _channel1, int _channel2, ValueAccess *_values );
+    virtual void set ( int _x1, int _y1, int _z1, int _x2, int _y2, int _z2, int _channel1, int _channel2, int _ftype );
 
     /**
      * @brief interface for feature computation
@@ -931,7 +950,7 @@ class IntegralCenteredOps: public IntegralOps
     }
 
     /**
-     * @brief return operation type (for store and restor)
+     * @brief return operation type (for store and restore)
      * @return OperationTypes
      **/
     virtual OperationTypes getOps()
@@ -956,10 +975,10 @@ class BiIntegralCenteredOps: public IntegralCenteredOps
 		 * @param _z2 position 2
      * @param _channel1 channel 1
      * @param _channel2 channel 2
-     * @param _values value extraction method
+     * @param _ftype feature type
      * @return void nothing
      **/
-    virtual void set ( int _x1, int _y1, int _z1, int _x2, int _y2, int _z2, int _channel1, int _channel2, ValueAccess *_values );
+    virtual void set ( int _x1, int _y1, int _z1, int _x2, int _y2, int _z2, int _channel1, int _channel2, int ftype );
 
     /**
      * @brief interface for feature computation
@@ -989,7 +1008,7 @@ class BiIntegralCenteredOps: public IntegralCenteredOps
     }
 
     /**
-     * @brief return operation type (for store and restor)
+     * @brief return operation type (for store and restore)
      * @return OperationTypes
      **/
     virtual OperationTypes getOps()
@@ -1034,7 +1053,7 @@ class HaarHorizontal: public IntegralCenteredOps
     }
 
     /**
-     * @brief return operation type (for store and restor)
+     * @brief return operation type (for store and restore)
      * @return OperationTypes
      **/
     virtual OperationTypes getOps()
@@ -1079,7 +1098,7 @@ class HaarVertical: public IntegralCenteredOps
     }
 
     /**
-     * @brief return operation type (for store and restor)
+     * @brief return operation type (for store and restore)
      * @return OperationTypes
      **/
     virtual OperationTypes getOps()
@@ -1124,7 +1143,7 @@ class HaarStacked: public IntegralCenteredOps
     }
 
     /**
-     * @brief return operation type (for store and restor)
+     * @brief return operation type (for store and restore)
      * @return OperationTypes
      **/
     virtual OperationTypes getOps()
@@ -1169,7 +1188,7 @@ class HaarDiagXY: public IntegralCenteredOps
     }
 
     /**
-     * @brief return operation type (for store and restor)
+     * @brief return operation type (for store and restore)
      * @return OperationTypes
      **/
     virtual OperationTypes getOps()
@@ -1214,7 +1233,7 @@ class HaarDiagXZ: public IntegralCenteredOps
     }
 
     /**
-     * @brief return operation type (for store and restor)
+     * @brief return operation type (for store and restore)
      * @return OperationTypes
      **/
     virtual OperationTypes getOps()
@@ -1259,7 +1278,7 @@ class HaarDiagYZ: public IntegralCenteredOps
     }
 
     /**
-     * @brief return operation type (for store and restor)
+     * @brief return operation type (for store and restore)
      * @return OperationTypes
      **/
     virtual OperationTypes getOps()
@@ -1306,7 +1325,7 @@ class Haar3Horiz: public BiIntegralCenteredOps
     }
 
     /**
-     * @brief return operation type (for store and restor)
+     * @brief return operation type (for store and restore)
      * @return OperationTypes
      **/
     virtual OperationTypes getOps()
@@ -1352,7 +1371,7 @@ class Haar3Vert: public BiIntegralCenteredOps
     }
 
     /**
-     * @brief return operation type (for store and restor)
+     * @brief return operation type (for store and restore)
      * @return OperationTypes
      **/
     virtual OperationTypes getOps()
@@ -1398,7 +1417,7 @@ class Haar3Stack: public BiIntegralCenteredOps
     }
 
     /**
-     * @brief return operation type (for store and restor)
+     * @brief return operation type (for store and restore)
      * @return OperationTypes
      **/
     virtual OperationTypes getOps()