|
@@ -22,12 +22,12 @@ using namespace NICE;
|
|
class Minus:public Operation
|
|
class Minus:public Operation
|
|
{
|
|
{
|
|
public:
|
|
public:
|
|
- virtual double getVal(const vector<vector<vector<double> > > &feats, const int &x, const int &y)
|
|
|
|
|
|
+ virtual double getVal(const MultiChannelImageT<double> &feats, const int &x, const int &y)
|
|
{
|
|
{
|
|
- int xsize = feats.size();
|
|
|
|
- int ysize = feats[0].size();
|
|
|
|
- double v1 = feats[BOUND(x+x1,0,xsize-1)][BOUND(y+y1,0,ysize-1)][channel1];
|
|
|
|
- double v2 = feats[BOUND(x+x2,0,xsize-1)][BOUND(y+y2,0,ysize-1)][channel2];
|
|
|
|
|
|
+ int xsize = feats.width();
|
|
|
|
+ int ysize = feats.height();
|
|
|
|
+ double v1 = feats.get(BOUND(x+x1,0,xsize-1),BOUND(y+y1,0,ysize-1),channel1);
|
|
|
|
+ double v2 = feats.get(BOUND(x+x2,0,xsize-1),BOUND(y+y2,0,ysize-1),channel2);
|
|
return v1-v2;
|
|
return v1-v2;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -40,12 +40,12 @@ public:
|
|
class MinusAbs:public Operation
|
|
class MinusAbs:public Operation
|
|
{
|
|
{
|
|
public:
|
|
public:
|
|
- virtual double getVal(const vector<vector<vector<double> > > &feats, const int &x, const int &y)
|
|
|
|
|
|
+ virtual double getVal(const MultiChannelImageT<double> &feats, const int &x, const int &y)
|
|
{
|
|
{
|
|
- int xsize = feats.size();
|
|
|
|
- int ysize = feats[0].size();
|
|
|
|
- double v1 = feats[BOUND(x+x1,0,xsize-1)][BOUND(y+y1,0,ysize-1)][channel1];
|
|
|
|
- double v2 = feats[BOUND(x+x2,0,xsize-1)][BOUND(y+y2,0,ysize-1)][channel2];
|
|
|
|
|
|
+ int xsize = feats.width();
|
|
|
|
+ int ysize = feats.height();
|
|
|
|
+ double v1 = feats.get(BOUND(x+x1,0,xsize-1),BOUND(y+y1,0,ysize-1),channel1);
|
|
|
|
+ double v2 = feats.get(BOUND(x+x2,0,xsize-1),BOUND(y+y2,0,ysize-1),channel2);
|
|
return abs(v1-v2);
|
|
return abs(v1-v2);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -58,12 +58,12 @@ public:
|
|
class Addition:public Operation
|
|
class Addition:public Operation
|
|
{
|
|
{
|
|
public:
|
|
public:
|
|
- virtual double getVal(const vector<vector<vector<double> > > &feats, const int &x, const int &y)
|
|
|
|
|
|
+ virtual double getVal(const MultiChannelImageT<double> &feats, const int &x, const int &y)
|
|
{
|
|
{
|
|
- int xsize = feats.size();
|
|
|
|
- int ysize = feats[0].size();
|
|
|
|
- double v1 = feats[BOUND(x+x1,0,xsize-1)][BOUND(y+y1,0,ysize-1)][channel1];
|
|
|
|
- double v2 = feats[BOUND(x+x2,0,xsize-1)][BOUND(y+y2,0,ysize-1)][channel2];
|
|
|
|
|
|
+ int xsize = feats.width();
|
|
|
|
+ int ysize = feats.height();
|
|
|
|
+ double v1 = feats.get(BOUND(x+x1,0,xsize-1),BOUND(y+y1,0,ysize-1),channel1);
|
|
|
|
+ double v2 = feats.get(BOUND(x+x2,0,xsize-1),BOUND(y+y2,0,ysize-1),channel2);
|
|
return v1+v2;
|
|
return v1+v2;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -76,11 +76,11 @@ public:
|
|
class Only1:public Operation
|
|
class Only1:public Operation
|
|
{
|
|
{
|
|
public:
|
|
public:
|
|
- virtual double getVal(const vector<vector<vector<double> > > &feats, const int &x, const int &y)
|
|
|
|
|
|
+ virtual double getVal(const MultiChannelImageT<double> &feats, const int &x, const int &y)
|
|
{
|
|
{
|
|
- int xsize = feats.size();
|
|
|
|
- int ysize = feats[0].size();
|
|
|
|
- double v1 = feats[BOUND(x+x1,0,xsize-1)][BOUND(y+y1,0,ysize-1)][channel1];
|
|
|
|
|
|
+ int xsize = feats.width();
|
|
|
|
+ int ysize = feats.height();
|
|
|
|
+ double v1 = feats.get(BOUND(x+x1,0,xsize-1),BOUND(y+y1,0,ysize-1),channel1);
|
|
return v1;
|
|
return v1;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -130,13 +130,13 @@ SemSegContextTree::~SemSegContextTree()
|
|
{
|
|
{
|
|
}
|
|
}
|
|
|
|
|
|
-void SemSegContextTree::getBestSplit(const vector<vector<vector<vector<double> > > > &feats, vector<vector<vector<int> > > ¤tfeats,const vector<vector<vector<int> > > &labels, int node, Operation *&splitop, double &splitval)
|
|
|
|
|
|
+void SemSegContextTree::getBestSplit(const vector<MultiChannelImageT<double> > &feats, vector<vector<vector<int> > > ¤tfeats,const vector<vector<vector<int> > > &labels, int node, Operation *&splitop, double &splitval)
|
|
{
|
|
{
|
|
int imgCount, featdim;
|
|
int imgCount, featdim;
|
|
try
|
|
try
|
|
{
|
|
{
|
|
imgCount = (int)feats.size();
|
|
imgCount = (int)feats.size();
|
|
- featdim = feats[0][0][0].size();
|
|
|
|
|
|
+ featdim = feats[0].channels();
|
|
}
|
|
}
|
|
catch(Exception)
|
|
catch(Exception)
|
|
{
|
|
{
|
|
@@ -216,7 +216,7 @@ void SemSegContextTree::getBestSplit(const vector<vector<vector<vector<double> >
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- //cout << "size: " << selFeats.size() << endl;
|
|
|
|
|
|
+ cout << "size: " << selFeats.size() << endl;
|
|
//getchar();
|
|
//getchar();
|
|
|
|
|
|
map<int,int>::iterator mapit;
|
|
map<int,int>::iterator mapit;
|
|
@@ -251,8 +251,6 @@ void SemSegContextTree::getBestSplit(const vector<vector<vector<vector<double> >
|
|
featsel.push_back(op);
|
|
featsel.push_back(op);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
#pragma omp parallel for private(mapit)
|
|
#pragma omp parallel for private(mapit)
|
|
for(int f = 0; f < featsPerSplit; f++)
|
|
for(int f = 0; f < featsPerSplit; f++)
|
|
{
|
|
{
|
|
@@ -359,11 +357,9 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
pb.show();
|
|
pb.show();
|
|
|
|
|
|
//TODO: Speichefresser!, lohnt sich sparse?
|
|
//TODO: Speichefresser!, lohnt sich sparse?
|
|
- vector<vector<vector<vector<double> > > > allfeats;
|
|
|
|
|
|
+ vector<MultiChannelImageT<double> > allfeats;
|
|
vector<vector<vector<int> > > currentfeats;
|
|
vector<vector<vector<int> > > currentfeats;
|
|
vector<vector<vector<int> > > labels;
|
|
vector<vector<vector<int> > > labels;
|
|
-
|
|
|
|
- forbidden_classes;
|
|
|
|
|
|
|
|
std::string forbidden_classes_s = conf->gS ( "analysis", "donttrain", "" );
|
|
std::string forbidden_classes_s = conf->gS ( "analysis", "donttrain", "" );
|
|
if ( forbidden_classes_s == "" )
|
|
if ( forbidden_classes_s == "" )
|
|
@@ -412,24 +408,25 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
Globals::setCurrentImgFN ( currentFile );
|
|
Globals::setCurrentImgFN ( currentFile );
|
|
|
|
|
|
//TODO: resize image?!
|
|
//TODO: resize image?!
|
|
-
|
|
|
|
- vector<vector<vector<double> > > feats;
|
|
|
|
|
|
+ MultiChannelImageT<double> feats;
|
|
|
|
+ allfeats.push_back(feats);
|
|
#if 0
|
|
#if 0
|
|
lfcw->getFeats(img, feats);
|
|
lfcw->getFeats(img, feats);
|
|
#else
|
|
#else
|
|
- feats = vector<vector<vector<double> > >(xsize,vector<vector<double> >(ysize,vector<double>(3,0.0)));
|
|
|
|
|
|
+ allfeats[imgcounter].reInit(xsize, ysize, 3, true);
|
|
for(int x = 0; x < xsize; x++)
|
|
for(int x = 0; x < xsize; x++)
|
|
{
|
|
{
|
|
for(int y = 0; y < ysize; y++)
|
|
for(int y = 0; y < ysize; y++)
|
|
{
|
|
{
|
|
for(int r = 0; r < 3; r++)
|
|
for(int r = 0; r < 3; r++)
|
|
{
|
|
{
|
|
- feats[x][y][r] = img.getPixel(x,y,r);
|
|
|
|
|
|
+ allfeats[imgcounter].set(x,y,img.getPixel(x,y,r),r);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-#endif
|
|
|
|
- allfeats.push_back(feats);
|
|
|
|
|
|
+#endif
|
|
|
|
+cout << 5 << endl;
|
|
|
|
+
|
|
|
|
|
|
// getting groundtruth
|
|
// getting groundtruth
|
|
NICE::Image pixelLabels (xsize, ysize);
|
|
NICE::Image pixelLabels (xsize, ysize);
|
|
@@ -644,22 +641,21 @@ void SemSegContextTree::semanticseg ( CachedExample *ce, NICE::Image & segresult
|
|
|
|
|
|
//TODO: resize image?!
|
|
//TODO: resize image?!
|
|
|
|
|
|
- vector<vector<vector<double> > > feats;
|
|
|
|
-
|
|
|
|
|
|
+ MultiChannelImageT<double> feats;
|
|
#if 0
|
|
#if 0
|
|
- lfcw->getFeats(img, feats);
|
|
|
|
|
|
+ lfcw->getFeats(img, feats);
|
|
#else
|
|
#else
|
|
- feats = vector<vector<vector<double> > >(xsize,vector<vector<double> >(ysize,vector<double>(3,0.0)));
|
|
|
|
- for(int x = 0; x < xsize; x++)
|
|
|
|
- {
|
|
|
|
- for(int y = 0; y < ysize; y++)
|
|
|
|
|
|
+ feats.reInit (xsize, ysize, 3, true);
|
|
|
|
+ for(int x = 0; x < xsize; x++)
|
|
{
|
|
{
|
|
- for(int r = 0; r < 3; r++)
|
|
|
|
|
|
+ for(int y = 0; y < ysize; y++)
|
|
{
|
|
{
|
|
- feats[x][y][r] = img.getPixel(x,y,r);
|
|
|
|
|
|
+ for(int r = 0; r < 3; r++)
|
|
|
|
+ {
|
|
|
|
+ feats.set(x,y,img.getPixel(x,y,r),r);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
bool allleaf = false;
|
|
bool allleaf = false;
|