diff --git a/Modules/Applications/AppClassification/app/otbZonalStatistics.cxx b/Modules/Applications/AppClassification/app/otbZonalStatistics.cxx
index d7e614b3f0a3d34c4ae1617f715d2339ffd04ec0..46f28803ef7738000097d429f94f3832a9f817f1 100644
--- a/Modules/Applications/AppClassification/app/otbZonalStatistics.cxx
+++ b/Modules/Applications/AppClassification/app/otbZonalStatistics.cxx
@@ -742,12 +742,18 @@ public:
      // Remove the no-data entry
      RemoveNoDataEntry();
      // Generate output
-     if (GetParameterAsString("out") == "xml") WriteXMLStatsFile();
+     if (GetParameterAsString("out") == "xml")
+       {
+       	if(GetParameterInt("histogram") == 0) WriteXMLStatsFile();
+       	else WriteXMLHistogramFile(); 	  	
+       }
      else     // vector or raster
         {
         if (m_FromLabelImage) GenerateVectorDataFromLabelImage();
-        if (GetParameterAsString("out") == "vector") WriteVectorData(); 
-        else if (GetParameterAsString("out") == "raster") WriteRasterData();
+        if (GetParameterAsString("out") == "vector" && GetParameterInt("histogram") == 0 ) WriteVectorData(); 
+        else if (GetParameterAsString("out") == "vector" && GetParameterInt("histogram") != 0 ) WriteVectorHistogramData();
+        else if (GetParameterAsString("out") == "raster" && GetParameterInt("histogram") == 0) WriteRasterData();
+        else if (GetParameterAsString("out") == "raster" && GetParameterInt("histogram") != 0) WriteRasterHistogramData();
         else otbAppLogFATAL("Unknown output mode");
         }
     }