|
@@ -66,6 +66,29 @@ class ClassificationResultAcess: public ValueAccess
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+class SparseImageAcess: public ValueAccess
|
|
|
|
+{
|
|
|
|
+ private:
|
|
|
|
+ double scale;
|
|
|
|
+
|
|
|
|
+ public:
|
|
|
|
+ virtual double getVal ( const Features &feats, const int &x, const int &y, const int &channel )
|
|
|
|
+ {
|
|
|
|
+ //MultiChannelImageT<SparseVector> textonMap;
|
|
|
|
+ //TODO: implement access
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ virtual string writeInfos()
|
|
|
|
+ {
|
|
|
|
+ return "context";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ virtual ValueTypes getType()
|
|
|
|
+ {
|
|
|
|
+ return CONTEXT;
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
void Operation::restore ( std::istream &is )
|
|
void Operation::restore ( std::istream &is )
|
|
{
|
|
{
|
|
is >> x1;
|
|
is >> x1;
|
|
@@ -106,6 +129,57 @@ std::string Operation::writeInfos()
|
|
return ss.str();
|
|
return ss.str();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void Operation::set ( int ws, int c1size, int c2size, int c3size, bool useGaussian )
|
|
|
|
+{
|
|
|
|
+ int types = 1;
|
|
|
|
+ if ( c2size > 0 )
|
|
|
|
+ {
|
|
|
|
+ types++;
|
|
|
|
+ }
|
|
|
|
+ if ( c3size > 0 )
|
|
|
|
+ {
|
|
|
|
+ types++;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ types = std::min(types, maxtypes);
|
|
|
|
+
|
|
|
|
+ int ft = ( int ) ( ( double ) rand() / ( double ) RAND_MAX * ( double ) types );
|
|
|
|
+
|
|
|
|
+ if ( ft > 0 )
|
|
|
|
+ {
|
|
|
|
+ ws *= 4;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ( useGaussian )
|
|
|
|
+ {
|
|
|
|
+ double sigma = ( double ) ws * 2.0;
|
|
|
|
+ x1 = randGaussDouble ( sigma ) * ( double ) ws;
|
|
|
|
+ x2 = randGaussDouble ( sigma ) * ( double ) ws;
|
|
|
|
+ y1 = randGaussDouble ( sigma ) * ( double ) ws;
|
|
|
|
+ y2 = randGaussDouble ( sigma ) * ( double ) ws;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ x1 = ( int ) ( ( double ) rand() / ( double ) RAND_MAX * ( double ) ws ) - ws / 2;
|
|
|
|
+ x2 = ( int ) ( ( double ) rand() / ( double ) RAND_MAX * ( double ) ws ) - ws / 2;
|
|
|
|
+ y1 = ( int ) ( ( double ) rand() / ( double ) RAND_MAX * ( double ) ws ) - ws / 2;
|
|
|
|
+ y2 = ( int ) ( ( double ) rand() / ( double ) RAND_MAX * ( double ) ws ) - ws / 2;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ( ft == RAWFEAT )
|
|
|
|
+ {
|
|
|
|
+ values = new MCImageAccess();
|
|
|
|
+ }
|
|
|
|
+ else if ( ft == CONTEXT )
|
|
|
|
+ {
|
|
|
|
+ values = new ClassificationResultAcess();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ values = new SparseImageAcess();
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
class Minus: public Operation
|
|
class Minus: public Operation
|
|
{
|
|
{
|
|
public:
|
|
public:
|
|
@@ -130,7 +204,7 @@ class Minus: public Operation
|
|
if ( values != NULL )
|
|
if ( values != NULL )
|
|
out += values->writeInfos();
|
|
out += values->writeInfos();
|
|
|
|
|
|
- return out+Operation::writeInfos();
|
|
|
|
|
|
+ return out + Operation::writeInfos();
|
|
}
|
|
}
|
|
|
|
|
|
virtual OperationTypes getOps()
|
|
virtual OperationTypes getOps()
|
|
@@ -139,6 +213,8 @@ class Minus: public Operation
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
class MinusAbs: public Operation
|
|
class MinusAbs: public Operation
|
|
{
|
|
{
|
|
|
|
|
|
@@ -199,7 +275,7 @@ class Addition: public Operation
|
|
if ( values != NULL )
|
|
if ( values != NULL )
|
|
out += values->writeInfos();
|
|
out += values->writeInfos();
|
|
|
|
|
|
- return out+Operation::writeInfos();
|
|
|
|
|
|
+ return out + Operation::writeInfos();
|
|
}
|
|
}
|
|
|
|
|
|
virtual OperationTypes getOps()
|
|
virtual OperationTypes getOps()
|
|
@@ -232,7 +308,7 @@ class Only1: public Operation
|
|
if ( values != NULL )
|
|
if ( values != NULL )
|
|
out += values->writeInfos();
|
|
out += values->writeInfos();
|
|
|
|
|
|
- return out+Operation::writeInfos();
|
|
|
|
|
|
+ return out + Operation::writeInfos();
|
|
}
|
|
}
|
|
|
|
|
|
virtual OperationTypes getOps()
|
|
virtual OperationTypes getOps()
|
|
@@ -259,7 +335,7 @@ class RelativeXPosition: public Operation
|
|
|
|
|
|
virtual string writeInfos()
|
|
virtual string writeInfos()
|
|
{
|
|
{
|
|
- return "RelativeXPosition"+Operation::writeInfos();
|
|
|
|
|
|
+ return "RelativeXPosition" + Operation::writeInfos();
|
|
}
|
|
}
|
|
|
|
|
|
virtual OperationTypes getOps()
|
|
virtual OperationTypes getOps()
|
|
@@ -286,7 +362,7 @@ class RelativeYPosition: public Operation
|
|
|
|
|
|
virtual string writeInfos()
|
|
virtual string writeInfos()
|
|
{
|
|
{
|
|
- return "RelativeYPosition"+Operation::writeInfos();
|
|
|
|
|
|
+ return "RelativeYPosition" + Operation::writeInfos();
|
|
}
|
|
}
|
|
|
|
|
|
virtual OperationTypes getOps()
|
|
virtual OperationTypes getOps()
|
|
@@ -340,7 +416,7 @@ class IntegralOps: public Operation
|
|
|
|
|
|
virtual string writeInfos()
|
|
virtual string writeInfos()
|
|
{
|
|
{
|
|
- return "IntegralOps"+Operation::writeInfos();
|
|
|
|
|
|
+ return "IntegralOps" + Operation::writeInfos();
|
|
}
|
|
}
|
|
|
|
|
|
virtual OperationTypes getOps()
|
|
virtual OperationTypes getOps()
|
|
@@ -369,7 +445,7 @@ class GlobalFeats: public IntegralOps
|
|
|
|
|
|
virtual string writeInfos()
|
|
virtual string writeInfos()
|
|
{
|
|
{
|
|
- return "GlobalFeats"+Operation::writeInfos();
|
|
|
|
|
|
+ return "GlobalFeats" + Operation::writeInfos();
|
|
}
|
|
}
|
|
|
|
|
|
virtual OperationTypes getOps()
|
|
virtual OperationTypes getOps()
|
|
@@ -409,7 +485,7 @@ class IntegralCenteredOps: public IntegralOps
|
|
|
|
|
|
virtual string writeInfos()
|
|
virtual string writeInfos()
|
|
{
|
|
{
|
|
- return "IntegralCenteredOps"+Operation::writeInfos();
|
|
|
|
|
|
+ return "IntegralCenteredOps" + Operation::writeInfos();
|
|
}
|
|
}
|
|
|
|
|
|
virtual OperationTypes getOps()
|
|
virtual OperationTypes getOps()
|
|
@@ -449,7 +525,7 @@ class BiIntegralCenteredOps: public IntegralCenteredOps
|
|
|
|
|
|
virtual string writeInfos()
|
|
virtual string writeInfos()
|
|
{
|
|
{
|
|
- return "BiIntegralCenteredOps"+Operation::writeInfos();
|
|
|
|
|
|
+ return "BiIntegralCenteredOps" + Operation::writeInfos();
|
|
}
|
|
}
|
|
|
|
|
|
virtual OperationTypes getOps()
|
|
virtual OperationTypes getOps()
|
|
@@ -485,7 +561,7 @@ class HaarHorizontal: public IntegralCenteredOps
|
|
|
|
|
|
virtual string writeInfos()
|
|
virtual string writeInfos()
|
|
{
|
|
{
|
|
- return "HaarHorizontal"+Operation::writeInfos();
|
|
|
|
|
|
+ return "HaarHorizontal" + Operation::writeInfos();
|
|
}
|
|
}
|
|
|
|
|
|
virtual OperationTypes getOps()
|
|
virtual OperationTypes getOps()
|
|
@@ -521,7 +597,7 @@ class HaarVertical: public IntegralCenteredOps
|
|
|
|
|
|
virtual string writeInfos()
|
|
virtual string writeInfos()
|
|
{
|
|
{
|
|
- return "HaarVertical"+Operation::writeInfos();
|
|
|
|
|
|
+ return "HaarVertical" + Operation::writeInfos();
|
|
}
|
|
}
|
|
|
|
|
|
virtual OperationTypes getOps()
|
|
virtual OperationTypes getOps()
|
|
@@ -557,7 +633,7 @@ class HaarDiag: public IntegralCenteredOps
|
|
|
|
|
|
virtual string writeInfos()
|
|
virtual string writeInfos()
|
|
{
|
|
{
|
|
- return "HaarDiag"+Operation::writeInfos();
|
|
|
|
|
|
+ return "HaarDiag" + Operation::writeInfos();
|
|
}
|
|
}
|
|
|
|
|
|
virtual OperationTypes getOps()
|
|
virtual OperationTypes getOps()
|
|
@@ -596,7 +672,7 @@ class Haar3Horiz: public BiIntegralCenteredOps
|
|
|
|
|
|
virtual string writeInfos()
|
|
virtual string writeInfos()
|
|
{
|
|
{
|
|
- return "Haar3Horiz"+Operation::writeInfos();
|
|
|
|
|
|
+ return "Haar3Horiz" + Operation::writeInfos();
|
|
}
|
|
}
|
|
|
|
|
|
virtual OperationTypes getOps()
|
|
virtual OperationTypes getOps()
|
|
@@ -635,7 +711,7 @@ class Haar3Vert: public BiIntegralCenteredOps
|
|
|
|
|
|
virtual string writeInfos()
|
|
virtual string writeInfos()
|
|
{
|
|
{
|
|
- return "Haar3Vert"+Operation::writeInfos();
|
|
|
|
|
|
+ return "Haar3Vert" + Operation::writeInfos();
|
|
}
|
|
}
|
|
|
|
|
|
virtual OperationTypes getOps()
|
|
virtual OperationTypes getOps()
|
|
@@ -819,10 +895,10 @@ double SemSegContextTree::getBestSplit ( std::vector<NICE::MultiChannelImageT<do
|
|
{
|
|
{
|
|
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;
|
|
-
|
|
|
|
|
|
+
|
|
if ( randD < fraction[labelmap[cn]] )
|
|
if ( randD < fraction[labelmap[cn]] )
|
|
{
|
|
{
|
|
vector<int> tmp ( 3, 0 );
|
|
vector<int> tmp ( 3, 0 );
|
|
@@ -880,7 +956,7 @@ double SemSegContextTree::getBestSplit ( std::vector<NICE::MultiChannelImageT<do
|
|
|
|
|
|
if ( useGaussian )
|
|
if ( useGaussian )
|
|
{
|
|
{
|
|
- double sigma = ( double ) tmpws / 2.0;
|
|
|
|
|
|
+ double sigma = ( double ) tmpws * 2.0;
|
|
x1 = randGaussDouble ( sigma ) * ( double ) tmpws;
|
|
x1 = randGaussDouble ( sigma ) * ( double ) tmpws;
|
|
x2 = randGaussDouble ( sigma ) * ( double ) tmpws;
|
|
x2 = randGaussDouble ( sigma ) * ( double ) tmpws;
|
|
y1 = randGaussDouble ( sigma ) * ( double ) tmpws;
|
|
y1 = randGaussDouble ( sigma ) * ( double ) tmpws;
|
|
@@ -1343,8 +1419,8 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
{
|
|
{
|
|
featcounter++;
|
|
featcounter++;
|
|
int cn = labels[iCounter] ( x, y );
|
|
int cn = labels[iCounter] ( x, y );
|
|
- if(labelmap.find(cn) == labelmap.end())
|
|
|
|
- continue;
|
|
|
|
|
|
+ if ( labelmap.find ( cn ) == labelmap.end() )
|
|
|
|
+ continue;
|
|
a[labelmap[cn]] ++;
|
|
a[labelmap[cn]] ++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1495,7 +1571,7 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
if ( val < splitval )
|
|
if ( val < splitval )
|
|
{
|
|
{
|
|
currentfeats[iCounter].set ( x, y, left, tree );
|
|
currentfeats[iCounter].set ( x, y, left, tree );
|
|
- if(labelmap.find(labels[iCounter] ( x, y )) != labelmap.end())
|
|
|
|
|
|
+ if ( labelmap.find ( labels[iCounter] ( x, y ) ) != labelmap.end() )
|
|
forest[tree][left].dist[labelmap[labels[iCounter] ( x, y ) ]]++;
|
|
forest[tree][left].dist[labelmap[labels[iCounter] ( x, y ) ]]++;
|
|
forest[tree][left].featcounter++;
|
|
forest[tree][left].featcounter++;
|
|
SparseVector v;
|
|
SparseVector v;
|
|
@@ -1505,7 +1581,7 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
else
|
|
else
|
|
{
|
|
{
|
|
currentfeats[iCounter].set ( x, y, right, tree );
|
|
currentfeats[iCounter].set ( x, y, right, tree );
|
|
- if(labelmap.find(labels[iCounter] ( x, y )) != labelmap.end())
|
|
|
|
|
|
+ if ( labelmap.find ( labels[iCounter] ( x, y ) ) != labelmap.end() )
|
|
forest[tree][right].dist[labelmap[labels[iCounter] ( x, y ) ]]++;
|
|
forest[tree][right].dist[labelmap[labels[iCounter] ( x, y ) ]]++;
|
|
forest[tree][right].featcounter++;
|
|
forest[tree][right].featcounter++;
|
|
//feld im subsampled finden und in diesem rechts hochzählen
|
|
//feld im subsampled finden und in diesem rechts hochzählen
|
|
@@ -1699,7 +1775,7 @@ void SemSegContextTree::semanticseg ( CachedExample *ce, NICE::Image & segresult
|
|
int xpos = 8;
|
|
int xpos = 8;
|
|
//int xpos = 15;
|
|
//int xpos = 15;
|
|
int ypos = 78;
|
|
int ypos = 78;
|
|
-
|
|
|
|
|
|
+
|
|
int xsize;
|
|
int xsize;
|
|
int ysize;
|
|
int ysize;
|
|
ce->getImageSize ( xsize, ysize );
|
|
ce->getImageSize ( xsize, ysize );
|
|
@@ -1802,11 +1878,11 @@ void SemSegContextTree::semanticseg ( CachedExample *ce, NICE::Image & segresult
|
|
v.insert ( pair<int, double> ( forest[tree][forest[tree][t].right].nodeNumber, 1.0 ) );
|
|
v.insert ( pair<int, double> ( forest[tree][forest[tree][t].right].nodeNumber, 1.0 ) );
|
|
textonMap ( subx, suby ).add ( v );
|
|
textonMap ( subx, suby ).add ( v );
|
|
}
|
|
}
|
|
-
|
|
|
|
- if(x == xpos && y == ypos)
|
|
|
|
|
|
+
|
|
|
|
+ if ( x == xpos && y == ypos )
|
|
{
|
|
{
|
|
cout << "val: " << val << " decision: " << forest[tree][t].decision << " details: " << forest[tree][t].feat->writeInfos() << endl;
|
|
cout << "val: " << val << " decision: " << forest[tree][t].decision << " details: " << forest[tree][t].feat->writeInfos() << endl;
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1832,7 +1908,7 @@ void SemSegContextTree::semanticseg ( CachedExample *ce, NICE::Image & segresult
|
|
depth++;
|
|
depth++;
|
|
}
|
|
}
|
|
|
|
|
|
-cout << forest[0][currentfeats.get ( xpos, ypos, 0 )].dist << endl;
|
|
|
|
|
|
+ cout << forest[0][currentfeats.get ( xpos, ypos, 0 ) ].dist << endl;
|
|
|
|
|
|
if ( pixelWiseLabeling )
|
|
if ( pixelWiseLabeling )
|
|
{
|
|
{
|
|
@@ -2026,10 +2102,10 @@ void SemSegContextTree::restore ( std::istream & is, int format )
|
|
is >> forest[t][n].isleaf;
|
|
is >> forest[t][n].isleaf;
|
|
is >> forest[t][n].depth;
|
|
is >> forest[t][n].depth;
|
|
is >> forest[t][n].featcounter;
|
|
is >> forest[t][n].featcounter;
|
|
-
|
|
|
|
|
|
+
|
|
is >> forest[t][n].nodeNumber;
|
|
is >> forest[t][n].nodeNumber;
|
|
is >> forest[t][n].dist;
|
|
is >> forest[t][n].dist;
|
|
-
|
|
|
|
|
|
+
|
|
int feattype;
|
|
int feattype;
|
|
is >> feattype;
|
|
is >> feattype;
|
|
assert ( feattype < NBOPERATIONS );
|
|
assert ( feattype < NBOPERATIONS );
|