|
@@ -18,6 +18,9 @@
|
|
|
|
|
|
#define BOUND(x,min,max) (((x)<(min))?(min):((x)>(max)?(max):(x)))
|
|
|
#undef LOCALFEATS
|
|
|
+#undef WRITEGLOB
|
|
|
+#undef TEXTONMAP
|
|
|
+
|
|
|
//#define LOCALFEATS
|
|
|
|
|
|
using namespace OBJREC;
|
|
@@ -1287,7 +1290,9 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
|
vector<MultiChannelImageT<double> > allfeats;
|
|
|
vector<MultiChannelImageT<unsigned short int> > currentfeats;
|
|
|
vector<MatrixT<int> > labels;
|
|
|
+#ifdef TEXTONMAP
|
|
|
vector<MultiChannelImageT<SparseVectorInt> > textonMap;
|
|
|
+#endif
|
|
|
vector<MultiChannelImageT<SparseVectorInt> > integralTexton;
|
|
|
|
|
|
|
|
@@ -1333,8 +1338,10 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
|
|
|
|
currentfeats.push_back ( MultiChannelImageT<unsigned short int> ( xsize, ysize, nbTrees ) );
|
|
|
currentfeats[imgcounter].setAll ( 0 );
|
|
|
+#ifdef TEXTONMAP
|
|
|
textonMap.push_back ( MultiChannelImageT<SparseVectorInt> ( xsize / grid + 1, ysize / grid + 1, 1 ));
|
|
|
integralTexton.push_back ( MultiChannelImageT<SparseVectorInt> ( xsize / grid + 1, ysize / grid + 1, 1 ));
|
|
|
+#endif
|
|
|
|
|
|
labels.push_back ( tmpMat );
|
|
|
|
|
@@ -1586,7 +1593,9 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
|
forest[tree][left].featcounter++;
|
|
|
SparseVectorInt v;
|
|
|
v.insert ( pair<int, double> ( leftu, weight ) );
|
|
|
+#ifdef TEXTONMAP
|
|
|
textonMap[iCounter] ( subx, suby ).add ( v );
|
|
|
+#endif
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -1597,7 +1606,9 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
|
//feld im subsampled finden und in diesem rechts hochzählen
|
|
|
SparseVectorInt v;
|
|
|
v.insert ( pair<int, double> ( rightu, weight ) );
|
|
|
+#ifdef TEXTONMAP
|
|
|
textonMap[iCounter] ( subx, suby ).add ( v );
|
|
|
+#endif
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1719,7 +1730,9 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
|
for ( int i = 0; i < imgcounter; i++ )
|
|
|
{
|
|
|
computeIntegralImage ( currentfeats[i], allfeats[i], integralImgs[i] );
|
|
|
+#ifdef TEXTONMAP
|
|
|
computeIntegralImage ( textonMap[i], integralTexton[i] );
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
#if 1
|
|
@@ -1729,7 +1742,6 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
-#define WRITEGLOB
|
|
|
#ifdef WRITEGLOB
|
|
|
ofstream outstream("globtrain.feat");
|
|
|
|
|
@@ -1842,8 +1854,11 @@ void SemSegContextTree::semanticseg ( CachedExample *ce, NICE::Image & segresult
|
|
|
//TODO: resize image?!
|
|
|
|
|
|
MultiChannelImageT<double> feats;
|
|
|
+
|
|
|
+#ifdef TEXTONMAP
|
|
|
MultiChannelImageT<SparseVectorInt> textonMap ( xsize / grid + 1, ysize / grid + 1, 1 );
|
|
|
MultiChannelImageT<SparseVectorInt> integralTexton ( xsize / grid + 1, ysize / grid + 1, 1 );
|
|
|
+#endif
|
|
|
|
|
|
#ifdef LOCALFEATS
|
|
|
lfcw->getFeats ( img, feats );
|
|
@@ -1918,14 +1933,18 @@ void SemSegContextTree::semanticseg ( CachedExample *ce, NICE::Image & segresult
|
|
|
currentfeats.set ( x, y, forest[tree][t].left, tree );
|
|
|
SparseVectorInt v;
|
|
|
v.insert ( pair<int, double> ( forest[tree][forest[tree][t].left].nodeNumber, weight ) );
|
|
|
+#ifdef TEXTONMAP
|
|
|
textonMap ( subx, suby ).add ( v );
|
|
|
+#endif
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
currentfeats.set ( x, y, forest[tree][t].right, tree );
|
|
|
SparseVectorInt v;
|
|
|
v.insert ( pair<int, double> ( forest[tree][forest[tree][t].right].nodeNumber, weight ) );
|
|
|
+#ifdef TEXTONMAP
|
|
|
textonMap ( subx, suby ).add ( v );
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
/*if ( x == xpos && y == ypos )
|
|
@@ -1951,7 +1970,9 @@ void SemSegContextTree::semanticseg ( CachedExample *ce, NICE::Image & segresult
|
|
|
}
|
|
|
|
|
|
computeIntegralImage ( currentfeats, feats, integralImg );
|
|
|
+#ifdef TEXTONMAP
|
|
|
computeIntegralImage ( textonMap, integralTexton );
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
cout << forest[0][currentfeats.get ( xpos, ypos, 0 ) ].dist << endl;
|