diff --git a/Modules/Segmentation/Conversion/include/otbOGRDataSourceToLabelImageFilter.txx b/Modules/Segmentation/Conversion/include/otbOGRDataSourceToLabelImageFilter.txx
index a704709105277d56f305ccf6baae11bd77df121e..3ae5c733cc842aec695cf843e751992ebb8454dc 100644
--- a/Modules/Segmentation/Conversion/include/otbOGRDataSourceToLabelImageFilter.txx
+++ b/Modules/Segmentation/Conversion/include/otbOGRDataSourceToLabelImageFilter.txx
@@ -241,7 +241,7 @@ OGRDataSourceToLabelImageFilter<TOutputImage>::GenerateData()
      {
      std::vector<std::string> options;
 
-     std::vector<double> foreground(nbBands,m_ForegroundValue);
+     std::vector<double> foreground(nbBands*m_SrcDataSetLayers.size(),m_ForegroundValue);
 
      if(m_BurnAttributeMode)
        {