|
@@ -196,7 +196,7 @@ double SemSegContextTree::getBestSplit ( std::vector<NICE::MultiChannelImageT<do
|
|
|
|
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- imgCount = (int)feats.size();
|
|
|
|
|
|
+ imgCount = ( int ) feats.size();
|
|
}
|
|
}
|
|
catch ( Exception )
|
|
catch ( Exception )
|
|
{
|
|
{
|
|
@@ -225,15 +225,15 @@ double SemSegContextTree::getBestSplit ( std::vector<NICE::MultiChannelImageT<do
|
|
if ( forbidden_classes.find ( labelmapback[i] ) != forbidden_classes.end() )
|
|
if ( forbidden_classes.find ( labelmapback[i] ) != forbidden_classes.end() )
|
|
fraction[i] = 0;
|
|
fraction[i] = 0;
|
|
else
|
|
else
|
|
- fraction[i] = ( (double)maxSamples ) / ( (double)featcounter * a[i] * a.size() );
|
|
|
|
|
|
+ fraction[i] = ( ( double ) maxSamples ) / ( ( double ) featcounter * a[i] * a.size() );
|
|
}
|
|
}
|
|
|
|
|
|
featcounter = 0;
|
|
featcounter = 0;
|
|
|
|
|
|
for ( int iCounter = 0; iCounter < imgCount; iCounter++ )
|
|
for ( int iCounter = 0; iCounter < imgCount; iCounter++ )
|
|
{
|
|
{
|
|
- int xsize = (int)currentfeats[iCounter].width();
|
|
|
|
- int ysize = (int)currentfeats[iCounter].height();
|
|
|
|
|
|
+ int xsize = ( int ) currentfeats[iCounter].width();
|
|
|
|
+ int ysize = ( int ) currentfeats[iCounter].height();
|
|
|
|
|
|
for ( int x = 0; x < xsize; x++ )
|
|
for ( int x = 0; x < xsize; x++ )
|
|
{
|
|
{
|
|
@@ -242,7 +242,7 @@ double SemSegContextTree::getBestSplit ( std::vector<NICE::MultiChannelImageT<do
|
|
if ( currentfeats[iCounter].get ( x, y, tree ) == node )
|
|
if ( currentfeats[iCounter].get ( x, y, tree ) == node )
|
|
{
|
|
{
|
|
int cn = labels[iCounter] ( x, y );
|
|
int cn = labels[iCounter] ( x, y );
|
|
- double randD = (double)rand() / (double)RAND_MAX;
|
|
|
|
|
|
+ double randD = ( double ) rand() / ( double ) RAND_MAX;
|
|
|
|
|
|
if ( labelmap.find ( cn ) == labelmap.end() )
|
|
if ( labelmap.find ( cn ) == labelmap.end() )
|
|
continue;
|
|
continue;
|
|
@@ -268,7 +268,7 @@ double SemSegContextTree::getBestSplit ( std::vector<NICE::MultiChannelImageT<do
|
|
|
|
|
|
for ( mapit = e.begin() ; mapit != e.end(); mapit++ )
|
|
for ( mapit = e.begin() ; mapit != e.end(); mapit++ )
|
|
{
|
|
{
|
|
- double p = (double)( *mapit ).second / (double)featcounter;
|
|
|
|
|
|
+ double p = ( double ) ( *mapit ).second / ( double ) featcounter;
|
|
globent += p * log2 ( p );
|
|
globent += p * log2 ( p );
|
|
}
|
|
}
|
|
|
|
|
|
@@ -278,14 +278,14 @@ double SemSegContextTree::getBestSplit ( std::vector<NICE::MultiChannelImageT<do
|
|
{
|
|
{
|
|
return 0.0;
|
|
return 0.0;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/** vector of all possible features */
|
|
/** vector of all possible features */
|
|
std::vector<Operation*> featsel;
|
|
std::vector<Operation*> featsel;
|
|
|
|
|
|
for ( int i = 0; i < featsPerSplit; i++ )
|
|
for ( int i = 0; i < featsPerSplit; i++ )
|
|
{
|
|
{
|
|
int x1, x2, y1, y2;
|
|
int x1, x2, y1, y2;
|
|
- int ft = (int)( (double)rand() / (double)RAND_MAX * (double)ftypes );
|
|
|
|
|
|
+ int ft = ( int ) ( ( double ) rand() / ( double ) RAND_MAX * ( double ) ftypes );
|
|
|
|
|
|
int tmpws = windowSize;
|
|
int tmpws = windowSize;
|
|
|
|
|
|
@@ -303,14 +303,14 @@ double SemSegContextTree::getBestSplit ( std::vector<NICE::MultiChannelImageT<do
|
|
tmpws *= 4;
|
|
tmpws *= 4;
|
|
}
|
|
}
|
|
|
|
|
|
- x1 = (int)( (double)rand() / (double)RAND_MAX * (double)tmpws ) - tmpws / 2;
|
|
|
|
- x2 = (int)( (double)rand() / (double)RAND_MAX * (double)tmpws ) - tmpws / 2;
|
|
|
|
- y1 = (int)( (double)rand() / (double)RAND_MAX * (double)tmpws ) - tmpws / 2;
|
|
|
|
- y2 = (int)( (double)rand() / (double)RAND_MAX * (double)tmpws ) - tmpws / 2;
|
|
|
|
|
|
+ x1 = ( int ) ( ( double ) rand() / ( double ) RAND_MAX * ( double ) tmpws ) - tmpws / 2;
|
|
|
|
+ x2 = ( int ) ( ( double ) rand() / ( double ) RAND_MAX * ( double ) tmpws ) - tmpws / 2;
|
|
|
|
+ y1 = ( int ) ( ( double ) rand() / ( double ) RAND_MAX * ( double ) tmpws ) - tmpws / 2;
|
|
|
|
+ y2 = ( int ) ( ( double ) rand() / ( double ) RAND_MAX * ( double ) tmpws ) - tmpws / 2;
|
|
|
|
|
|
- int f1 = ( int ) ( (double) rand() / (double) RAND_MAX * (double) channelsPerType[ft].size() );
|
|
|
|
- int f2 = ( int ) ( (double) rand() / (double) RAND_MAX * (double) channelsPerType[ft].size() );
|
|
|
|
- int o = ( int ) ( (double) rand() / (double) RAND_MAX * (double) ops[ft].size() );
|
|
|
|
|
|
+ int f1 = ( int ) ( ( double ) rand() / ( double ) RAND_MAX * ( double ) channelsPerType[ft].size() );
|
|
|
|
+ int f2 = ( int ) ( ( double ) rand() / ( double ) RAND_MAX * ( double ) channelsPerType[ft].size() );
|
|
|
|
+ int o = ( int ) ( ( double ) rand() / ( double ) RAND_MAX * ( double ) ops[ft].size() );
|
|
|
|
|
|
Operation *op = ops[ft][o]->clone();
|
|
Operation *op = ops[ft][o]->clone();
|
|
|
|
|
|
@@ -361,7 +361,7 @@ double SemSegContextTree::getBestSplit ( std::vector<NICE::MultiChannelImageT<do
|
|
|
|
|
|
for ( int r = 0; r < randomTests; r++ )
|
|
for ( int r = 0; r < randomTests; r++ )
|
|
{
|
|
{
|
|
- splits.push_back ( ( (double)rand() / (double)RAND_MAX*scale ) + minval );
|
|
|
|
|
|
+ splits.push_back ( ( ( double ) rand() / ( double ) RAND_MAX*scale ) + minval );
|
|
}
|
|
}
|
|
|
|
|
|
for ( int run = 0 ; run < randomTests; run++ )
|
|
for ( int run = 0 ; run < randomTests; run++ )
|
|
@@ -396,7 +396,7 @@ double SemSegContextTree::getBestSplit ( std::vector<NICE::MultiChannelImageT<do
|
|
|
|
|
|
for ( mapit = eL.begin() ; mapit != eL.end(); mapit++ )
|
|
for ( mapit = eL.begin() ; mapit != eL.end(); mapit++ )
|
|
{
|
|
{
|
|
- double p = (double)( *mapit ).second / (double)counterL;
|
|
|
|
|
|
+ double p = ( double ) ( *mapit ).second / ( double ) counterL;
|
|
leftent -= p * log2 ( p );
|
|
leftent -= p * log2 ( p );
|
|
}
|
|
}
|
|
|
|
|
|
@@ -404,13 +404,13 @@ double SemSegContextTree::getBestSplit ( std::vector<NICE::MultiChannelImageT<do
|
|
|
|
|
|
for ( mapit = eR.begin() ; mapit != eR.end(); mapit++ )
|
|
for ( mapit = eR.begin() ; mapit != eR.end(); mapit++ )
|
|
{
|
|
{
|
|
- double p = (double)( *mapit ).second / (double)counterR;
|
|
|
|
|
|
+ double p = ( double ) ( *mapit ).second / ( double ) counterR;
|
|
rightent -= p * log2 ( p );
|
|
rightent -= p * log2 ( p );
|
|
}
|
|
}
|
|
|
|
|
|
//cout << "rightent: " << rightent << " leftent: " << leftent << endl;
|
|
//cout << "rightent: " << rightent << " leftent: " << leftent << endl;
|
|
|
|
|
|
- double pl = (double)counterL / (double)( counterL + counterR );
|
|
|
|
|
|
+ double pl = ( double ) counterL / ( double ) ( counterL + counterR );
|
|
|
|
|
|
double ig = globent - ( 1.0 - pl ) * rightent - pl * leftent;
|
|
double ig = globent - ( 1.0 - pl ) * rightent - pl * leftent;
|
|
|
|
|
|
@@ -448,7 +448,7 @@ double SemSegContextTree::getBestSplit ( std::vector<NICE::MultiChannelImageT<do
|
|
}*/
|
|
}*/
|
|
|
|
|
|
|
|
|
|
-#ifdef DEBUG
|
|
|
|
|
|
+#ifdef DEBUGA
|
|
cout << "globent: " << globent << " bestig " << bestig << " splitval: " << splitval << endl;
|
|
cout << "globent: " << globent << " bestig " << bestig << " splitval: " << splitval << endl;
|
|
|
|
|
|
#endif
|
|
#endif
|
|
@@ -464,7 +464,7 @@ inline double SemSegContextTree::getMeanProb ( const int &x, const int &y, const
|
|
val += forest[tree][currentfeats.get ( x,y,tree ) ].dist[channel];
|
|
val += forest[tree][currentfeats.get ( x,y,tree ) ].dist[channel];
|
|
}
|
|
}
|
|
|
|
|
|
- return val / (double)nbTrees;
|
|
|
|
|
|
+ return val / ( double ) nbTrees;
|
|
}
|
|
}
|
|
|
|
|
|
void SemSegContextTree::computeIntegralImage ( const NICE::MultiChannelImageT<SparseVectorInt> &infeats, NICE::MultiChannelImageT<SparseVectorInt> &integralImage )
|
|
void SemSegContextTree::computeIntegralImage ( const NICE::MultiChannelImageT<SparseVectorInt> &infeats, NICE::MultiChannelImageT<SparseVectorInt> &integralImage )
|
|
@@ -513,25 +513,27 @@ void SemSegContextTree::computeIntegralImage ( const NICE::MultiChannelImageT<un
|
|
{
|
|
{
|
|
firstiteration = false;
|
|
firstiteration = false;
|
|
#pragma omp parallel for
|
|
#pragma omp parallel for
|
|
- for ( int it = 0; it < integralMap.size(); it++ )
|
|
|
|
|
|
+ for ( int it = 0; it < ( int ) integralMap.size(); it++ )
|
|
{
|
|
{
|
|
|
|
+ //cerr << "there are " << omp_get_num_threads() << " threads. " << endl;
|
|
|
|
+ //cerr << "current thread: " << omp_get_thread_num() << endl;
|
|
int c1 = integralMap[it].first;
|
|
int c1 = integralMap[it].first;
|
|
int c = integralMap[it].second;
|
|
int c = integralMap[it].second;
|
|
|
|
|
|
- feats( 0, 0, c ) = feats( 0, 0, c1 );
|
|
|
|
|
|
+ feats ( 0, 0, c ) = feats ( 0, 0, c1 );
|
|
|
|
|
|
//first column
|
|
//first column
|
|
for ( int y = 1; y < ysize; y++ )
|
|
for ( int y = 1; y < ysize; y++ )
|
|
{
|
|
{
|
|
- feats( 0, y, c ) = feats.get ( 0, y, c1 )
|
|
|
|
- + feats.get ( 0, y-1, c );
|
|
|
|
|
|
+ feats ( 0, y, c ) = feats.get ( 0, y, c1 )
|
|
|
|
+ + feats.get ( 0, y - 1, c );
|
|
}
|
|
}
|
|
|
|
|
|
//first row
|
|
//first row
|
|
for ( int x = 1; x < xsize; x++ )
|
|
for ( int x = 1; x < xsize; x++ )
|
|
{
|
|
{
|
|
- feats( x, 0, c ) = feats.get ( x, 0, c1 )
|
|
|
|
- + feats.get ( x-1, 0, c );
|
|
|
|
|
|
+ feats ( x, 0, c ) = feats.get ( x, 0, c1 )
|
|
|
|
+ + feats.get ( x - 1, 0, c );
|
|
}
|
|
}
|
|
|
|
|
|
//rest
|
|
//rest
|
|
@@ -539,17 +541,17 @@ void SemSegContextTree::computeIntegralImage ( const NICE::MultiChannelImageT<un
|
|
{
|
|
{
|
|
for ( int x = 1; x < xsize; x++ )
|
|
for ( int x = 1; x < xsize; x++ )
|
|
{
|
|
{
|
|
- feats ( x, y, c ) = feats ( x, y, c1 )
|
|
|
|
- + feats ( x, y - 1, c )
|
|
|
|
- + feats ( x - 1, y, c )
|
|
|
|
- - feats ( x - 1, y - 1, c );
|
|
|
|
|
|
+ feats ( x, y, c ) = feats ( x, y, c1 )
|
|
|
|
+ + feats ( x, y - 1, c )
|
|
|
|
+ + feats ( x - 1, y, c )
|
|
|
|
+ - feats ( x - 1, y - 1, c );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
int channels = ( int ) forest[0][0].dist.size();
|
|
int channels = ( int ) forest[0][0].dist.size();
|
|
-
|
|
|
|
|
|
+
|
|
#pragma omp parallel for
|
|
#pragma omp parallel for
|
|
for ( int c = 0; c < channels; c++ )
|
|
for ( int c = 0; c < channels; c++ )
|
|
{
|
|
{
|
|
@@ -585,7 +587,7 @@ void SemSegContextTree::computeIntegralImage ( const NICE::MultiChannelImageT<un
|
|
|
|
|
|
inline double computeWeight ( const double &d, const double &dim )
|
|
inline double computeWeight ( const double &d, const double &dim )
|
|
{
|
|
{
|
|
- return 1.0 / ( pow ( 2, (double)( dim - d + 1 ) ) );
|
|
|
|
|
|
+ return 1.0 / ( pow ( 2, ( double ) ( dim - d + 1 ) ) );
|
|
}
|
|
}
|
|
|
|
|
|
void SemSegContextTree::train ( const MultiDataset *md )
|
|
void SemSegContextTree::train ( const MultiDataset *md )
|
|
@@ -764,7 +766,7 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
|
|
|
|
channelsPerType = vector<vector<int> > ( amountTypes, vector<int>() );
|
|
channelsPerType = vector<vector<int> > ( amountTypes, vector<int>() );
|
|
|
|
|
|
- for ( int i = 0; i < channelType.size(); i++ )
|
|
|
|
|
|
+ for ( int i = 0; i < ( int ) channelType.size(); i++ )
|
|
{
|
|
{
|
|
channelsPerType[channelType[i]].push_back ( i );
|
|
channelsPerType[channelType[i]].push_back ( i );
|
|
}
|
|
}
|
|
@@ -785,8 +787,8 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
|
|
|
|
for ( int iCounter = 0; iCounter < imgcounter; iCounter++ )
|
|
for ( int iCounter = 0; iCounter < imgcounter; iCounter++ )
|
|
{
|
|
{
|
|
- int xsize = (int)currentfeats[iCounter].width();
|
|
|
|
- int ysize = (int)currentfeats[iCounter].height();
|
|
|
|
|
|
+ int xsize = ( int ) currentfeats[iCounter].width();
|
|
|
|
+ int ysize = ( int ) currentfeats[iCounter].height();
|
|
|
|
|
|
for ( int x = 0; x < xsize; x++ )
|
|
for ( int x = 0; x < xsize; x++ )
|
|
{
|
|
{
|
|
@@ -801,13 +803,13 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- for ( int i = 0; i < (int)a.size(); i++ )
|
|
|
|
|
|
+ for ( int i = 0; i < ( int ) a.size(); i++ )
|
|
{
|
|
{
|
|
- a[i] /= (double)featcounter;
|
|
|
|
|
|
+ a[i] /= ( double ) featcounter;
|
|
}
|
|
}
|
|
|
|
|
|
#ifdef DEBUG
|
|
#ifdef DEBUG
|
|
- for ( int i = 0; i < (int)a.size(); i++ )
|
|
|
|
|
|
+ for ( int i = 0; i < ( int ) a.size(); i++ )
|
|
{
|
|
{
|
|
cout << "a[" << i << "]: " << a[i] << endl;
|
|
cout << "a[" << i << "]: " << a[i] << endl;
|
|
}
|
|
}
|
|
@@ -840,7 +842,7 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
timer.stop();
|
|
timer.stop();
|
|
cerr << "preprocessing finished in: " << timer.getLastAbsolute() << " seconds" << endl;
|
|
cerr << "preprocessing finished in: " << timer.getLastAbsolute() << " seconds" << endl;
|
|
timer.start();
|
|
timer.start();
|
|
-
|
|
|
|
|
|
+
|
|
while ( !allleaf && depth < maxDepth )
|
|
while ( !allleaf && depth < maxDepth )
|
|
{
|
|
{
|
|
depth++;
|
|
depth++;
|
|
@@ -861,23 +863,24 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
{
|
|
{
|
|
weight = computeWeight ( 1, maxDepth );
|
|
weight = computeWeight ( 1, maxDepth );
|
|
}
|
|
}
|
|
-
|
|
|
|
-#pragma omp parallel for
|
|
|
|
|
|
+
|
|
|
|
+ // omp_set_dynamic(0);
|
|
|
|
+//#pragma omp parallel for
|
|
for ( int tree = 0; tree < nbTrees; tree++ )
|
|
for ( int tree = 0; tree < nbTrees; tree++ )
|
|
{
|
|
{
|
|
- int t = (int)forest[tree].size();
|
|
|
|
- int s = startnode[tree];
|
|
|
|
|
|
+ const int t = ( int ) forest[tree].size();
|
|
|
|
+ const int s = startnode[tree];
|
|
startnode[tree] = t;
|
|
startnode[tree] = t;
|
|
-#pragma omp parallel for
|
|
|
|
|
|
+#pragma omp parallel for
|
|
for ( int i = s; i < t; i++ )
|
|
for ( int i = s; i < t; i++ )
|
|
{
|
|
{
|
|
if ( !forest[tree][i].isleaf && forest[tree][i].left < 0 )
|
|
if ( !forest[tree][i].isleaf && forest[tree][i].left < 0 )
|
|
{
|
|
{
|
|
Operation *splitfeat = NULL;
|
|
Operation *splitfeat = NULL;
|
|
double splitval;
|
|
double splitval;
|
|
- double bestig = getBestSplit(allfeats, lastfeats, labels, i, splitfeat, splitval, tree);
|
|
|
|
|
|
+ double bestig = getBestSplit ( allfeats, lastfeats, labels, i, splitfeat, splitval, tree );
|
|
|
|
|
|
- for ( int ii = 0; ii < lastfeats.size(); ii++ )
|
|
|
|
|
|
+ for ( int ii = 0; ii < ( int ) lastfeats.size(); ii++ )
|
|
{
|
|
{
|
|
for ( int c = 0; c < lastfeats[ii].channels(); c++ )
|
|
for ( int c = 0; c < lastfeats[ii].channels(); c++ )
|
|
{
|
|
{
|
|
@@ -892,9 +895,13 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
if ( splitfeat != NULL )
|
|
if ( splitfeat != NULL )
|
|
{
|
|
{
|
|
allleaf = false;
|
|
allleaf = false;
|
|
- int left = forest[tree].size();
|
|
|
|
- forest[tree].push_back ( TreeNode() );
|
|
|
|
- forest[tree].push_back ( TreeNode() );
|
|
|
|
|
|
+ int left;
|
|
|
|
+ #pragma omp critical
|
|
|
|
+ {
|
|
|
|
+ left = forest[tree].size();
|
|
|
|
+ forest[tree].push_back ( TreeNode() );
|
|
|
|
+ forest[tree].push_back ( TreeNode() );
|
|
|
|
+ }
|
|
int right = left + 1;
|
|
int right = left + 1;
|
|
forest[tree][i].left = left;
|
|
forest[tree][i].left = left;
|
|
forest[tree][i].right = right;
|
|
forest[tree][i].right = right;
|
|
@@ -931,9 +938,8 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
feat.tree = &forest[tree];
|
|
feat.tree = &forest[tree];
|
|
double val = splitfeat->getVal ( feat, x, y );
|
|
double val = splitfeat->getVal ( feat, x, y );
|
|
|
|
|
|
- int subx = x / grid;
|
|
|
|
- int suby = y / grid;
|
|
|
|
-
|
|
|
|
|
|
+ //int subx = x / grid;
|
|
|
|
+ //int suby = y / grid;
|
|
#pragma omp critical
|
|
#pragma omp critical
|
|
if ( val < splitval )
|
|
if ( val < splitval )
|
|
{
|
|
{
|
|
@@ -1035,18 +1041,15 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
//compute integral images
|
|
//compute integral images
|
|
if ( firstiteration )
|
|
if ( firstiteration )
|
|
{
|
|
{
|
|
for ( int i = 0; i < imgcounter; i++ )
|
|
for ( int i = 0; i < imgcounter; i++ )
|
|
{
|
|
{
|
|
- int pos = allfeats.size();
|
|
|
|
allfeats[i].addChannel ( ( int ) ( classes + rawChannels ) );
|
|
allfeats[i].addChannel ( ( int ) ( classes + rawChannels ) );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-#pragma omp parallel for
|
|
|
|
for ( int i = 0; i < imgcounter; i++ )
|
|
for ( int i = 0; i < imgcounter; i++ )
|
|
{
|
|
{
|
|
computeIntegralImage ( currentfeats[i], allfeats[i], channelType.size() - classes );
|
|
computeIntegralImage ( currentfeats[i], allfeats[i], channelType.size() - classes );
|
|
@@ -1061,7 +1064,7 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
cout << "time for depth " << depth << ": " << timerDepth.getLastAbsolute() << endl;
|
|
cout << "time for depth " << depth << ": " << timerDepth.getLastAbsolute() << endl;
|
|
#endif
|
|
#endif
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
timer.stop();
|
|
timer.stop();
|
|
cerr << "learning finished in: " << timer.getLastAbsolute() << " seconds" << endl;
|
|
cerr << "learning finished in: " << timer.getLastAbsolute() << " seconds" << endl;
|
|
timer.start();
|
|
timer.start();
|
|
@@ -1102,7 +1105,7 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
#ifdef DEBUG
|
|
#ifdef DEBUG
|
|
for ( int tree = 0; tree < nbTrees; tree++ )
|
|
for ( int tree = 0; tree < nbTrees; tree++ )
|
|
{
|
|
{
|
|
- int t = (int)forest[tree].size();
|
|
|
|
|
|
+ int t = ( int ) forest[tree].size();
|
|
|
|
|
|
for ( int i = 0; i < t; i++ )
|
|
for ( int i = 0; i < t; i++ )
|
|
{
|
|
{
|
|
@@ -1112,10 +1115,10 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
{
|
|
{
|
|
cout << ", feat: " << forest[tree][i].feat->writeInfos() << " ";
|
|
cout << ", feat: " << forest[tree][i].feat->writeInfos() << " ";
|
|
opOverview[forest[tree][i].feat->getOps() ]++;
|
|
opOverview[forest[tree][i].feat->getOps() ]++;
|
|
- contextOverview[forest[tree][i].depth][ (int)forest[tree][i].feat->getContext() ]++;
|
|
|
|
|
|
+ contextOverview[forest[tree][i].depth][ ( int ) forest[tree][i].feat->getContext() ]++;
|
|
}
|
|
}
|
|
|
|
|
|
- for ( int d = 0; d < (int)forest[tree][i].dist.size(); d++ )
|
|
|
|
|
|
+ for ( int d = 0; d < ( int ) forest[tree][i].dist.size(); d++ )
|
|
{
|
|
{
|
|
cout << " " << forest[tree][i].dist[d];
|
|
cout << " " << forest[tree][i].dist[d];
|
|
}
|
|
}
|
|
@@ -1183,7 +1186,7 @@ void SemSegContextTree::extractBasicFeatures ( NICE::MultiChannelImageT<double>
|
|
ImageT<double> tmp = feats[c];
|
|
ImageT<double> tmp = feats[c];
|
|
ImageT<double> tmp2 = feats[c+currentsize];
|
|
ImageT<double> tmp2 = feats[c+currentsize];
|
|
|
|
|
|
- NICE::FilterT<double,double,double>::gradientStrength( tmp, tmp2 );
|
|
|
|
|
|
+ NICE::FilterT<double, double, double>::gradientStrength ( tmp, tmp2 );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1228,9 +1231,9 @@ void SemSegContextTree::extractBasicFeatures ( NICE::MultiChannelImageT<double>
|
|
ImageT<double> dst = feats[currentChannel];
|
|
ImageT<double> dst = feats[currentChannel];
|
|
|
|
|
|
// copy standard image to double image
|
|
// copy standard image to double image
|
|
- for ( uint y = 0 ; y < confidenceImage.height(); y++ )
|
|
|
|
- for ( uint x = 0 ; x < confidenceImage.width(); x++ )
|
|
|
|
- feats ( x, y, currentChannel ) = (double) confidenceImage ( x, y );
|
|
|
|
|
|
+ for ( uint y = 0 ; y < ( uint ) confidenceImage.height(); y++ )
|
|
|
|
+ for ( uint x = 0 ; x < ( uint ) confidenceImage.width(); x++ )
|
|
|
|
+ feats ( x, y, currentChannel ) = ( double ) confidenceImage ( x, y );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1317,9 +1320,8 @@ void SemSegContextTree::semanticseg ( CachedExample *ce, NICE::Image & segresult
|
|
|
|
|
|
double val = forest[tree][t].feat->getVal ( feat, x, y );
|
|
double val = forest[tree][t].feat->getVal ( feat, x, y );
|
|
|
|
|
|
- int subx = x / grid;
|
|
|
|
- int suby = y / grid;
|
|
|
|
-
|
|
|
|
|
|
+ //int subx = x / grid;
|
|
|
|
+ //int suby = y / grid;
|
|
if ( val < forest[tree][t].decision )
|
|
if ( val < forest[tree][t].decision )
|
|
{
|
|
{
|
|
currentfeats.set ( x, y, forest[tree][t].left, tree );
|
|
currentfeats.set ( x, y, forest[tree][t].left, tree );
|
|
@@ -1473,7 +1475,7 @@ void SemSegContextTree::semanticseg ( CachedExample *ce, NICE::Image & segresult
|
|
}
|
|
}
|
|
#undef VISUALIZE
|
|
#undef VISUALIZE
|
|
#ifdef VISUALIZE
|
|
#ifdef VISUALIZE
|
|
- for ( int j = 0 ; j < (int)probabilities.numChannels; j++ )
|
|
|
|
|
|
+ for ( int j = 0 ; j < ( int ) probabilities.numChannels; j++ )
|
|
{
|
|
{
|
|
//cout << "class: " << j << endl;//" " << cn.text ( j ) << endl;
|
|
//cout << "class: " << j << endl;//" " << cn.text ( j ) << endl;
|
|
|
|
|
|
@@ -1587,7 +1589,7 @@ void SemSegContextTree::semanticseg ( CachedExample *ce, NICE::Image & segresult
|
|
|
|
|
|
void SemSegContextTree::store ( std::ostream & os, int format ) const
|
|
void SemSegContextTree::store ( std::ostream & os, int format ) const
|
|
{
|
|
{
|
|
- os.precision (numeric_limits<double>::digits10 + 1);
|
|
|
|
|
|
+ os.precision ( numeric_limits<double>::digits10 + 1 );
|
|
os << nbTrees << endl;
|
|
os << nbTrees << endl;
|
|
classnames.store ( os );
|
|
classnames.store ( os );
|
|
|
|
|
|
@@ -1624,14 +1626,14 @@ void SemSegContextTree::store ( std::ostream & os, int format ) const
|
|
}
|
|
}
|
|
|
|
|
|
os << channelType.size() << endl;
|
|
os << channelType.size() << endl;
|
|
- for ( int i = 0; i < channelType.size(); i++ )
|
|
|
|
|
|
+ for ( int i = 0; i < ( int ) channelType.size(); i++ )
|
|
{
|
|
{
|
|
os << channelType[i] << " ";
|
|
os << channelType[i] << " ";
|
|
}
|
|
}
|
|
os << endl;
|
|
os << endl;
|
|
|
|
|
|
os << integralMap.size() << endl;
|
|
os << integralMap.size() << endl;
|
|
- for ( int i = 0; i < integralMap.size(); i++ )
|
|
|
|
|
|
+ for ( int i = 0; i < ( int ) integralMap.size(); i++ )
|
|
{
|
|
{
|
|
os << integralMap[i].first << " " << integralMap[i].second << endl;
|
|
os << integralMap[i].first << " " << integralMap[i].second << endl;
|
|
}
|
|
}
|