|
@@ -692,24 +692,42 @@ SemSegContextTree::SemSegContextTree ( const Config *conf, const MultiDataset *m
|
|
|
|
|
|
ftypes = conf->gI ( section, "features", 2 );;
|
|
|
|
|
|
- ops.push_back ( new Minus() );
|
|
|
- ops.push_back ( new MinusAbs() );
|
|
|
- ops.push_back ( new Addition() );
|
|
|
- ops.push_back ( new Only1() );
|
|
|
- ops.push_back ( new RelativeXPosition() );
|
|
|
- ops.push_back ( new RelativeYPosition() );
|
|
|
-
|
|
|
- cops.push_back ( new BiIntegralCenteredOps() );
|
|
|
- cops.push_back ( new IntegralCenteredOps() );
|
|
|
- cops.push_back ( new IntegralOps() );
|
|
|
- cops.push_back ( new HaarHorizontal() );
|
|
|
- cops.push_back ( new HaarVertical() );
|
|
|
- cops.push_back ( new HaarDiag() );
|
|
|
- cops.push_back ( new Haar3Horiz() );
|
|
|
- cops.push_back ( new Haar3Vert() );
|
|
|
- //cops.push_back( new GlobalFeats() );
|
|
|
+ string featsec = "Features";
|
|
|
+
|
|
|
+ if(conf->gB ( featsec, "minus", true ))
|
|
|
+ ops.push_back ( new Minus() );
|
|
|
+ if(conf->gB ( featsec, "minus_abs", true ))
|
|
|
+ ops.push_back ( new MinusAbs() );
|
|
|
+ if(conf->gB ( featsec, "addition", true ))
|
|
|
+ ops.push_back ( new Addition() );
|
|
|
+ if(conf->gB ( featsec, "only1", true ))
|
|
|
+ ops.push_back ( new Only1() );
|
|
|
+ if(conf->gB ( featsec, "rel_x", true ))
|
|
|
+ ops.push_back ( new RelativeXPosition() );
|
|
|
+ if(conf->gB ( featsec, "rel_y", true ))
|
|
|
+ ops.push_back ( new RelativeYPosition() );
|
|
|
+
|
|
|
+ if(conf->gB ( featsec, "bi_int_cent", true ))
|
|
|
+ cops.push_back ( new BiIntegralCenteredOps() );
|
|
|
+ if(conf->gB ( featsec, "int_cent", true ))
|
|
|
+ cops.push_back ( new IntegralCenteredOps() );
|
|
|
+ if(conf->gB ( featsec, "int", true ))
|
|
|
+ cops.push_back ( new IntegralOps() );
|
|
|
+ if(conf->gB ( featsec, "haar_horz", true ))
|
|
|
+ cops.push_back ( new HaarHorizontal() );
|
|
|
+ if(conf->gB ( featsec, "haar_vert", true ))
|
|
|
+ cops.push_back ( new HaarVertical() );
|
|
|
+ if(conf->gB ( featsec, "haar_diag", true ))
|
|
|
+ cops.push_back ( new HaarDiag() );
|
|
|
+ if(conf->gB ( featsec, "haar3_horz", true ))
|
|
|
+ cops.push_back ( new Haar3Horiz() );
|
|
|
+ if(conf->gB ( featsec, "haar3_vert", true ))
|
|
|
+ cops.push_back ( new Haar3Vert() );
|
|
|
+ if(conf->gB ( featsec, "glob", true ))
|
|
|
+ cops.push_back( new GlobalFeats() );
|
|
|
|
|
|
opOverview = vector<int> ( NBOPERATIONS, 0 );
|
|
|
+ contextOverview = vector<vector<double> >(maxDepth, vector<double>(2,0.0));
|
|
|
|
|
|
calcVal.push_back ( new MCImageAccess() );
|
|
|
calcVal.push_back ( new ClassificationResultAcess() );
|
|
@@ -877,6 +895,7 @@ double SemSegContextTree::getBestSplit ( std::vector<NICE::MultiChannelImageT<do
|
|
|
int o = ( int ) ( ( double ) rand() / ( double ) RAND_MAX * ( double ) ops.size() );
|
|
|
Operation *op = ops[o]->clone();
|
|
|
op->set ( x1, y1, x2, y2, f1, f2, calcVal[ft] );
|
|
|
+ op->setContext(false);
|
|
|
featsel.push_back ( op );
|
|
|
}
|
|
|
else if ( ft == 1 )
|
|
@@ -895,15 +914,21 @@ double SemSegContextTree::getBestSplit ( std::vector<NICE::MultiChannelImageT<do
|
|
|
int f2 = ( int ) ( ( double ) rand() / ( double ) RAND_MAX * ( double ) chans );
|
|
|
op = ops[o]->clone();
|
|
|
op->set ( x1, y1, x2, y2, f1, f2, calcVal[ft] );
|
|
|
+ op->setContext(true);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
int chans = integralImgs[0].channels();
|
|
|
int f1 = ( int ) ( ( double ) rand() / ( double ) RAND_MAX * ( double ) chans );
|
|
|
int f2 = ( int ) ( ( double ) rand() / ( double ) RAND_MAX * ( double ) chans );
|
|
|
+
|
|
|
o -= opssize;
|
|
|
op = cops[o]->clone();
|
|
|
op->set ( x1, y1, x2, y2, f1, f2, calcVal[ft] );
|
|
|
+ if(f1 < forest[0][0].dist.size())
|
|
|
+ op->setContext(true);
|
|
|
+ else
|
|
|
+ op->setContext(false);
|
|
|
}
|
|
|
|
|
|
featsel.push_back ( op );
|
|
@@ -1153,34 +1178,6 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
|
|
|
|
int imgcounter = 0;
|
|
|
|
|
|
- /*
|
|
|
- MultiChannelImageT<int> ttmp2(0,0,0);
|
|
|
- MultiChannelImageT<double> ttmp1(100,100,1);
|
|
|
- MultiChannelImageT<double> tint(100,100,1);
|
|
|
- ttmp1.setAll(1.0);
|
|
|
- tint.setAll(0.0);
|
|
|
- computeIntegralImage(ttmp2,ttmp1,tint);
|
|
|
-
|
|
|
-
|
|
|
- for(int i = 0; i < cops.size(); i++)
|
|
|
- {
|
|
|
- Features feats;
|
|
|
- feats.feats = ∭
|
|
|
- feats.cfeats = &ttmp2;
|
|
|
- feats.cTree = 0;
|
|
|
- feats.tree = new vector<TreeNode>;
|
|
|
- feats.integralImg = ∭
|
|
|
- cops[i]->set(-10, -6, 8, 9, 0, 0, new MCImageAccess());
|
|
|
- cout << "for: " << cops[i]->writeInfos() << endl;
|
|
|
- int y = 50;
|
|
|
- for(int x = 40; x < 44; x++)
|
|
|
- {
|
|
|
- cout << "x: " << x << " val: " << cops[i]->getVal(feats, x, y) << endl;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- getchar();*/
|
|
|
-
|
|
|
int amountPixels = 0;
|
|
|
|
|
|
LOOP_ALL_S ( *trainp )
|
|
@@ -1588,6 +1585,7 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
|
{
|
|
|
cout << ", feat: " << forest[tree][i].feat->writeInfos() << " ";
|
|
|
opOverview[forest[tree][i].feat->getOps() ]++;
|
|
|
+ contextOverview[depth][forest[tree][i].feat->getContext()]++;
|
|
|
}
|
|
|
|
|
|
for ( int d = 0; d < ( int ) forest[tree][i].dist.size(); d++ )
|
|
@@ -1608,6 +1606,16 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
|
{
|
|
|
cout << cops[c]->writeInfos() << ": " << opOverview[cops[c]->getOps() ] << endl;
|
|
|
}
|
|
|
+
|
|
|
+ for(int d = 0; d < maxDepth; d++)
|
|
|
+ {
|
|
|
+ double sum = contextOverview[d][0] + contextOverview[d][1];
|
|
|
+
|
|
|
+ contextOverview[d][0] /= sum;
|
|
|
+ contextOverview[d][1] /= sum;
|
|
|
+
|
|
|
+ cout << "depth: " << d << " woContext: " << contextOverview[d][0] << " wContext: " << contextOverview[d][0] << endl;
|
|
|
+ }
|
|
|
|
|
|
#endif
|
|
|
}
|