Browse Source

continued Operations3D revision

Sven Sickert 9 years ago
parent
commit
9013992a01
3 changed files with 7 additions and 193 deletions
  1. 2 13
      semseg/SemSegContextTree3D.cpp
  2. 5 5
      semseg/operations/Operations3D.cpp
  3. 0 175
      semseg/operations/Operations3D.h

+ 2 - 13
semseg/SemSegContextTree3D.cpp

@@ -183,7 +183,7 @@ void SemSegContextTree3D::initOperations()
     string featsec = "Features";
 
     // operation prototypes
-    vector<Operation3D*> tops0, tops1, tops2, tops3, tops4, tops5;
+    vector<Operation3D*> tops0, tops1, tops2, tops3, tops4;
 
     if ( conf->gB ( featsec, "int", true ) )
     {
@@ -411,7 +411,6 @@ double SemSegContextTree3D::getBestSplit (
 
     // pointers to all randomly chosen features
     std::vector<Operation3D*> featsel;
-
     for ( int i = 0; i < featsPerSplit; i++ )
     {
         int x1, x2, y1, y2, z1, z2, ft;
@@ -433,18 +432,8 @@ double SemSegContextTree3D::getBestSplit (
         /* random feature maps (channels) */
         int f1, f2;
         f1 = ( int ) ( rand() % channelsPerType[ft].size() );
-        if ( (rand() % 2) == 0 )
-            f2 = ( int ) ( rand() % channelsPerType[ft].size() );
-        else
-            f2 = f1;
         f1 = channelsPerType[ft][f1];
-        f2 = channelsPerType[ft][f2];
-
-        if ( ft == 1 )
-        {
-            int classes = ( int ) regionProbs[0][0].size();
-            f2 = ( int ) ( rand() % classes );
-        }
+        f2 = ( int ) ( rand() % classNames->numClasses() );
 
         /* random extraction method (operation) */
         int o = ( int ) ( rand() % ops[ft].size() );

+ 5 - 5
semseg/operations/Operations3D.cpp

@@ -111,7 +111,7 @@ void Operation3D::store ( std::ostream & os )
         os << -1 << std::endl;
     else
     {
-        if (featType == 3 || featType == 4)
+        if (context)
             os << CONTEXT << std::endl;
         else
             os << RAWFEAT << std::endl;
@@ -168,7 +168,7 @@ std::string Operation3D::writeInfos()
 double RegionFeat3D::getVal ( const Features &feats, const int &x, const int &y, const int &z )
 {
     int currentRegion = (*feats.feats)(x,y,z,channel1);
-    int chosenClass = channel2;
+    unsigned short chosenClass = channel2;
     return (*feats.rProbs)[currentRegion][chosenClass];
 }
 
@@ -184,7 +184,7 @@ double Minus3D::getVal ( const Features &feats, const int &x, const int &y, cons
     getXYZ ( feats, xsize, ysize, zsize );
 
     double v1 = intToRaw(feats, BOUND ( x + x1, 0, xsize - 1 ), BOUND ( y + y1, 0, ysize - 1 ), BOUND ( z + z1, 0, zsize - 1 ), channel1);
-    double v2 = intToRaw(feats, BOUND ( x + x2, 0, xsize - 1 ), BOUND ( y + y2, 0, ysize - 1 ), BOUND ( z + z2, 0, zsize - 1 ), channel2);
+    double v2 = intToRaw(feats, BOUND ( x + x2, 0, xsize - 1 ), BOUND ( y + y2, 0, ysize - 1 ), BOUND ( z + z2, 0, zsize - 1 ), channel1);
 
     return v1-v2;
 }
@@ -195,7 +195,7 @@ double MinusAbs3D::getVal ( const Features &feats, const int &x, const int &y, c
     getXYZ ( feats, xsize, ysize, zsize );
 
     double v1 = intToRaw(feats, BOUND ( x + x1, 0, xsize - 1 ), BOUND ( y + y1, 0, ysize - 1 ), BOUND ( z + z1, 0, zsize - 1 ), channel1);
-    double v2 = intToRaw(feats, BOUND ( x + x2, 0, xsize - 1 ), BOUND ( y + y2, 0, ysize - 1 ), BOUND ( z + z2, 0, zsize - 1 ), channel2);
+    double v2 = intToRaw(feats, BOUND ( x + x2, 0, xsize - 1 ), BOUND ( y + y2, 0, ysize - 1 ), BOUND ( z + z2, 0, zsize - 1 ), channel1);
 
     return abs(v1-v2);
 }
@@ -206,7 +206,7 @@ double Addition3D::getVal ( const Features &feats, const int &x, const int &y, c
     getXYZ ( feats, xsize, ysize, zsize );
 
     double v1 = intToRaw(feats, BOUND ( x + x1, 0, xsize - 1 ), BOUND ( y + y1, 0, ysize - 1 ), BOUND ( z + z1, 0, zsize - 1 ), channel1);
-    double v2 = intToRaw(feats, BOUND ( x + x2, 0, xsize - 1 ), BOUND ( y + y2, 0, ysize - 1 ), BOUND ( z + z2, 0, zsize - 1 ), channel2);
+    double v2 = intToRaw(feats, BOUND ( x + x2, 0, xsize - 1 ), BOUND ( y + y2, 0, ysize - 1 ), BOUND ( z + z2, 0, zsize - 1 ), channel1);
 
     return v1+v2;
 }

+ 0 - 175
semseg/operations/Operations3D.h

@@ -1492,179 +1492,4 @@ public:
     }
 };
 
-/**
- * @brief Ray features
- */
-/**
- * @brief Ray Distance-Difference features
- */
-class RayDiff3D: public Operation3D
-{
-public:
-    /**
-     * @brief interface for feature computation
-     * @param feats features
-     * @param x current x position
-     * @param y current y position
-     * @param z current z position
-     * @return double distance
-     **/
-    virtual double getVal ( const Features &feats, const int &x, const int &y, const int &z );
-
-    /**
-     * @brief clone operation instead of copy constructor (copy constructor does not work)
-     **/
-    virtual Operation3D* clone()
-    {
-        return new RayDiff3D();
-    }
-
-    /**
-     * @brief print some infos about operation extraction type
-     * @return string feature type
-     **/
-    virtual std::string writeInfos()
-    {
-        return "(-)RayDiff              " + Operation3D::writeInfos();
-    }
-
-    /**
-     * @brief return operation type (for store and restore)
-     * @return OperationTypes
-     **/
-    virtual OperationTypes getOps()
-    {
-        return RAYDIFF;
-    }
-};
-
-/**
- * @brief Ray Distance features
- */
-class RayDist3D: public Operation3D
-{
-public:
-    /**
-     * @brief interface for feature computation
-     * @param feats features
-     * @param x current x position
-     * @param y current y position
-     * @param z current z position
-     * @return double distance
-     **/
-    virtual double getVal ( const Features &feats, const int &x, const int &y, const int &z );
-
-    /**
-     * @brief clone operation instead of copy constructor (copy constructor does not work)
-     **/
-    virtual Operation3D* clone()
-    {
-        return new RayDist3D();
-    }
-
-    /**
-     * @brief print some infos about operation extraction type
-     * @return string feature type
-     **/
-    virtual std::string writeInfos()
-    {
-        return "(-)RayDist              " + Operation3D::writeInfos();
-    }
-
-    /**
-     * @brief return operation type (for store and restore)
-     * @return OperationTypes
-     **/
-    virtual OperationTypes getOps()
-    {
-        return RAYDIST;
-    }
-};
-
-/**
- * @brief Ray Orientation features
- */
-class RayOrient3D: public Operation3D
-{
-public:
-    /**
-     * @brief interface for feature computation
-     * @param feats features
-     * @param x current x position
-     * @param y current y position
-     * @param z current z position
-     * @return double distance
-     **/
-    virtual double getVal ( const Features &feats, const int &x, const int &y, const int &z );
-
-    /**
-     * @brief clone operation instead of copy constructor (copy constructor does not work)
-     **/
-    virtual Operation3D* clone()
-    {
-        return new RayOrient3D();
-    }
-
-    /**
-     * @brief print some infos about operation extraction type
-     * @return string feature type
-     **/
-    virtual std::string writeInfos()
-    {
-        return "(-)RayOrient            " + Operation3D::writeInfos();
-    }
-
-    /**
-     * @brief return operation type (for store and restore)
-     * @return OperationTypes
-     **/
-    virtual OperationTypes getOps()
-    {
-        return RAYORIENT;
-    }
-};
-
-/**
- * @brief Ray Norm features
- */
-class RayNorm3D: public Operation3D
-{
-public:
-    /**
-     * @brief interface for feature computation
-     * @param feats features
-     * @param x current x position
-     * @param y current y position
-     * @param z current z position
-     * @return double distance
-     **/
-    virtual double getVal ( const Features &feats, const int &x, const int &y, const int &z );
-
-    /**
-     * @brief clone operation instead of copy constructor (copy constructor does not work)
-     **/
-    virtual Operation3D* clone()
-    {
-        return new RayNorm3D();
-    }
-
-    /**
-     * @brief print some infos about operation extraction type
-     * @return string feature type
-     **/
-    virtual std::string writeInfos()
-    {
-        return "(-)RayNorm              " + Operation3D::writeInfos();
-    }
-
-    /**
-     * @brief return operation type (for store and restore)
-     * @return OperationTypes
-     **/
-    virtual OperationTypes getOps()
-    {
-        return RAYNORM;
-    }
-};
-
 } //end namespace