diff --git a/app/otbPatchesSelection.cxx b/app/otbPatchesSelection.cxx
index 99bb4d2d57f7601615aedd28202ba29a2143351c..3154b8b7ecb312ec2bc4d5e187efbfc7caf47a3e 100644
--- a/app/otbPatchesSelection.cxx
+++ b/app/otbPatchesSelection.cxx
@@ -545,7 +545,6 @@ public:
     otbAppLogINFO("Grid step : " << this->GetParameterInt("grid.step"));
     otbAppLogINFO("Patch size : " << this->GetParameterInt("grid.psize"));
 
-
     // Compute no-data mask
     m_NoDataFilter = IsNoDataFilterType::New();
     m_NoDataFilter->GetFunctor().SetNoDataValue(GetParameterFloat("nodata"));
@@ -556,6 +555,9 @@ public:
     // If mask available, use it
     if (HasValue("mask"))
       {
+      if (GetParameterUInt8Image("mask")->GetLargestPossibleRegion().GetSize() !=
+          GetParameterFloatVectorImage("in")->GetLargestPossibleRegion().GetSize())
+        otbAppLogFATAL("Mask must have the same size as the input image!");
       m_MaskImageFilter = MaskImageFilterType::New();
       m_MaskImageFilter->SetInput(m_NoDataFilter->GetOutput());
       m_MaskImageFilter->SetMaskImage(GetParameterUInt8Image("mask"));