diff --git a/Testing/Code/Markov/otbMRFSamplerRandomMAP.cxx b/Testing/Code/Markov/otbMRFSamplerRandomMAP.cxx
index 95f6dc300528ff61ea71e49f0ec797398d48b705..f2c3cc1b5deb4b5cd78b868f32f182a597697653 100644
--- a/Testing/Code/Markov/otbMRFSamplerRandomMAP.cxx
+++ b/Testing/Code/Markov/otbMRFSamplerRandomMAP.cxx
@@ -51,6 +51,8 @@ int otbMRFSamplerRandomMAP(int argc, char * argv[])
   readerIn->Update();
   readerLab->Update();
 
+  object->SetNumberOfClasses(1);
+
   // USED TO OVERPASS RANDOM CALCULATION
   //object->SetValueInsteadRandom(300);