Browse Source

current version :)

Bjoern Froehlich 13 years ago
parent
commit
59114b820c
1 changed files with 62 additions and 9 deletions
  1. 62 9
      semseg/SemSegCsurka.cpp

+ 62 - 9
semseg/SemSegCsurka.cpp

@@ -1071,7 +1071,7 @@ void SemSegCsurka::trainpostprocess ( const MultiDataset *md )
 #ifdef DEBUG_CSURK
 #ifdef DEBUG_CSURK
       Image overlay ( img.width(), img.height() );
       Image overlay ( img.width(), img.height() );
 
 
-      double maxval = 0.0;
+      double maxval = -numeric_limits<double>::max();
 
 
       for ( int y = 0; y < img.height(); y++ )
       for ( int y = 0; y < img.height(); y++ )
       {
       {
@@ -1489,20 +1489,32 @@ void SemSegCsurka::classifyregions ( CachedExample *ce, NICE::Image & segresult,
   {
   {
     clog << "[log] SemSegCsruka::classifyregions: Wahrscheinlichkeitskarten erstellen: classifier != NULL" << endl;
     clog << "[log] SemSegCsruka::classifyregions: Wahrscheinlichkeitskarten erstellen: classifier != NULL" << endl;
 //#pragma omp parallel for
 //#pragma omp parallel for
+    
+    int equalcounter = 0;
+    
+    
     for ( int s = 0; s < scalesize; s++ )
     for ( int s = 0; s < scalesize; s++ )
     {
     {
 //#pragma omp parallel for
 //#pragma omp parallel for
       for ( int i = s; i < ( int ) pce.size(); i += scalesize )
       for ( int i = s; i < ( int ) pce.size(); i += scalesize )
       {
       {
         ClassificationResult r = classifier->classify ( pce[i].second );
         ClassificationResult r = classifier->classify ( pce[i].second );
+        
+        bool equal = true;
+        
+        double prev = r.scores[0];
+        
         for ( int j = 0 ; j < r.scores.size(); j++ )
         for ( int j = 0 ; j < r.scores.size(); j++ )
         {
         {
           if ( useclass[j] == 0 )
           if ( useclass[j] == 0 )
             continue;
             continue;
           fV[j] += r.scores[j];
           fV[j] += r.scores[j];
           preMap.set ( pce[i].second.x, pce[i].second.y, r.scores[j], j + s*klassen );
           preMap.set ( pce[i].second.x, pce[i].second.y, r.scores[j], j + s*klassen );
+          if(r.scores[j] != prev)
+            equal = false;
         }
         }
-        
+        if(equal)
+          equalcounter++;
         if(s == 0 && i == pce.size()/2)
         if(s == 0 && i == pce.size()/2)
         {
         {
           cout << "scores: ";
           cout << "scores: ";
@@ -1517,6 +1529,7 @@ void SemSegCsurka::classifyregions ( CachedExample *ce, NICE::Image & segresult,
         
         
       }
       }
     }
     }
+    cout << equalcounter << " elements are equaly classified" << endl;
   }
   }
   else
   else
   {
   {
@@ -1545,6 +1558,40 @@ void SemSegCsurka::classifyregions ( CachedExample *ce, NICE::Image & segresult,
     scalesVec.push_back ( *iter );
     scalesVec.push_back ( *iter );
   }
   }
 
 
+#undef VISSEMSEG
+#ifdef VISSEMSEG
+  
+  for ( int j = 0 ; j < ( int ) preMap.numChannels; j++ )
+  {
+    cout << "klasse: " << j << endl;//" " << cn.text ( j ) << endl;
+
+    NICE::Matrix tmp ( preMap.ysize, preMap.xsize );
+    double maxval = 0.0;
+    for ( int y = 0; y < preMap.ysize; y++ )
+      for ( int x = 0; x < preMap.xsize; x++ )
+      {
+        double val = preMap.get ( x, y, j );
+        tmp ( y, x ) = val;
+        maxval = std::max ( val, maxval );
+      }
+      
+    NICE::ColorImage imgrgb ( preMap.xsize, preMap.ysize );
+    ICETools::convertToRGB ( tmp, imgrgb );
+
+    cout << "maxval = " << maxval << " for class " << j << endl; //cn.text ( j ) << endl;
+
+    //Show ( ON, imgrgb, cn.text ( j ) );
+    //showImage(imgrgb, "Ergebnis");
+
+    std::string s;
+    std::stringstream out;
+    out << "tmpprebmap" << j << ".ppm";
+    s = out.str();
+    imgrgb.writePPM ( s );
+
+    //getchar();
+  }
+#endif
 
 
   // Gaußfiltern
   // Gaußfiltern
   clog << "[log] SemSegCsruka::classifyregions: Wahrscheinlichkeitskarten erstellen -> Gaussfiltern" << endl;
   clog << "[log] SemSegCsruka::classifyregions: Wahrscheinlichkeitskarten erstellen -> Gaussfiltern" << endl;
@@ -1624,16 +1671,15 @@ void SemSegCsurka::classifyregions ( CachedExample *ce, NICE::Image & segresult,
 
 
   std::string s;
   std::string s;
   std::stringstream out;
   std::stringstream out;
-  std::vector< std::string > list;
-  StringTools::split ( Globals::getCurrentImgFN (), '/', list );
+  std::vector< std::string > list2;
+  StringTools::split ( Globals::getCurrentImgFN (), '/', list2 );
 
 
-  out << "probmaps/" << list.back() << ".probs";
+  out << "probmaps/" << list2.back() << ".probs";
 
 
   s = out.str();
   s = out.str();
 
 
   probabilities.store ( s );
   probabilities.store ( s );
-  s
-
+  
   for ( int j = 0 ; j < ( int ) probabilities.numChannels; j++ )
   for ( int j = 0 ; j < ( int ) probabilities.numChannels; j++ )
   {
   {
     cout << "klasse: " << j << endl;//" " << cn.text ( j ) << endl;
     cout << "klasse: " << j << endl;//" " << cn.text ( j ) << endl;
@@ -1644,9 +1690,11 @@ void SemSegCsurka::classifyregions ( CachedExample *ce, NICE::Image & segresult,
       for ( int x = 0; x < probabilities.xsize; x++ )
       for ( int x = 0; x < probabilities.xsize; x++ )
       {
       {
         double val = probabilities.get ( x, y, j );
         double val = probabilities.get ( x, y, j );
+
         tmp ( y, x ) = val;
         tmp ( y, x ) = val;
         maxval = std::max ( val, maxval );
         maxval = std::max ( val, maxval );
       }
       }
+      
     NICE::ColorImage imgrgb ( probabilities.xsize, probabilities.ysize );
     NICE::ColorImage imgrgb ( probabilities.xsize, probabilities.ysize );
     ICETools::convertToRGB ( tmp, imgrgb );
     ICETools::convertToRGB ( tmp, imgrgb );
 
 
@@ -1734,11 +1782,14 @@ void SemSegCsurka::classifyregions ( CachedExample *ce, NICE::Image & segresult,
         Regionen[i].second.x /= ( int ) Regionen[i].second.weight;
         Regionen[i].second.x /= ( int ) Regionen[i].second.weight;
         Regionen[i].second.y /= ( int ) Regionen[i].second.weight;
         Regionen[i].second.y /= ( int ) Regionen[i].second.weight;
       }
       }
-      double maxval = 0.0;
+      double maxval = -numeric_limits<double>::max();
       int maxpos = 0;
       int maxpos = 0;
 
 
       for ( int j = 0 ; j < ( int ) regionprob[i].size(); j++ )
       for ( int j = 0 ; j < ( int ) regionprob[i].size(); j++ )
       {
       {
+        if ( forbidden_classes.find ( j ) != forbidden_classes.end() )
+          continue;
+        
         regionprob[i][j] /= Regionen[i].second.weight;
         regionprob[i][j] /= Regionen[i].second.weight;
 
 
         if ( maxval < regionprob[i][j] )
         if ( maxval < regionprob[i][j] )
@@ -1845,7 +1896,7 @@ void SemSegCsurka::semanticseg ( CachedExample *ce,
     cout << "klasse: " << j << " " << cn.text ( j ) << endl;
     cout << "klasse: " << j << " " << cn.text ( j ) << endl;
 
 
     NICE::Matrix tmp ( probabilities.ysize, probabilities.xsize );
     NICE::Matrix tmp ( probabilities.ysize, probabilities.xsize );
-    double maxval = 0.0;
+    double maxval = -numeric_limits<double>::max();
     for ( int y = 0; y < probabilities.ysize; y++ )
     for ( int y = 0; y < probabilities.ysize; y++ )
       for ( int x = 0; x < probabilities.xsize; x++ )
       for ( int x = 0; x < probabilities.xsize; x++ )
       {
       {
@@ -1868,3 +1919,5 @@ void SemSegCsurka::semanticseg ( CachedExample *ce,
 #endif
 #endif
 
 
 }
 }
+
+