Эх сурвалжийг харах

output of probability maps optional in config file

Sven Sickert 10 жил өмнө
parent
commit
c6e527c587

+ 19 - 15
progs/testSemanticSegmentation3D.cpp

@@ -122,6 +122,7 @@ void startClassification (SemanticSegmentation *semseg,
 {
   bool show_results = conf.gB ( "debug", "show_results", false );
   bool write_results = conf.gB ( "debug", "write_results", false );
+  bool writeProbMaps = conf.gB ( "debug", "write_prob_maps", false );
   if (doCrossVal)
     write_results = false;
 
@@ -245,26 +246,29 @@ void startClassification (SemanticSegmentation *semseg,
             ov_rgb_gt.write ( out.str() + "_overlay_gt." + output_type );
 
             // write Probability maps
-            NICE::ColorImage prob_map( probabilities.width(), probabilities.height() );
-            prob_map.set(0,0,0);
-            int iNumChannels = probabilities.channels();
-            for ( int idxProbMap = 0; idxProbMap < iNumChannels; idxProbMap++)
+            if (writeProbMaps)
             {
-                for ( int y = 0 ; y < probabilities.height(); y++ )
+                NICE::ColorImage prob_map( probabilities.width(), probabilities.height() );
+                prob_map.set(0,0,0);
+                int iNumChannels = probabilities.channels();
+                for ( int idxProbMap = 0; idxProbMap < iNumChannels; idxProbMap++)
                 {
-                    for ( int x = 0 ; x < probabilities.width(); x++ )
+                    for ( int y = 0 ; y < probabilities.height(); y++ )
                     {
-                        double probVal = probabilities.get( x, y, z, idxProbMap ) * 255.0;
-                        int tmp = round(probVal);
-                        for ( int c = 0 ; c < 3 ; c++ )
-                            prob_map.setPixel( x, y, c, tmp );
+                        for ( int x = 0 ; x < probabilities.width(); x++ )
+                        {
+                            double probVal = probabilities.get( x, y, z, idxProbMap ) * 255.0;
+                            int tmp = round(probVal);
+                            for ( int c = 0 ; c < 3 ; c++ )
+                                prob_map.setPixel( x, y, c, tmp );
+                        }
                     }
+                    std::stringstream ssFileProbMap;
+                    //ssFileProbMap << out.str() << "_probs." << "c" << idxProbMap << "." << output_type;
+                    ssFileProbMap << out.str() << "_probs." << "c-" << classNames.code( idxProbMap ) << "." << output_type;
+                    //classNames
+                    prob_map.write ( ssFileProbMap.str() );
                 }
-                std::stringstream ssFileProbMap;
-                //ssFileProbMap << out.str() << "_probs." << "c" << idxProbMap << "." << output_type;
-                ssFileProbMap << out.str() << "_probs." << "c-" << classNames.code( idxProbMap ) << "." << output_type;
-                //classNames
-                prob_map.write ( ssFileProbMap.str() );
             }
           }
         }