diff --git a/Mesh_3/include/CGAL/Mesh_3/generate_weights_from_labeled_image.h b/Mesh_3/include/CGAL/Mesh_3/generate_weights_from_labeled_image.h index 563bc8d902c..65b8ed9daf1 100644 --- a/Mesh_3/include/CGAL/Mesh_3/generate_weights_from_labeled_image.h +++ b/Mesh_3/include/CGAL/Mesh_3/generate_weights_from_labeled_image.h @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -85,6 +86,7 @@ void generate_weights(const CGAL::Image_3& image, boost::container::flat_set labels; internal::convert_image_3_to_itk(image, *itk_img, labels); + using DuplicatorType = itk::ImageDuplicator; using IndicatorFilter = itk::ThresholdImageFilter; using RescaleFilterType = itk::RescaleIntensityImageFilter; using GaussianFilterType = itk::SmoothingRecursiveGaussianImageFilter; @@ -93,9 +95,13 @@ void generate_weights(const CGAL::Image_3& image, for (Image_word_type label : labels) { + DuplicatorType::Pointer duplicator = DuplicatorType::New(); + duplicator->SetInputImage(itk_img); + duplicator->Update(); + //compute "indicator image" for "label" IndicatorFilter::Pointer indicator = IndicatorFilter::New(); - indicator->SetInput(itk_img); + indicator->SetInput(duplicator->GetOutput()); indicator->SetOutsideValue(0); indicator->ThresholdOutside(label, label); indicator->Update();