From ac57432192c56a03d4cceb92c1f154910675e258 Mon Sep 17 00:00:00 2001
From: Guillaume Pasero <guillaume.pasero@c-s.fr>
Date: Thu, 30 Mar 2017 17:06:20 +0200
Subject: [PATCH] BUG: maximum train and validation sizes were not correctly
 handled

---
 .../app/otbTrainImagesClassifier.cxx            | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/Modules/Applications/AppClassification/app/otbTrainImagesClassifier.cxx b/Modules/Applications/AppClassification/app/otbTrainImagesClassifier.cxx
index 52bca6f6a2..9797ec0fad 100644
--- a/Modules/Applications/AppClassification/app/otbTrainImagesClassifier.cxx
+++ b/Modules/Applications/AppClassification/app/otbTrainImagesClassifier.cxx
@@ -336,17 +336,20 @@ void DoExecute() ITK_OVERRIDE
       // only fmt will be used for both training and validation samples
       // So we try to compute the total number of samples given input
       // parameters mt, mv and vtr.
-      if (mt > -1 && mv > -1)
-        {
-        fmt = mt + mv;
-        }
-      if (mt > -1 && mv <= -1 && vtr < 0.99999)
+      if (mt > -1 && vtr < 0.99999)
         {
         fmt = static_cast<long>((double) mt / (1.0 - vtr));
         }
-      if (mt <= -1 && mv > -1 && vtr > 0.00001)
+      if (mv > -1 && vtr > 0.00001)
         {
-        fmt = static_cast<long>((double) mv / vtr);
+        if (fmt > -1 )
+          {
+          fmt = std::min(fmt, static_cast<long>((double) mv / vtr));
+          }
+        else
+          {
+          fmt = static_cast<long>((double) mv / vtr);
+          }
         }
       }
     }
-- 
GitLab