Bjoern Froehlich 13 жил өмнө
parent
commit
53620f9239

+ 53 - 0
semseg/SemSegContextTree.cpp

@@ -13,6 +13,7 @@
 
 #include "core/basics/Timer.h"
 #include "core/basics/vectorio.h"
+#include "core/image/FilterT.h"
 
 #include <omp.h>
 #include <iostream>
@@ -677,6 +678,31 @@ void SemSegContextTree::train ( const MultiDataset *md )
     }
 
     allfeats[imgcounter] = ColorSpace::rgbtolab ( allfeats[imgcounter] );
+    
+    allfeats[imgcounter].addChannel(3);
+    
+    ImageT<double> tmp(xsize, ysize);
+    ImageT<double> tmp2(xsize, ysize);
+    
+    for(int c = 0; c < 3; c++)
+    {
+      for(int y = 0; y < ysize; y++)
+      {
+        for(int x = 0; x < xsize; x++)
+        {
+          tmp(x,y) = allfeats[imgcounter](x,y,c);
+        }
+      }
+    
+      NICE::FilterT<double>::sobel(tmp, tmp2);
+      for(int y = 0; y < ysize; y++)
+      {
+        for(int x = 0; x < xsize; x++)
+        {
+          allfeats[imgcounter](x,y,c+3) = tmp2(x,y);
+        }
+      }
+    }
 #endif
 
     // getting groundtruth
@@ -1180,6 +1206,33 @@ void SemSegContextTree::semanticseg ( CachedExample *ce, NICE::Image & segresult
   }
 
   feats = ColorSpace::rgbtolab ( feats );
+  
+  feats.addChannel(3);
+  
+  ImageT<double> tmp(xsize, ysize);
+  ImageT<double> tmp2(xsize, ysize);
+  
+  for(int c = 0; c < 3; c++)
+  {
+    for(int y = 0; y < ysize; y++)
+    {
+      for(int x = 0; x < xsize; x++)
+      {
+        tmp(x,y) = feats(x,y,c);
+      }
+    }
+  
+    NICE::FilterT<double>::sobel(tmp, tmp2);
+    for(int y = 0; y < ysize; y++)
+    {
+      for(int x = 0; x < xsize; x++)
+      {
+        feats(x,y,c+3) = tmp2(x,y);
+      }
+    }
+  }
+  
+  
 #endif
 
   bool allleaf = false;

+ 1 - 1
semseg/SemanticSegmentation.cpp

@@ -52,7 +52,7 @@ void SemanticSegmentation::convertLSetToExamples ( Examples &examples, LabeledSe
 #endif
   for ( map< int, vector<NICE::Vector *> >::iterator iter = lvec.begin(); iter != lvec.end(); ++iter )
   {
-    for ( int j = 0; j < iter->second.size(); j++ )
+    for ( int j = 0; j < (int)iter->second.size(); j++ )
     {
       NICE::Vector *vec = new NICE::Vector ( * ( iter->second[j] ) );
       Example ex ( vec );