Bjoern Froehlich 13 년 전
부모
커밋
fae214d310
2개의 변경된 파일52개의 추가작업 그리고 9개의 파일을 삭제
  1. 45 5
      semseg/SemSegContextTree.cpp
  2. 7 4
      semseg/SemSegCsurka.cpp

+ 45 - 5
semseg/SemSegContextTree.cpp

@@ -9,6 +9,7 @@
 #include "objrec/segmentation/RSMeanShift.h"
 #include "objrec/segmentation/RSGraphBased.h"
 #include "core/basics/numerictools.h"
+#include "vislearning/baselib/ICETools.h"
 
 #include "core/basics/Timer.h"
 #include "core/basics/vectorio.h"
@@ -2070,11 +2071,11 @@ void SemSegContextTree::semanticseg ( CachedExample *ce, NICE::Image & segresult
   if ( pixelWiseLabeling )
   {
     //finales labeln:
-    long int offset = 0;
+    //long int offset = 0;
 
     for ( int x = 0; x < xsize; x++ )
     {
-      for ( int y = 0; y < ysize; y++, offset++ )
+      for ( int y = 0; y < ysize; y++ )
       {
         double maxvalue = - numeric_limits<double>::max(); //TODO: das kann auch nur pro knoten gemacht werden, nicht pro pixel
         int maxindex = 0;
@@ -2085,11 +2086,11 @@ void SemSegContextTree::semanticseg ( CachedExample *ce, NICE::Image & segresult
           int currentclass = labelmapback[i];
           if(useclass[currentclass])
           {
-            probabilities.data[currentclass][offset] = getMeanProb ( x, y, i, currentfeats );
+            probabilities(x,y,currentclass) = getMeanProb ( x, y, i, currentfeats );
 
-            if ( probabilities.data[currentclass][offset] > maxvalue )
+            if ( probabilities(x,y,currentclass) > maxvalue )
             {
-              maxvalue = probabilities.data[currentclass][offset];
+              maxvalue = probabilities(x,y,currentclass);
               maxindex = currentclass;
             }
           }
@@ -2099,6 +2100,45 @@ void SemSegContextTree::semanticseg ( CachedExample *ce, NICE::Image & segresult
           cout << "maxvalue: " << maxvalue << endl;
       }
     }
+#undef VISUALIZE
+#ifdef VISUALIZE
+    for ( int j = 0 ; j < ( int ) probabilities.numChannels; j++ )
+    {
+      //cout << "class: " << j << endl;//" " << cn.text ( j ) << endl;
+
+      NICE::Matrix tmp ( probabilities.height(), probabilities.width() );
+      double maxval = -numeric_limits<double>::max();
+      double minval = numeric_limits<double>::max();
+      
+      
+      for ( int y = 0; y < probabilities.height(); y++ )
+        for ( int x = 0; x < probabilities.width(); x++ )
+        {
+          double val = probabilities( x, y, j );
+          tmp ( y, x ) = val;
+          maxval = std::max ( val, maxval );
+          minval = std::min ( val, minval );
+        }
+      tmp(0,0) = 1.0;
+      tmp(0,1) = 0.0;
+        
+      NICE::ColorImage imgrgb ( probabilities.width(), probabilities.height() );
+      ICETools::convertToRGB ( tmp, imgrgb );
+
+      cout << "maxval = " << maxval << " minval: " << minval << " for class " << j << endl; //cn.text ( j ) << endl;
+      
+      std::string s;
+      std::stringstream out;
+      out << "tmpprebmap" << j << ".ppm";
+      s = out.str();
+      imgrgb.write( s );
+      //showImage(imgrgb, "Ergebnis");
+      //getchar();
+    }
+    cout << "fertsch" << endl;
+    getchar();
+    cout << "weiter gehtsch" << endl;
+#endif
   }
   else
   {

+ 7 - 4
semseg/SemSegCsurka.cpp

@@ -1313,7 +1313,7 @@ void SemSegCsurka::classifyregions ( CachedExample *ce, NICE::Image & segresult,
 
   if ( opSiftImpl == "NICE" )
   {
-    cSIFT = new LFonHSG ( conf, "HSGtrain" );
+    cSIFT = new LFonHSG ( conf, "HSGtest" );
   }
   else if ( opSiftImpl == "VANDESANDE" )
   {
@@ -1491,6 +1491,7 @@ void SemSegCsurka::classifyregions ( CachedExample *ce, NICE::Image & segresult,
     for ( int s = 0; s < scalesize; s++ )
     {
 //#pragma omp parallel for
+cout << "s: " << s << endl;
       for ( int i = s; i < ( int ) pce.size(); i += scalesize )
       {
         ClassificationResult r = classifier->classify ( pce[i].second );
@@ -1503,7 +1504,7 @@ void SemSegCsurka::classifyregions ( CachedExample *ce, NICE::Image & segresult,
           preMap.set ( pce[i].second.x, pce[i].second.y, r.scores[j], j + s*klassen );
         }
 
-        if(s == 0 && i == pce.size()/2)
+        /*if(s == 0 && i == pce.size()/2)
         {
           cout << "scores: ";
           for ( int j = 0 ; j < r.scores.size(); j++ )
@@ -1513,7 +1514,7 @@ void SemSegCsurka::classifyregions ( CachedExample *ce, NICE::Image & segresult,
             cout << r.scores[j] << " ";
           }
           cout << endl;
-        }
+        }*/
         
       }
     }
@@ -1537,6 +1538,7 @@ void SemSegCsurka::classifyregions ( CachedExample *ce, NICE::Image & segresult,
       }
     }
   }
+  cout << 1 << endl;
   vector<double> scalesVec;
   for ( set<double>::const_iterator iter = scales.begin();
         iter != scales.end();
@@ -1544,6 +1546,7 @@ void SemSegCsurka::classifyregions ( CachedExample *ce, NICE::Image & segresult,
   {
     scalesVec.push_back ( *iter );
   }
+  cout << 2 << endl;
 
 #undef VISSEMSEG
 #ifdef VISSEMSEG
@@ -1799,7 +1802,7 @@ void SemSegCsurka::classifyregions ( CachedExample *ce, NICE::Image & segresult,
         segresult.setPixel ( x, y, Regionen[pos].first );
       }
     }
-#define WRITEREGIONS
+#undef WRITEREGIONS
 #ifdef WRITEREGIONS
     RegionGraph rg;
     seg->getGraphRepresentation ( img, mask, rg );