|
@@ -697,25 +697,8 @@ double SemSegContextTree::getBestSplit( std::vector<NICE::MultiChannelImageT<dou
|
|
|
|
|
|
set<vector<int> >selFeats;
|
|
|
map<int, int> e;
|
|
|
- int featcounter = 0;
|
|
|
-
|
|
|
- for ( int iCounter = 0; iCounter < imgCount; iCounter++ )
|
|
|
- {
|
|
|
- int xsize = ( int )currentfeats[iCounter].width();
|
|
|
- int ysize = ( int )currentfeats[iCounter].height();
|
|
|
-
|
|
|
- for ( int x = 0; x < xsize; x++ )
|
|
|
- {
|
|
|
- for ( int y = 0; y < ysize; y++ )
|
|
|
- {
|
|
|
- if ( currentfeats[iCounter].get( x, y, tree ) == node )
|
|
|
- {
|
|
|
- featcounter++;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+ int featcounter = forest[tree][node].featcounter;
|
|
|
+
|
|
|
if ( featcounter < minFeats )
|
|
|
{
|
|
|
//cout << "only " << featcounter << " feats in current node -> it's a leaf" << endl;
|
|
@@ -734,8 +717,6 @@ double SemSegContextTree::getBestSplit( std::vector<NICE::MultiChannelImageT<dou
|
|
|
//cout << "fraction["<<i<<"]: "<< fraction[i] << " a[" << i << "]: " << a[i] << endl;
|
|
|
}
|
|
|
|
|
|
- //cout << "a.size(): " << a.size() << endl;
|
|
|
- //getchar();
|
|
|
featcounter = 0;
|
|
|
|
|
|
for ( int iCounter = 0; iCounter < imgCount; iCounter++ )
|
|
@@ -863,7 +844,7 @@ double SemSegContextTree::getBestSplit( std::vector<NICE::MultiChannelImageT<dou
|
|
|
featsel.push_back( op );
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
#pragma omp parallel for private(mapit)
|
|
|
for ( int f = 0; f < featsPerSplit; f++ )
|
|
|
{
|
|
@@ -964,7 +945,7 @@ double SemSegContextTree::getBestSplit( std::vector<NICE::MultiChannelImageT<dou
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ //getchar();
|
|
|
//splitop->writeInfos();
|
|
|
//cout<< "ig: " << bestig << endl;
|
|
|
//FIXME: delete all features!
|
|
@@ -998,9 +979,7 @@ void SemSegContextTree::computeIntegralImage( const NICE::MultiChannelImageT<int
|
|
|
int ysize = currentfeats.height();
|
|
|
|
|
|
int channels = ( int )forest[0][0].dist.size();
|
|
|
-
|
|
|
#pragma omp parallel for
|
|
|
-
|
|
|
for ( int c = 0; c < channels; c++ )
|
|
|
{
|
|
|
integralImage.set( 0, 0, getMeanProb( 0, 0, c, currentfeats ), c );
|
|
@@ -1037,7 +1016,6 @@ void SemSegContextTree::computeIntegralImage( const NICE::MultiChannelImageT<int
|
|
|
if ( integralImage.get( xsize - 1, ysize - 1, channels ) == 0.0 )
|
|
|
{
|
|
|
#pragma omp parallel for
|
|
|
-
|
|
|
for ( int c1 = 0; c1 < channels2; c1++ )
|
|
|
{
|
|
|
int c = channels + c1;
|
|
@@ -1121,6 +1099,8 @@ void SemSegContextTree::train( const MultiDataset *md )
|
|
|
|
|
|
getchar();*/
|
|
|
|
|
|
+ int amountPixels = 0;
|
|
|
+
|
|
|
LOOP_ALL_S( *trainp )
|
|
|
{
|
|
|
EACH_INFO( classno, info );
|
|
@@ -1144,6 +1124,7 @@ void SemSegContextTree::train( const MultiDataset *md )
|
|
|
|
|
|
int xsize, ysize;
|
|
|
ce->getImageSize( xsize, ysize );
|
|
|
+ amountPixels += xsize*ysize;
|
|
|
|
|
|
MatrixT<int> tmpMat( xsize, ysize );
|
|
|
|
|
@@ -1268,6 +1249,7 @@ void SemSegContextTree::train( const MultiDataset *md )
|
|
|
tree.push_back( TreeNode() );
|
|
|
tree[0].dist = vector<double>( classes, 0.0 );
|
|
|
tree[0].depth = depth;
|
|
|
+ tree[0].featcounter = amountPixels;
|
|
|
forest.push_back( tree );
|
|
|
}
|
|
|
|
|
@@ -1295,15 +1277,28 @@ void SemSegContextTree::train( const MultiDataset *md )
|
|
|
startnode[tree] = t;
|
|
|
//TODO vielleicht parallel wenn nächste schleife trotzdem noch parallelsiert würde, die hat mehr gewicht
|
|
|
//#pragma omp parallel for
|
|
|
-
|
|
|
+#if 0
|
|
|
+ timer.stop();
|
|
|
+ cout << "time before tree: " << timer.getLast() << endl;
|
|
|
+ timer.start();
|
|
|
+#endif
|
|
|
for ( int i = s; i < t; i++ )
|
|
|
{
|
|
|
if ( !forest[tree][i].isleaf && forest[tree][i].left < 0 )
|
|
|
{
|
|
|
+#if 0
|
|
|
+ timer.stop();
|
|
|
+ cout << "time 1: " << timer.getLast() << endl;
|
|
|
+ timer.start();
|
|
|
+#endif
|
|
|
Operation *splitfeat = NULL;
|
|
|
double splitval;
|
|
|
double bestig = getBestSplit( allfeats, lastfeats, integralImgs, labels, i, splitfeat, splitval, tree );
|
|
|
-
|
|
|
+#if 0
|
|
|
+ timer.stop();
|
|
|
+ cout << "time 2: " << timer.getLast() << endl;
|
|
|
+ timer.start();
|
|
|
+#endif
|
|
|
forest[tree][i].feat = splitfeat;
|
|
|
forest[tree][i].decision = splitval;
|
|
|
|
|
@@ -1320,9 +1315,14 @@ void SemSegContextTree::train( const MultiDataset *md )
|
|
|
forest[tree][right].dist = vector<double>( classes, 0.0 );
|
|
|
forest[tree][left].depth = depth + 1;
|
|
|
forest[tree][right].depth = depth + 1;
|
|
|
-
|
|
|
+ forest[tree][left].featcounter = 0;
|
|
|
+ forest[tree][right].featcounter = 0;
|
|
|
+#if 0
|
|
|
+ timer.stop();
|
|
|
+ cout << "time 3: " << timer.getLast() << endl;
|
|
|
+ timer.start();
|
|
|
+#endif
|
|
|
#pragma omp parallel for
|
|
|
-
|
|
|
for ( int iCounter = 0; iCounter < imgcounter; iCounter++ )
|
|
|
{
|
|
|
int xsize = currentfeats[iCounter].width();
|
|
@@ -1346,6 +1346,7 @@ void SemSegContextTree::train( const MultiDataset *md )
|
|
|
{
|
|
|
currentfeats[iCounter].set( x, y, left, tree );
|
|
|
forest[tree][left].dist[labelmap[labels[iCounter]( x, y )]]++;
|
|
|
+ forest[tree][left].featcounter++;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -1356,7 +1357,13 @@ void SemSegContextTree::train( const MultiDataset *md )
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+#if 0
|
|
|
+ timer.stop();
|
|
|
+ cout << "time 4: " << timer.getLast() << endl;
|
|
|
+ timer.start();
|
|
|
+#endif
|
|
|
+ forest[tree][right].featcounter = forest[tree][i].featcounter - forest[tree][left].featcounter;
|
|
|
+
|
|
|
double lcounter = 0.0, rcounter = 0.0;
|
|
|
|
|
|
for ( uint d = 0; d < forest[tree][left].dist.size(); d++ )
|
|
@@ -1374,7 +1381,11 @@ void SemSegContextTree::train( const MultiDataset *md )
|
|
|
rcounter += forest[tree][right].dist[d];
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+#if 0
|
|
|
+ timer.stop();
|
|
|
+ cout << "time 5: " << timer.getLast() << endl;
|
|
|
+ timer.start();
|
|
|
+#endif
|
|
|
if ( lcounter <= 0 || rcounter <= 0 )
|
|
|
{
|
|
|
cout << "lcounter : " << lcounter << " rcounter: " << rcounter << endl;
|
|
@@ -1431,13 +1442,23 @@ void SemSegContextTree::train( const MultiDataset *md )
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+#if 0
|
|
|
+ timer.stop();
|
|
|
+ cout << "time after tree: " << timer.getLast() << endl;
|
|
|
+ timer.start();
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
//TODO: features neu berechnen!
|
|
|
|
|
|
//compute integral image
|
|
|
int channels = classes + allfeats[0].channels();
|
|
|
-
|
|
|
+#if 0
|
|
|
+ timer.stop();
|
|
|
+ cout << "time for part0: " << timer.getLast() << endl;
|
|
|
+ timer.start();
|
|
|
+#endif
|
|
|
+
|
|
|
if ( integralImgs[0].width() == 0 )
|
|
|
{
|
|
|
for ( int i = 0; i < imgcounter; i++ )
|
|
@@ -1448,7 +1469,14 @@ void SemSegContextTree::train( const MultiDataset *md )
|
|
|
integralImgs[i].setAll( 0.0 );
|
|
|
}
|
|
|
}
|
|
|
+#if 0
|
|
|
+ timer.stop();
|
|
|
+ cout << "time for part1: " << timer.getLast() << endl;
|
|
|
+ timer.start();
|
|
|
+#endif
|
|
|
+
|
|
|
|
|
|
+#pragma omp parallel for
|
|
|
for ( int i = 0; i < imgcounter; i++ )
|
|
|
{
|
|
|
computeIntegralImage( currentfeats[i], allfeats[i], integralImgs[i] );
|
|
@@ -1464,7 +1492,6 @@ void SemSegContextTree::train( const MultiDataset *md )
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
cout << "depth: " << depth << endl;
|
|
|
-
|
|
|
#endif
|
|
|
}
|
|
|
|