diff --git a/Modules/Segmentation/Watersheds/include/itkIsolatedWatershedImageFilter.h b/Modules/Segmentation/Watersheds/include/itkIsolatedWatershedImageFilter.h
index 0204211400..fa4fa9cf00 100644
--- a/Modules/Segmentation/Watersheds/include/itkIsolatedWatershedImageFilter.h
+++ b/Modules/Segmentation/Watersheds/include/itkIsolatedWatershedImageFilter.h
@@ -37,43 +37,44 @@ namespace itk
  * \ingroup ITKWatersheds
  */
 
-template< typename TInputImage, typename TOutputImage >
-class ITK_TEMPLATE_EXPORT IsolatedWatershedImageFilter:
-  public ImageToImageFilter< TInputImage, TOutputImage >
+template <typename TInputImage, typename TOutputImage>
+class ITK_TEMPLATE_EXPORT IsolatedWatershedImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
 {
 public:
-  /** Standard class typedefs. */
-  typedef IsolatedWatershedImageFilter                    Self;
-  typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass;
-  typedef SmartPointer< Self >                            Pointer;
-  typedef SmartPointer< const Self >                      ConstPointer;
+  ITK_DISALLOW_COPY_AND_ASSIGN(IsolatedWatershedImageFilter);
+
+  /** Standard class type aliases. */
+  using Self = IsolatedWatershedImageFilter;
+  using Superclass = ImageToImageFilter<TInputImage, TOutputImage>;
+  using Pointer = SmartPointer<Self>;
+  using ConstPointer = SmartPointer<const Self>;
 
   /** Method for creation through the object factory. */
   itkNewMacro(Self);
 
   /** Run-time type information (and related methods).  */
-  itkTypeMacro(IsolatedWatershedImageFilter,
-               ImageToImageFilter);
+  itkTypeMacro(IsolatedWatershedImageFilter, ImageToImageFilter);
 
-  typedef TInputImage                           InputImageType;
-  typedef typename InputImageType::Pointer      InputImagePointer;
-  typedef typename InputImageType::ConstPointer InputImageConstPointer;
-  typedef typename InputImageType::RegionType   InputImageRegionType;
-  typedef typename InputImageType::PixelType    InputImagePixelType;
-  typedef typename InputImageType::IndexType    IndexType;
-  typedef typename InputImageType::SizeType     SizeType;
+  using InputImageType = TInputImage;
+  using InputImagePointer = typename InputImageType::Pointer;
+  using InputImageConstPointer = typename InputImageType::ConstPointer;
+  using InputImageRegionType = typename InputImageType::RegionType;
+  using InputImagePixelType = typename InputImageType::PixelType;
+  using IndexType = typename InputImageType::IndexType;
+  using SizeType = typename InputImageType::SizeType;
 
-  typedef TOutputImage                         OutputImageType;
-  typedef typename OutputImageType::Pointer    OutputImagePointer;
-  typedef typename OutputImageType::RegionType OutputImageRegionType;
-  typedef typename OutputImageType::PixelType  OutputImagePixelType;
+  using OutputImageType = TOutputImage;
+  using OutputImagePointer = typename OutputImageType::Pointer;
+  using OutputImageRegionType = typename OutputImageType::RegionType;
+  using OutputImagePixelType = typename OutputImageType::PixelType;
 
-  typedef typename NumericTraits<InputImagePixelType>::RealType      RealPixelType;
-  typedef Image<RealPixelType, TInputImage::ImageDimension>          RealImageType;
+  using RealPixelType = typename NumericTraits<InputImagePixelType>::RealType;
+  using RealImageType = Image<RealPixelType, TInputImage::ImageDimension>;
 
-  typedef WatershedImageFilter< RealImageType >                          WatershedType;
-  typedef GradientMagnitudeImageFilter< InputImageType, RealImageType > GradientMagnitudeType;
-  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
+  using WatershedType = WatershedImageFilter<RealImageType>;
+  using GradientMagnitudeType = GradientMagnitudeImageFilter<InputImageType, RealImageType>;
+  void
+  PrintSelf(std::ostream & os, Indent indent) const override;
 
   /** Set seed point 1. This seed will be isolated from Seed2 (if
    *  possible). All pixels connected to this seed will be replaced
@@ -114,7 +115,7 @@ public:
 
 protected:
   IsolatedWatershedImageFilter();
-  ~IsolatedWatershedImageFilter() ITK_OVERRIDE {}
+  ~IsolatedWatershedImageFilter() override = default;
   IndexType m_Seed1;
   IndexType m_Seed2;
 
@@ -131,21 +132,22 @@ protected:
   double m_UpperValueLimit;
 
   // Override since the filter needs all the data for the algorithm
-  void GenerateInputRequestedRegion() ITK_OVERRIDE;
+  void
+  GenerateInputRequestedRegion() override;
 
   // Override since the filter produces the entire dataset
-  void EnlargeOutputRequestedRegion(DataObject *output) ITK_OVERRIDE;
+  void
+  EnlargeOutputRequestedRegion(DataObject * output) override;
 
-  void VerifyInputInformation() ITK_OVERRIDE;
-  void GenerateData() ITK_OVERRIDE;
-
-private:
-  ITK_DISALLOW_COPY_AND_ASSIGN(IsolatedWatershedImageFilter);
+  void
+  VerifyInputInformation() ITKv5_CONST override;
+  void
+  GenerateData() override;
 };
 } // end namespace itk
 
 #ifndef ITK_MANUAL_INSTANTIATION
-#include "itkIsolatedWatershedImageFilter.hxx"
+#  include "itkIsolatedWatershedImageFilter.hxx"
 #endif
 
 #endif
diff --git a/Modules/Segmentation/Watersheds/include/itkIsolatedWatershedImageFilter.hxx b/Modules/Segmentation/Watersheds/include/itkIsolatedWatershedImageFilter.hxx
index f9c47220a7..ad0c05df48 100644
--- a/Modules/Segmentation/Watersheds/include/itkIsolatedWatershedImageFilter.hxx
+++ b/Modules/Segmentation/Watersheds/include/itkIsolatedWatershedImageFilter.hxx
@@ -25,15 +25,14 @@
 namespace itk
 {
 
-template< typename TInputImage, typename TOutputImage >
-IsolatedWatershedImageFilter< TInputImage, TOutputImage >
-::IsolatedWatershedImageFilter()
+template <typename TInputImage, typename TOutputImage>
+IsolatedWatershedImageFilter<TInputImage, TOutputImage>::IsolatedWatershedImageFilter()
 {
-  m_Threshold = NumericTraits< InputImagePixelType >::ZeroValue();
+  m_Threshold = NumericTraits<InputImagePixelType>::ZeroValue();
   m_Seed1.Fill(0);
   m_Seed2.Fill(0);
-  m_ReplaceValue1 = NumericTraits< OutputImagePixelType >::OneValue();
-  m_ReplaceValue2 = NumericTraits< OutputImagePixelType >::ZeroValue();
+  m_ReplaceValue1 = NumericTraits<OutputImagePixelType>::OneValue();
+  m_ReplaceValue2 = NumericTraits<OutputImagePixelType>::ZeroValue();
   m_IsolatedValue = 0.0;
   m_IsolatedValueTolerance = 0.001;
   m_UpperValueLimit = 1.0;
@@ -41,69 +40,63 @@ IsolatedWatershedImageFilter< TInputImage, TOutputImage >
   m_Watershed = WatershedType::New();
 }
 
-template< typename TInputImage, typename TOutputImage >
+template <typename TInputImage, typename TOutputImage>
 void
-IsolatedWatershedImageFilter< TInputImage, TOutputImage >
-::GenerateInputRequestedRegion()
+IsolatedWatershedImageFilter<TInputImage, TOutputImage>::GenerateInputRequestedRegion()
 {
   Superclass::GenerateInputRequestedRegion();
-  if ( this->GetInput() )
-    {
-    InputImagePointer image =
-      const_cast< TInputImage * >( this->GetInput() );
+  if (this->GetInput())
+  {
+    InputImagePointer image = const_cast<TInputImage *>(this->GetInput());
     image->SetRequestedRegionToLargestPossibleRegion();
-    }
+  }
 }
 
-template< typename TInputImage, typename TOutputImage >
+template <typename TInputImage, typename TOutputImage>
 void
-IsolatedWatershedImageFilter< TInputImage, TOutputImage >
-::EnlargeOutputRequestedRegion(DataObject *output)
+IsolatedWatershedImageFilter<TInputImage, TOutputImage>::EnlargeOutputRequestedRegion(DataObject * output)
 {
   Superclass::EnlargeOutputRequestedRegion(output);
   output->SetRequestedRegionToLargestPossibleRegion();
 }
 
-template< typename TInputImage, typename TOutputImage >
+template <typename TInputImage, typename TOutputImage>
 void
-IsolatedWatershedImageFilter< TInputImage, TOutputImage >
-::VerifyInputInformation()
+IsolatedWatershedImageFilter<TInputImage, TOutputImage>::VerifyInputInformation() ITKv5_CONST
 {
   Superclass::VerifyInputInformation();
 
-  const InputImageType *inputImage = this->GetInput();
+  const InputImageType * inputImage = this->GetInput();
 
   const InputImageRegionType region = inputImage->GetRequestedRegion();
 
   // Check that the seeds are valid after the input has had its output
   // information updated
-  if ( !region.IsInside(m_Seed1) )
-    {
+  if (!region.IsInside(m_Seed1))
+  {
     itkExceptionMacro("Seed1 is not within the input image!");
-    }
-  if ( !region.IsInside(m_Seed2) )
-    {
+  }
+  if (!region.IsInside(m_Seed2))
+  {
     itkExceptionMacro("Seed2 is not within the input image!");
-    }
-
+  }
 }
 
-template< typename TInputImage, typename TOutputImage >
+template <typename TInputImage, typename TOutputImage>
 void
-IsolatedWatershedImageFilter< TInputImage, TOutputImage >
-::GenerateData()
+IsolatedWatershedImageFilter<TInputImage, TOutputImage>::GenerateData()
 {
-  const InputImageType *inputImage = this->GetInput();
-  OutputImageType      *outputImage = this->GetOutput();
-  OutputImageRegionType region = outputImage->GetRequestedRegion();
+  const InputImageType * inputImage = this->GetInput();
+  OutputImageType *      outputImage = this->GetOutput();
+  OutputImageRegionType  region = outputImage->GetRequestedRegion();
 
   // Set up the pipeline
-  m_GradientMagnitude->SetInput (inputImage);
+  m_GradientMagnitude->SetInput(inputImage);
 
   // Set up the Watershed
-  m_Watershed->SetInput( m_GradientMagnitude->GetOutput() );
-  m_Watershed->SetThreshold( m_Threshold );
-  m_Watershed->SetLevel( m_UpperValueLimit );
+  m_Watershed->SetInput(m_GradientMagnitude->GetOutput());
+  m_Watershed->SetThreshold(m_Threshold);
+  m_Watershed->SetLevel(m_UpperValueLimit);
 
   // Allocate the output
   this->AllocateOutputs();
@@ -112,54 +105,51 @@ IsolatedWatershedImageFilter< TInputImage, TOutputImage >
   double upper = m_UpperValueLimit;
   double guess = upper;
 
-  const unsigned int maximumIterationsInBinarySearch =
-    static_cast< unsigned int >(
-      std::log( ( static_cast< float >( upper ) - static_cast< float >( lower ) )
-               / static_cast< float >( m_IsolatedValueTolerance ) )  / std::log(2.0) );
+  const auto maximumIterationsInBinarySearch = static_cast<unsigned int>(
+    std::log((static_cast<float>(upper) - static_cast<float>(lower)) / static_cast<float>(m_IsolatedValueTolerance)) /
+    std::log(2.0));
 
-  const float progressWeight = 1.0f / static_cast< float >( maximumIterationsInBinarySearch + 2 );
+  const float progressWeight = 1.0f / static_cast<float>(maximumIterationsInBinarySearch + 2);
   float       cumulatedProgress = 0.0f;
 
   IterationReporter iterate(this, 0, 1);
 
   // Do a binary search to find an upper waterlevel that separates the
   // two seeds.
-  while ( lower + m_IsolatedValueTolerance < guess )
-    {
+  while (lower + m_IsolatedValueTolerance < guess)
+  {
     ProgressReporter progress(this, 0, region.GetNumberOfPixels(), 100, cumulatedProgress, progressWeight);
     cumulatedProgress += progressWeight;
-    m_Watershed->SetLevel (guess);
-    m_Watershed->Update ();
-    if ( m_Watershed->GetOutput()->GetPixel(m_Seed1) == m_Watershed->GetOutput()->GetPixel(m_Seed2) )
-      {
+    m_Watershed->SetLevel(guess);
+    m_Watershed->Update();
+    if (m_Watershed->GetOutput()->GetPixel(m_Seed1) == m_Watershed->GetOutput()->GetPixel(m_Seed2))
+    {
       upper = guess;
-      }
+    }
     else
-      {
+    {
       lower = guess;
-      }
-    guess = ( upper + lower ) / 2;
-    iterate.CompletedStep();
     }
+    guess = (upper + lower) / 2;
+    iterate.CompletedStep();
+  }
 
   // If the watershed basins are not separated or if the upper/lower
   // threshold were not valid, then use lower.
-  if (  m_Watershed->GetOutput()->GetBufferedRegion() != region
-        || m_Watershed->GetOutput()->GetPixel(m_Seed1) ==
-        m_Watershed->GetOutput()->GetPixel(m_Seed2) )
-    {
-    m_Watershed->SetLevel (lower);
-    m_Watershed->Update ();
-    }
+  if (m_Watershed->GetOutput()->GetBufferedRegion() != region ||
+      m_Watershed->GetOutput()->GetPixel(m_Seed1) == m_Watershed->GetOutput()->GetPixel(m_Seed2))
+  {
+    m_Watershed->SetLevel(lower);
+    m_Watershed->Update();
+  }
 
   // Now produce an output image with the two seeded basins labeled
 
   ProgressReporter progress(this, 0, region.GetNumberOfPixels(), 100, cumulatedProgress, progressWeight);
 
-  ImageRegionIterator< OutputImageType > ot =
-    ImageRegionIterator< OutputImageType >(outputImage, region);
-  ImageRegionIterator< typename WatershedType::OutputImageType > it =
-    ImageRegionIterator< typename WatershedType::OutputImageType >(m_Watershed->GetOutput(), region);
+  ImageRegionIterator<OutputImageType> ot = ImageRegionIterator<OutputImageType>(outputImage, region);
+  ImageRegionIterator<typename WatershedType::OutputImageType> it =
+    ImageRegionIterator<typename WatershedType::OutputImageType>(m_Watershed->GetOutput(), region);
 
   IdentifierType seed1Label = m_Watershed->GetOutput()->GetPixel(m_Seed1);
   IdentifierType seed2Label = m_Watershed->GetOutput()->GetPixel(m_Seed2);
@@ -167,55 +157,46 @@ IsolatedWatershedImageFilter< TInputImage, TOutputImage >
 
   it.GoToBegin();
   ot.GoToBegin();
-  while ( !it.IsAtEnd() )
-    {
+  while (!it.IsAtEnd())
+  {
     value = it.Get();
-    if ( value == seed1Label )
-      {
+    if (value == seed1Label)
+    {
       ot.Set(m_ReplaceValue1);
-      }
-    else if ( value == seed2Label )
-      {
+    }
+    else if (value == seed2Label)
+    {
       ot.Set(m_ReplaceValue2);
-      }
+    }
     else
-      {
-      ot.Set(NumericTraits< OutputImagePixelType >::ZeroValue());
-      }
+    {
+      ot.Set(NumericTraits<OutputImagePixelType>::ZeroValue());
+    }
     ++it;
     ++ot;
     progress.CompletedPixel(); // potential exception thrown here
-    }
+  }
   m_IsolatedValue = lower;
   iterate.CompletedStep();
 }
 
-template< typename TInputImage, typename TOutputImage >
+template <typename TInputImage, typename TOutputImage>
 void
-IsolatedWatershedImageFilter< TInputImage, TOutputImage >
-::PrintSelf(std::ostream & os, Indent indent) const
+IsolatedWatershedImageFilter<TInputImage, TOutputImage>::PrintSelf(std::ostream & os, Indent indent) const
 {
   this->Superclass::PrintSelf(os, indent);
-  os << indent << "Threshold: "
-     << m_Threshold
-     << std::endl;
-  os << indent << "UpperValueLimit: "
-     << m_UpperValueLimit
+  os << indent << "Threshold: " << m_Threshold << std::endl;
+  os << indent << "UpperValueLimit: " << m_UpperValueLimit << std::endl;
+  os << indent
+     << "ReplaceValue1: " << static_cast<typename NumericTraits<OutputImagePixelType>::PrintType>(m_ReplaceValue1)
      << std::endl;
-  os << indent << "ReplaceValue1: "
-     << static_cast< typename NumericTraits< OutputImagePixelType >::PrintType >( m_ReplaceValue1 )
-     << std::endl;
-  os << indent << "ReplaceValue2: "
-     << static_cast< typename NumericTraits< OutputImagePixelType >::PrintType >( m_ReplaceValue2 )
+  os << indent
+     << "ReplaceValue2: " << static_cast<typename NumericTraits<OutputImagePixelType>::PrintType>(m_ReplaceValue2)
      << std::endl;
   os << indent << "Seed1: " << m_Seed1 << std::endl;
   os << indent << "Seed2: " << m_Seed2 << std::endl;
-  os << indent << "IsolatedValue: "
-     << m_IsolatedValue
-     << std::endl;
-  os << indent << "IsolatedValueTolerance: "
-     << m_IsolatedValueTolerance
-     << std::endl;
+  os << indent << "IsolatedValue: " << m_IsolatedValue << std::endl;
+  os << indent << "IsolatedValueTolerance: " << m_IsolatedValueTolerance << std::endl;
 }
 
 } // end namespace itk
diff --git a/Modules/Segmentation/Watersheds/include/itkMorphologicalWatershedFromMarkersImageFilter.h b/Modules/Segmentation/Watersheds/include/itkMorphologicalWatershedFromMarkersImageFilter.h
index 7098f76dad..41390bd02c 100644
--- a/Modules/Segmentation/Watersheds/include/itkMorphologicalWatershedFromMarkersImageFilter.h
+++ b/Modules/Segmentation/Watersheds/include/itkMorphologicalWatershedFromMarkersImageFilter.h
@@ -77,34 +77,35 @@ namespace itk
  * \ingroup ImageEnhancement  MathematicalMorphologyImageFilters
  * \ingroup ITKWatersheds
  */
-template< typename TInputImage, typename TLabelImage >
-class ITK_TEMPLATE_EXPORT MorphologicalWatershedFromMarkersImageFilter:
-  public ImageToImageFilter< TInputImage, TLabelImage >
+template <typename TInputImage, typename TLabelImage>
+class ITK_TEMPLATE_EXPORT MorphologicalWatershedFromMarkersImageFilter
+  : public ImageToImageFilter<TInputImage, TLabelImage>
 {
 public:
-  /** Standard class typedefs. */
-  typedef MorphologicalWatershedFromMarkersImageFilter   Self;
-  typedef ImageToImageFilter< TInputImage, TLabelImage > Superclass;
-  typedef SmartPointer< Self >                           Pointer;
-  typedef SmartPointer< const Self >                     ConstPointer;
-
-  /** Some convenient typedefs. */
-  typedef TInputImage                           InputImageType;
-  typedef TLabelImage                           LabelImageType;
-  typedef typename InputImageType::Pointer      InputImagePointer;
-  typedef typename InputImageType::ConstPointer InputImageConstPointer;
-  typedef typename InputImageType::RegionType   InputImageRegionType;
-  typedef typename InputImageType::PixelType    InputImagePixelType;
-  typedef typename LabelImageType::Pointer      LabelImagePointer;
-  typedef typename LabelImageType::ConstPointer LabelImageConstPointer;
-  typedef typename LabelImageType::RegionType   LabelImageRegionType;
-  typedef typename LabelImageType::PixelType    LabelImagePixelType;
-
-  typedef typename LabelImageType::IndexType IndexType;
+  ITK_DISALLOW_COPY_AND_ASSIGN(MorphologicalWatershedFromMarkersImageFilter);
+
+  /** Standard class type aliases. */
+  using Self = MorphologicalWatershedFromMarkersImageFilter;
+  using Superclass = ImageToImageFilter<TInputImage, TLabelImage>;
+  using Pointer = SmartPointer<Self>;
+  using ConstPointer = SmartPointer<const Self>;
+
+  /** Some convenient type alias. */
+  using InputImageType = TInputImage;
+  using LabelImageType = TLabelImage;
+  using InputImagePointer = typename InputImageType::Pointer;
+  using InputImageConstPointer = typename InputImageType::ConstPointer;
+  using InputImageRegionType = typename InputImageType::RegionType;
+  using InputImagePixelType = typename InputImageType::PixelType;
+  using LabelImagePointer = typename LabelImageType::Pointer;
+  using LabelImageConstPointer = typename LabelImageType::ConstPointer;
+  using LabelImageRegionType = typename LabelImageType::RegionType;
+  using LabelImagePixelType = typename LabelImageType::PixelType;
+
+  using IndexType = typename LabelImageType::IndexType;
 
   /** ImageDimension constants */
-  itkStaticConstMacro(ImageDimension, unsigned int,
-                      TInputImage::ImageDimension);
+  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
 
   /** Standard New method. */
   itkNewMacro(Self);
@@ -113,27 +114,30 @@ public:
   itkTypeMacro(MorphologicalWatershedFromMarkersImageFilter, ImageToImageFilter);
 
   /** Set the marker image */
-  void SetMarkerImage(const TLabelImage *input)
+  void
+  SetMarkerImage(const TLabelImage * input)
   {
     // Process object is not const-correct so the const casting is required.
-    this->SetNthInput( 1, const_cast< TLabelImage * >( input ) );
+    this->SetNthInput(1, const_cast<TLabelImage *>(input));
   }
 
   /** Get the marker image */
-  const LabelImageType * GetMarkerImage() const
+  const LabelImageType *
+  GetMarkerImage() const
   {
-    return itkDynamicCastInDebugMode< LabelImageType * >
-      (const_cast< DataObject * >( this->ProcessObject::GetInput(1) ) );
+    return itkDynamicCastInDebugMode<LabelImageType *>(const_cast<DataObject *>(this->ProcessObject::GetInput(1)));
   }
 
   /** Set the input image */
-  void SetInput1(const TInputImage *input)
+  void
+  SetInput1(const TInputImage * input)
   {
     this->SetInput(input);
   }
 
   /** Set the marker image */
-  void SetInput2(const TLabelImage *input)
+  void
+  SetInput2(const TLabelImage * input)
   {
     this->SetMarkerImage(input);
   }
@@ -159,33 +163,35 @@ public:
 
 protected:
   MorphologicalWatershedFromMarkersImageFilter();
-  ~MorphologicalWatershedFromMarkersImageFilter() ITK_OVERRIDE {}
-  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
+  ~MorphologicalWatershedFromMarkersImageFilter() override = default;
+  void
+  PrintSelf(std::ostream & os, Indent indent) const override;
 
   /** MorphologicalWatershedFromMarkersImageFilter needs to request the
    * entire input images.
    */
-  void GenerateInputRequestedRegion() ITK_OVERRIDE;
+  void
+  GenerateInputRequestedRegion() override;
 
   /** This filter will enlarge the output requested region to produce
    * all of the output.
    * \sa ProcessObject::EnlargeOutputRequestedRegion() */
-  void EnlargeOutputRequestedRegion( DataObject *itkNotUsed(output) ) ITK_OVERRIDE;
+  void
+  EnlargeOutputRequestedRegion(DataObject * itkNotUsed(output)) override;
 
   /** The filter is single threaded. */
-  void GenerateData() ITK_OVERRIDE;
+  void
+  GenerateData() override;
 
 private:
-  ITK_DISALLOW_COPY_AND_ASSIGN(MorphologicalWatershedFromMarkersImageFilter);
-
-  bool m_FullyConnected;
+  bool m_FullyConnected{ false };
 
-  bool m_MarkWatershedLine;
+  bool m_MarkWatershedLine{ true };
 }; // end of class
 } // end namespace itk
 
 #ifndef ITK_MANUAL_INSTANTIATION
-#include "itkMorphologicalWatershedFromMarkersImageFilter.hxx"
+#  include "itkMorphologicalWatershedFromMarkersImageFilter.hxx"
 #endif
 
 #endif
diff --git a/Modules/Segmentation/Watersheds/include/itkMorphologicalWatershedFromMarkersImageFilter.hxx b/Modules/Segmentation/Watersheds/include/itkMorphologicalWatershedFromMarkersImageFilter.hxx
index 51f99e5825..32da4249e9 100644
--- a/Modules/Segmentation/Watersheds/include/itkMorphologicalWatershedFromMarkersImageFilter.hxx
+++ b/Modules/Segmentation/Watersheds/include/itkMorphologicalWatershedFromMarkersImageFilter.hxx
@@ -33,59 +33,52 @@
 namespace itk
 {
 
-template< typename TInputImage, typename TLabelImage >
-MorphologicalWatershedFromMarkersImageFilter< TInputImage, TLabelImage >
-::MorphologicalWatershedFromMarkersImageFilter():
-  m_FullyConnected( false ),
-  m_MarkWatershedLine( true )
+template <typename TInputImage, typename TLabelImage>
+MorphologicalWatershedFromMarkersImageFilter<TInputImage, TLabelImage>::MorphologicalWatershedFromMarkersImageFilter()
+
 
 {
   this->SetNumberOfRequiredInputs(2);
 }
 
 
-template< typename TInputImage, typename TLabelImage >
+template <typename TInputImage, typename TLabelImage>
 void
-MorphologicalWatershedFromMarkersImageFilter< TInputImage, TLabelImage >
-::GenerateInputRequestedRegion()
+MorphologicalWatershedFromMarkersImageFilter<TInputImage, TLabelImage>::GenerateInputRequestedRegion()
 {
   // call the superclass' implementation of this method
   Superclass::GenerateInputRequestedRegion();
 
   // get pointers to the inputs
-  LabelImageType * marker =
-    const_cast< LabelImageType * >( this->GetMarkerImage() );
+  auto * marker = const_cast<LabelImageType *>(this->GetMarkerImage());
 
-  InputImageType * input =
-    const_cast< InputImageType * >( this->GetInput() );
+  auto * input = const_cast<InputImageType *>(this->GetInput());
 
-  if ( !marker || !input )
-    {
+  if (!marker || !input)
+  {
     return;
-    }
+  }
 
   // We need to
   // configure the inputs such that all the data is available.
   //
-  marker->SetRequestedRegion( marker->GetLargestPossibleRegion() );
-  input->SetRequestedRegion( input->GetLargestPossibleRegion() );
+  marker->SetRequestedRegion(marker->GetLargestPossibleRegion());
+  input->SetRequestedRegion(input->GetLargestPossibleRegion());
 }
 
 
-template< typename TInputImage, typename TLabelImage >
+template <typename TInputImage, typename TLabelImage>
 void
-MorphologicalWatershedFromMarkersImageFilter< TInputImage, TLabelImage >
-::EnlargeOutputRequestedRegion(DataObject *)
+MorphologicalWatershedFromMarkersImageFilter<TInputImage, TLabelImage>::EnlargeOutputRequestedRegion(DataObject *)
 {
   LabelImageType * output = this->GetOutput();
-  output->SetRequestedRegion( output->GetLargestPossibleRegion() );
+  output->SetRequestedRegion(output->GetLargestPossibleRegion());
 }
 
 
-template< typename TInputImage, typename TLabelImage >
+template <typename TInputImage, typename TLabelImage>
 void
-MorphologicalWatershedFromMarkersImageFilter< TInputImage, TLabelImage >
-::GenerateData()
+MorphologicalWatershedFromMarkersImageFilter<TInputImage, TLabelImage>::GenerateData()
 {
   // there is 2 possible cases: with or without watershed lines.
   // the algorithm with watershed lines is from Meyer
@@ -99,17 +92,15 @@ MorphologicalWatershedFromMarkersImageFilter< TInputImage, TLabelImage >
   //---------------------------------------------------------------------------
 
   // the label used to find background in the marker image
-  static const LabelImagePixelType bgLabel =
-    NumericTraits< LabelImagePixelType >::ZeroValue();
+  static const LabelImagePixelType bgLabel = NumericTraits<LabelImagePixelType>::ZeroValue();
   // the label used to mark the watershed line in the output image
-  static const LabelImagePixelType wsLabel =
-    NumericTraits< LabelImagePixelType >::ZeroValue();
+  static const LabelImagePixelType wsLabel = NumericTraits<LabelImagePixelType>::ZeroValue();
 
   this->AllocateOutputs();
 
   const LabelImageType * markerImage = this->GetMarkerImage();
   const InputImageType * inputImage = this->GetInput();
-  LabelImageType * outputImage = this->GetOutput();
+  LabelImageType *       outputImage = this->GetOutput();
 
   // Set up the progress reporter
   // we can't found the exact number of pixel to process in the 2nd pass, so we
@@ -117,58 +108,55 @@ MorphologicalWatershedFromMarkersImageFilter< TInputImage, TLabelImage >
   ProgressReporter progress(this, 0, markerImage->GetRequestedRegion().GetNumberOfPixels() * 2);
 
   // mask and marker must have the same size
-  if ( markerImage->GetRequestedRegion().GetSize() != inputImage->GetRequestedRegion().GetSize() )
-    {
+  if (markerImage->GetRequestedRegion().GetSize() != inputImage->GetRequestedRegion().GetSize())
+  {
     itkExceptionMacro(<< "Marker and input must have the same size.");
-    }
+  }
 
   // FAH (in french: File d'Attente Hierarchique)
-  typedef std::queue< IndexType >                    QueueType;
-  typedef std::map< InputImagePixelType, QueueType > MapType;
+  using QueueType = std::queue<IndexType>;
+  using MapType = std::map<InputImagePixelType, QueueType>;
   MapType fah;
 
   // the radius which will be used for all the shaped iterators
-  Size< ImageDimension > radius;
+  Size<ImageDimension> radius;
   radius.Fill(1);
 
   // iterator for the marker image
-  typedef ConstShapedNeighborhoodIterator< LabelImageType > MarkerIteratorType;
+  using MarkerIteratorType = ConstShapedNeighborhoodIterator<LabelImageType>;
   typename MarkerIteratorType::ConstIterator nmIt;
-  MarkerIteratorType
-  markerIt( radius, markerImage, markerImage->GetRequestedRegion() );
+  MarkerIteratorType                         markerIt(radius, markerImage, markerImage->GetRequestedRegion());
   // add a boundary constant to avoid adding pixels on the border in the fah
-  ConstantBoundaryCondition< LabelImageType > lcbc;
-  lcbc.SetConstant( NumericTraits< LabelImagePixelType >::max() );
+  ConstantBoundaryCondition<LabelImageType> lcbc;
+  lcbc.SetConstant(NumericTraits<LabelImagePixelType>::max());
   markerIt.OverrideBoundaryCondition(&lcbc);
   setConnectivity(&markerIt, m_FullyConnected);
 
   // iterator for the input image
-  typedef ConstShapedNeighborhoodIterator< InputImageType > InputIteratorType;
-  InputIteratorType
-  inputIt( radius, inputImage, inputImage->GetRequestedRegion() );
+  using InputIteratorType = ConstShapedNeighborhoodIterator<InputImageType>;
+  InputIteratorType                         inputIt(radius, inputImage, inputImage->GetRequestedRegion());
   typename InputIteratorType::ConstIterator niIt;
   setConnectivity(&inputIt, m_FullyConnected);
 
   // iterator for the output image
-  typedef ShapedNeighborhoodIterator< LabelImageType > OutputIteratorType;
-  typedef typename OutputIteratorType::OffsetType      OffsetType;
+  using OutputIteratorType = ShapedNeighborhoodIterator<LabelImageType>;
+  using OffsetType = typename OutputIteratorType::OffsetType;
   typename OutputIteratorType::Iterator noIt;
-  OutputIteratorType
-  outputIt( radius, outputImage, outputImage->GetRequestedRegion() );
+  OutputIteratorType                    outputIt(radius, outputImage, outputImage->GetRequestedRegion());
   setConnectivity(&outputIt, m_FullyConnected);
 
   //---------------------------------------------------------------------------
   // Meyer's algorithm
   //---------------------------------------------------------------------------
-  if ( m_MarkWatershedLine )
-    {
+  if (m_MarkWatershedLine)
+  {
     // first stage:
     //  - set markers pixels to already processed status
     //  - copy markers pixels to output image
     //  - init FAH with indexes of background pixels with marker pixel(s) in
     //    their neighborhood
 
-    ConstantBoundaryCondition< LabelImageType > lcbc2;
+    ConstantBoundaryCondition<LabelImageType> lcbc2;
     // outside pixel are watershed so they won't be use to find real watershed
     // pixels
     lcbc2.SetConstant(wsLabel);
@@ -176,18 +164,17 @@ MorphologicalWatershedFromMarkersImageFilter< TInputImage, TLabelImage >
 
     // create a temporary image to store the state of each pixel (processed or
     // not)
-    typedef Image< bool, ImageDimension > StatusImageType;
+    using StatusImageType = Image<bool, ImageDimension>;
     typename StatusImageType::Pointer statusImage = StatusImageType::New();
-    statusImage->SetRegions( markerImage->GetLargestPossibleRegion() );
+    statusImage->SetRegions(markerImage->GetLargestPossibleRegion());
     statusImage->Allocate();
 
     // iterator for the status image
-    typedef ShapedNeighborhoodIterator< StatusImageType > StatusIteratorType;
-    typename StatusIteratorType::Iterator nsIt;
-    StatusIteratorType
-                                                 statusIt( radius, statusImage, outputImage->GetRequestedRegion() );
-    ConstantBoundaryCondition< StatusImageType > bcbc;
-    bcbc.SetConstant(true);    // outside pixel are already processed
+    using StatusIteratorType = ShapedNeighborhoodIterator<StatusImageType>;
+    typename StatusIteratorType::Iterator      nsIt;
+    StatusIteratorType                         statusIt(radius, statusImage, outputImage->GetRequestedRegion());
+    ConstantBoundaryCondition<StatusImageType> bcbc;
+    bcbc.SetConstant(true); // outside pixel are already processed
     statusIt.OverrideBoundaryCondition(&bcbc);
     setConnectivity(&statusIt, m_FullyConnected);
 
@@ -198,13 +185,12 @@ MorphologicalWatershedFromMarkersImageFilter< TInputImage, TLabelImage >
     // the overhead should be small
     statusImage->FillBuffer(false);
 
-    for ( markerIt.GoToBegin(), statusIt.GoToBegin(), outputIt.GoToBegin(), inputIt.GoToBegin();
-          !markerIt.IsAtEnd();
-          ++markerIt, ++outputIt )
-      {
+    for (markerIt.GoToBegin(), statusIt.GoToBegin(), outputIt.GoToBegin(), inputIt.GoToBegin(); !markerIt.IsAtEnd();
+         ++markerIt, ++outputIt)
+    {
       LabelImagePixelType markerPixel = markerIt.GetCenterPixel();
-      if ( markerPixel != bgLabel )
-        {
+      if (markerPixel != bgLabel)
+      {
         IndexType idx = markerIt.GetIndex();
 
         // move the iterators to the right place
@@ -222,36 +208,34 @@ MorphologicalWatershedFromMarkersImageFilter< TInputImage, TLabelImage >
         progress.CompletedPixel();
 
         // search the background pixels in the neighborhood
-        for ( nmIt = markerIt.Begin(), nsIt = statusIt.Begin(), niIt = inputIt.Begin();
-              nmIt != markerIt.End();
-              nmIt++, nsIt++, niIt++ )
+        for (nmIt = markerIt.Begin(), nsIt = statusIt.Begin(), niIt = inputIt.Begin(); nmIt != markerIt.End();
+             nmIt++, nsIt++, niIt++)
+        {
+          if (!nsIt.Get() && nmIt.Get() == bgLabel)
           {
-          if ( !nsIt.Get() && nmIt.Get() == bgLabel )
-            {
             // this neighbor is a background pixel and is not already
             // processed; add its index to fah
-            fah[niIt.Get()].push( markerIt.GetIndex()
-                                  + nmIt.GetNeighborhoodOffset() );
+            fah[niIt.Get()].push(markerIt.GetIndex() + nmIt.GetNeighborhoodOffset());
             // mark it as already in the fah to avoid adding it several times
             nsIt.Set(true);
-            }
           }
         }
+      }
       else
-        {
+      {
         // Some pixels may be never processed so, by default, non marked pixels
         // must be marked as watershed
         outputIt.SetCenterPixel(wsLabel);
-        }
+      }
       // one more pixel done in the init stage
       progress.CompletedPixel();
-      }
+    }
     // fill the borders of the status image with "true"
-    //FillSides<StatusImageType>(statusImage, true);
+    // FillSides<StatusImageType>(statusImage, true);
     // Now disable the boundary checks
-    //outputIt.NeedToUseBoundaryConditionOff();
-    //statusIt.NeedToUseBoundaryConditionOff();
-    //inputIt.NeedToUseBoundaryConditionOff();
+    // outputIt.NeedToUseBoundaryConditionOff();
+    // statusIt.NeedToUseBoundaryConditionOff();
+    // inputIt.NeedToUseBoundaryConditionOff();
     // end of init stage
 
     // flooding
@@ -261,16 +245,16 @@ MorphologicalWatershedFromMarkersImageFilter< TInputImage, TLabelImage >
     inputIt.GoToBegin();
 
     // and start flooding
-    while ( !fah.empty() )
-      {
+    while (!fah.empty())
+    {
       // store the current vars
       InputImagePixelType currentValue = fah.begin()->first;
       QueueType           currentQueue = fah.begin()->second;
       // and remove them from the fah
-      fah.erase( fah.begin() );
+      fah.erase(fah.begin());
 
-      while ( !currentQueue.empty() )
-        {
+      while (!currentQueue.empty())
+      {
         IndexType idx = currentQueue.front();
         currentQueue.pop();
 
@@ -284,77 +268,73 @@ MorphologicalWatershedFromMarkersImageFilter< TInputImage, TLabelImage >
         // that value to the pixel, else keep it as is (watershed line)
         LabelImagePixelType marker = wsLabel;
         bool                collision = false;
-        for ( noIt = outputIt.Begin(); noIt != outputIt.End(); noIt++ )
-          {
+        for (noIt = outputIt.Begin(); noIt != outputIt.End(); noIt++)
+        {
           LabelImagePixelType o = noIt.Get();
-          if ( o != wsLabel )
+          if (o != wsLabel)
+          {
+            if (marker != wsLabel && o != marker)
             {
-            if ( marker != wsLabel && o != marker )
-              {
               collision = true;
               break;
-              }
+            }
             else
-                  { marker = o; }
+            {
+              marker = o;
             }
           }
-        if ( !collision )
-          {
+        }
+        if (!collision)
+        {
           // set the marker value
           outputIt.SetCenterPixel(marker);
           // and propagate to the neighbors
-          for ( niIt = inputIt.Begin(), nsIt = statusIt.Begin();
-                niIt != inputIt.End();
-                niIt++, nsIt++ )
+          for (niIt = inputIt.Begin(), nsIt = statusIt.Begin(); niIt != inputIt.End(); niIt++, nsIt++)
+          {
+            if (!nsIt.Get())
             {
-            if ( !nsIt.Get() )
-              {
               // the pixel is not yet processed. add it to the fah
               InputImagePixelType GrayVal = niIt.Get();
-              if ( GrayVal <= currentValue )
-                {
-                currentQueue.push( inputIt.GetIndex()
-                                   + niIt.GetNeighborhoodOffset() );
-                }
+              if (GrayVal <= currentValue)
+              {
+                currentQueue.push(inputIt.GetIndex() + niIt.GetNeighborhoodOffset());
+              }
               else
-                {
-                fah[GrayVal].push( inputIt.GetIndex()
-                                   + niIt.GetNeighborhoodOffset() );
-                }
+              {
+                fah[GrayVal].push(inputIt.GetIndex() + niIt.GetNeighborhoodOffset());
+              }
               // mark it as already in the fah
               nsIt.Set(true);
-              }
             }
           }
+        }
         // one more pixel in the flooding stage
         progress.CompletedPixel();
-        }
       }
     }
+  }
 
   //---------------------------------------------------------------------------
   // Beucher's algorithm
   //---------------------------------------------------------------------------
   else
-    {
+  {
     // first stage:
     //  - copy markers pixels to output image
     //  - init FAH with indexes of pixels with background pixel in their
     //    neighborhood
 
-    ConstantBoundaryCondition< LabelImageType > lcbc2;
+    ConstantBoundaryCondition<LabelImageType> lcbc2;
     // outside pixel are watershed so they won't be use to find real watershed
     // pixels
-    lcbc2.SetConstant( NumericTraits< LabelImagePixelType >::max() );
+    lcbc2.SetConstant(NumericTraits<LabelImagePixelType>::max());
     outputIt.OverrideBoundaryCondition(&lcbc2);
 
-    for ( markerIt.GoToBegin(), outputIt.GoToBegin(), inputIt.GoToBegin();
-          !markerIt.IsAtEnd();
-          ++markerIt, ++outputIt )
-      {
+    for (markerIt.GoToBegin(), outputIt.GoToBegin(), inputIt.GoToBegin(); !markerIt.IsAtEnd(); ++markerIt, ++outputIt)
+    {
       LabelImagePixelType markerPixel = markerIt.GetCenterPixel();
-      if ( markerPixel != bgLabel )
-        {
+      if (markerPixel != bgLabel)
+      {
         IndexType  idx = markerIt.GetIndex();
         OffsetType shift = idx - inputIt.GetIndex();
         inputIt += shift;
@@ -364,32 +344,32 @@ MorphologicalWatershedFromMarkersImageFilter< TInputImage, TLabelImage >
         outputIt.SetCenterPixel(markerPixel);
         // search if it has background pixel in its neighborhood
         bool haveBgNeighbor = false;
-        for ( nmIt = markerIt.Begin(); nmIt != markerIt.End(); nmIt++ )
+        for (nmIt = markerIt.Begin(); nmIt != markerIt.End(); nmIt++)
+        {
+          if (nmIt.Get() == bgLabel)
           {
-          if ( nmIt.Get() == bgLabel )
-            {
             haveBgNeighbor = true;
             break;
-            }
           }
-        if ( haveBgNeighbor )
-          {
+        }
+        if (haveBgNeighbor)
+        {
           // there is a background pixel in the neighborhood; add to fah
-          fah[inputIt.GetCenterPixel()].push( markerIt.GetIndex() );
-          }
+          fah[inputIt.GetCenterPixel()].push(markerIt.GetIndex());
+        }
         else
-          {
+        {
           // increase progress because this pixel will not be used in the
           // flooding stage.
           progress.CompletedPixel();
-          }
         }
+      }
       else
-        {
+      {
         outputIt.SetCenterPixel(wsLabel);
-        }
-      progress.CompletedPixel();
       }
+      progress.CompletedPixel();
+    }
     // end of init stage
 
     // flooding
@@ -398,16 +378,16 @@ MorphologicalWatershedFromMarkersImageFilter< TInputImage, TLabelImage >
     inputIt.GoToBegin();
 
     // and start flooding
-    while ( !fah.empty() )
-      {
+    while (!fah.empty())
+    {
       // store the current vars
       InputImagePixelType currentValue = fah.begin()->first;
       QueueType           currentQueue = fah.begin()->second;
       // and remove them from the fah
-      fah.erase( fah.begin() );
+      fah.erase(fah.begin());
 
-      while ( !currentQueue.empty() )
-        {
+      while (!currentQueue.empty())
+      {
         IndexType idx = currentQueue.front();
         currentQueue.pop();
 
@@ -419,44 +399,40 @@ MorphologicalWatershedFromMarkersImageFilter< TInputImage, TLabelImage >
         LabelImagePixelType currentMarker = outputIt.GetCenterPixel();
         // get the current value of the pixel
         // iterate over neighbors to propagate the marker
-        for ( noIt = outputIt.Begin(), niIt = inputIt.Begin();
-              noIt != outputIt.End();
-              noIt++, niIt++ )
+        for (noIt = outputIt.Begin(), niIt = inputIt.Begin(); noIt != outputIt.End(); noIt++, niIt++)
+        {
+          if (noIt.Get() == wsLabel)
           {
-          if ( noIt.Get() == wsLabel )
-            {
             // the pixel is not yet processed. It can be labeled with the
             // current label
             noIt.Set(currentMarker);
             InputImagePixelType GrayVal = niIt.Get();
-            if ( GrayVal <= currentValue )
-              {
-              currentQueue.push( inputIt.GetIndex()
-                                 + noIt.GetNeighborhoodOffset() );
-              }
+            if (GrayVal <= currentValue)
+            {
+              currentQueue.push(inputIt.GetIndex() + noIt.GetNeighborhoodOffset());
+            }
             else
-              {
-              fah[GrayVal].push( inputIt.GetIndex()
-                                 + noIt.GetNeighborhoodOffset() );
-              }
-            progress.CompletedPixel();
+            {
+              fah[GrayVal].push(inputIt.GetIndex() + noIt.GetNeighborhoodOffset());
             }
+            progress.CompletedPixel();
           }
         }
       }
     }
+  }
 }
 
 
-template< typename TInputImage, typename TLabelImage >
+template <typename TInputImage, typename TLabelImage>
 void
-MorphologicalWatershedFromMarkersImageFilter< TInputImage, TLabelImage >
-::PrintSelf(std::ostream & os, Indent indent) const
+MorphologicalWatershedFromMarkersImageFilter<TInputImage, TLabelImage>::PrintSelf(std::ostream & os,
+                                                                                  Indent         indent) const
 {
   Superclass::PrintSelf(os, indent);
 
-  os << indent << "FullyConnected: "  << m_FullyConnected << std::endl;
-  os << indent << "MarkWatershedLine: "  << m_MarkWatershedLine << std::endl;
+  os << indent << "FullyConnected: " << m_FullyConnected << std::endl;
+  os << indent << "MarkWatershedLine: " << m_MarkWatershedLine << std::endl;
 }
 
 } // end namespace itk
diff --git a/Modules/Segmentation/Watersheds/include/itkMorphologicalWatershedImageFilter.h b/Modules/Segmentation/Watersheds/include/itkMorphologicalWatershedImageFilter.h
index 50f171171d..3477b72ec0 100644
--- a/Modules/Segmentation/Watersheds/include/itkMorphologicalWatershedImageFilter.h
+++ b/Modules/Segmentation/Watersheds/include/itkMorphologicalWatershedImageFilter.h
@@ -23,7 +23,7 @@
 namespace itk
 {
 /** \class MorphologicalWatershedImageFilter
- * \brief Watershed segmentation implementation with morphogical operators
+ * \brief Watershed segmentation implementation with morphological operators
  *
  * Watershed pixel are labeled 0.
  * TOutputImage should be an integer type.
@@ -47,35 +47,38 @@ namespace itk
  * \sa WatershedImageFilter, MorphologicalWatershedFromMarkersImageFilter
  * \ingroup ImageEnhancement  MathematicalMorphologyImageFilters
  * \ingroup ITKWatersheds
+ *
+ * \sphinx
+ * \sphinexample{Segmentation/Watersheds/MorphologicalWatershedSegmentation,Morphological Watershed Segmentation}
+ * \endsphinx
  */
-template< typename TInputImage, typename TOutputImage >
-class ITK_TEMPLATE_EXPORT MorphologicalWatershedImageFilter:
-  public ImageToImageFilter< TInputImage, TOutputImage >
+template <typename TInputImage, typename TOutputImage>
+class ITK_TEMPLATE_EXPORT MorphologicalWatershedImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
 {
 public:
-  /** Standard class typedefs. */
-  typedef MorphologicalWatershedImageFilter               Self;
-  typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass;
-  typedef SmartPointer< Self >                            Pointer;
-  typedef SmartPointer< const Self >                      ConstPointer;
-
-  /** Some convenient typedefs. */
-  typedef TInputImage                            InputImageType;
-  typedef TOutputImage                           OutputImageType;
-  typedef typename InputImageType::Pointer       InputImagePointer;
-  typedef typename InputImageType::ConstPointer  InputImageConstPointer;
-  typedef typename InputImageType::RegionType    InputImageRegionType;
-  typedef typename InputImageType::PixelType     InputImagePixelType;
-  typedef typename OutputImageType::Pointer      OutputImagePointer;
-  typedef typename OutputImageType::ConstPointer OutputImageConstPointer;
-  typedef typename OutputImageType::RegionType   OutputImageRegionType;
-  typedef typename OutputImageType::PixelType    OutputImagePixelType;
+  ITK_DISALLOW_COPY_AND_ASSIGN(MorphologicalWatershedImageFilter);
+
+  /** Standard class type aliases. */
+  using Self = MorphologicalWatershedImageFilter;
+  using Superclass = ImageToImageFilter<TInputImage, TOutputImage>;
+  using Pointer = SmartPointer<Self>;
+  using ConstPointer = SmartPointer<const Self>;
+
+  /** Some convenient type alias. */
+  using InputImageType = TInputImage;
+  using OutputImageType = TOutputImage;
+  using InputImagePointer = typename InputImageType::Pointer;
+  using InputImageConstPointer = typename InputImageType::ConstPointer;
+  using InputImageRegionType = typename InputImageType::RegionType;
+  using InputImagePixelType = typename InputImageType::PixelType;
+  using OutputImagePointer = typename OutputImageType::Pointer;
+  using OutputImageConstPointer = typename OutputImageType::ConstPointer;
+  using OutputImageRegionType = typename OutputImageType::RegionType;
+  using OutputImagePixelType = typename OutputImageType::PixelType;
 
   /** ImageDimension constants */
-  itkStaticConstMacro(InputImageDimension, unsigned int,
-                      TInputImage::ImageDimension);
-  itkStaticConstMacro(OutputImageDimension, unsigned int,
-                      TOutputImage::ImageDimension);
+  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
+  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
 
   /** Standard New method. */
   itkNewMacro(Self);
@@ -109,34 +112,36 @@ public:
 
 protected:
   MorphologicalWatershedImageFilter();
-  ~MorphologicalWatershedImageFilter() ITK_OVERRIDE {}
-  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
+  ~MorphologicalWatershedImageFilter() override = default;
+  void
+  PrintSelf(std::ostream & os, Indent indent) const override;
 
   /** MorphologicalWatershedImageFilter needs the entire input be
    * available. Thus, it needs to provide an implementation of
    * GenerateInputRequestedRegion(). */
-  void GenerateInputRequestedRegion() ITK_OVERRIDE;
+  void
+  GenerateInputRequestedRegion() override;
 
   /** MorphologicalWatershedImageFilter will produce the entire output. */
-  void EnlargeOutputRequestedRegion( DataObject *itkNotUsed(output) ) ITK_OVERRIDE;
+  void
+  EnlargeOutputRequestedRegion(DataObject * itkNotUsed(output)) override;
 
   /** Single-threaded version of GenerateData.  This filter delegates
    * to GrayscaleGeodesicErodeImageFilter. */
-  void GenerateData() ITK_OVERRIDE;
+  void
+  GenerateData() override;
 
 private:
-  ITK_DISALLOW_COPY_AND_ASSIGN(MorphologicalWatershedImageFilter);
-
-  bool m_FullyConnected;
+  bool m_FullyConnected{ false };
 
-  bool m_MarkWatershedLine;
+  bool m_MarkWatershedLine{ true };
 
   InputImagePixelType m_Level;
 }; // end of class
 } // end namespace itk
 
 #ifndef ITK_MANUAL_INSTANTIATION
-#include "itkMorphologicalWatershedImageFilter.hxx"
+#  include "itkMorphologicalWatershedImageFilter.hxx"
 #endif
 
 #endif
diff --git a/Modules/Segmentation/Watersheds/include/itkMorphologicalWatershedImageFilter.hxx b/Modules/Segmentation/Watersheds/include/itkMorphologicalWatershedImageFilter.hxx
index 5a529f3057..610868aa5a 100644
--- a/Modules/Segmentation/Watersheds/include/itkMorphologicalWatershedImageFilter.hxx
+++ b/Modules/Segmentation/Watersheds/include/itkMorphologicalWatershedImageFilter.hxx
@@ -28,48 +28,41 @@
 namespace itk
 {
 
-template< typename TInputImage, typename TOutputImage >
-MorphologicalWatershedImageFilter< TInputImage, TOutputImage >
-::MorphologicalWatershedImageFilter():
-  m_FullyConnected( false ),
-  m_MarkWatershedLine( true ),
-  m_Level( NumericTraits< InputImagePixelType >::ZeroValue() )
-{
-}
+template <typename TInputImage, typename TOutputImage>
+MorphologicalWatershedImageFilter<TInputImage, TOutputImage>::MorphologicalWatershedImageFilter()
+  : m_Level(NumericTraits<InputImagePixelType>::ZeroValue())
+{}
 
 
-template< typename TInputImage, typename TOutputImage >
+template <typename TInputImage, typename TOutputImage>
 void
-MorphologicalWatershedImageFilter< TInputImage, TOutputImage >
-::GenerateInputRequestedRegion()
+MorphologicalWatershedImageFilter<TInputImage, TOutputImage>::GenerateInputRequestedRegion()
 {
   // call the superclass' implementation of this method
   Superclass::GenerateInputRequestedRegion();
 
   // We need all the input.
-  InputImageType * input = const_cast< InputImageType * >( this->GetInput() );
-  if ( !input )
-    {
+  auto * input = const_cast<InputImageType *>(this->GetInput());
+  if (!input)
+  {
     return;
-    }
-  input->SetRequestedRegion( input->GetLargestPossibleRegion() );
+  }
+  input->SetRequestedRegion(input->GetLargestPossibleRegion());
 }
 
 
-template< typename TInputImage, typename TOutputImage >
+template <typename TInputImage, typename TOutputImage>
 void
-MorphologicalWatershedImageFilter< TInputImage, TOutputImage >
-::EnlargeOutputRequestedRegion(DataObject *)
+MorphologicalWatershedImageFilter<TInputImage, TOutputImage>::EnlargeOutputRequestedRegion(DataObject *)
 {
   OutputImageType * output = this->GetOutput();
-  output->SetRequestedRegion( output->GetLargestPossibleRegion() );
+  output->SetRequestedRegion(output->GetLargestPossibleRegion());
 }
 
 
-template< typename TInputImage, typename TOutputImage >
+template <typename TInputImage, typename TOutputImage>
 void
-MorphologicalWatershedImageFilter< TInputImage, TOutputImage >
-::GenerateData()
+MorphologicalWatershedImageFilter<TInputImage, TOutputImage>::GenerateData()
 {
   // Create a process accumulator for tracking the progress of this minipipeline
   ProgressAccumulator::Pointer progress = ProgressAccumulator::New();
@@ -82,83 +75,78 @@ MorphologicalWatershedImageFilter< TInputImage, TOutputImage >
   const InputImageType * input = this->GetInput();
 
   // h-minima filter to remove the smallest minima
-  typedef HMinimaImageFilter< TInputImage, TInputImage > HMinimaType;
+  using HMinimaType = HMinimaImageFilter<TInputImage, TInputImage>;
   typename HMinimaType::Pointer hmin;
 
   // Delegate to a R-Min filter to find the regional minima
-  typedef RegionalMinimaImageFilter< TInputImage, TOutputImage > RMinType;
+  using RMinType = RegionalMinimaImageFilter<TInputImage, TOutputImage>;
   typename RMinType::Pointer rmin = RMinType::New();
-  rmin->SetInput( input );
+  rmin->SetInput(input);
   rmin->SetFullyConnected(m_FullyConnected);
-  rmin->SetBackgroundValue(NumericTraits< OutputImagePixelType >::ZeroValue());
-  rmin->SetForegroundValue( NumericTraits< OutputImagePixelType >::max() );
+  rmin->SetBackgroundValue(NumericTraits<OutputImagePixelType>::ZeroValue());
+  rmin->SetForegroundValue(NumericTraits<OutputImagePixelType>::max());
 
   // label the components
-  typedef ConnectedComponentImageFilter< TOutputImage, TOutputImage >
-  ConnectedCompType;
+  using ConnectedCompType = ConnectedComponentImageFilter<TOutputImage, TOutputImage>;
   typename ConnectedCompType::Pointer label = ConnectedCompType::New();
   label->SetFullyConnected(m_FullyConnected);
-  label->SetInput( rmin->GetOutput() );
+  label->SetInput(rmin->GetOutput());
 
   // the watershed
-  typedef
-  MorphologicalWatershedFromMarkersImageFilter< TInputImage, TOutputImage >
-  WatershedType;
-  typename WatershedType::Pointer wshed = WatershedType::New();
-  wshed->SetInput( input );
-  wshed->SetMarkerImage( label->GetOutput() );
+  typedef MorphologicalWatershedFromMarkersImageFilter<TInputImage, TOutputImage> WatershedType;
+  typename WatershedType::Pointer                                                 wshed = WatershedType::New();
+  wshed->SetInput(input);
+  wshed->SetMarkerImage(label->GetOutput());
   wshed->SetFullyConnected(m_FullyConnected);
   wshed->SetMarkWatershedLine(m_MarkWatershedLine);
 
-  if ( m_Level != NumericTraits< InputImagePixelType >::ZeroValue() )
-    {
+  if (m_Level != NumericTraits<InputImagePixelType>::ZeroValue())
+  {
     // insert a h-minima filter to remove the smallest minima
     //
     hmin = HMinimaType::New();
-    hmin->SetInput( input );
+    hmin->SetInput(input);
     hmin->SetHeight(m_Level);
     hmin->SetFullyConnected(m_FullyConnected);
     // replace the input of the r-min filter
-    rmin->SetInput( hmin->GetOutput() );
+    rmin->SetInput(hmin->GetOutput());
 
     progress->RegisterInternalFilter(hmin, 0.4f);
     progress->RegisterInternalFilter(rmin, 0.1f);
     progress->RegisterInternalFilter(label, .2f);
     progress->RegisterInternalFilter(wshed, .3f);
-    }
+  }
   else
-    {
+  {
     // don't insert the h-minima to save some ressources
     progress->RegisterInternalFilter(rmin, 0.167f);
     progress->RegisterInternalFilter(label, .333f);
     progress->RegisterInternalFilter(wshed, .5f);
-    }
+  }
 
   // run the algorithm
   // graft our output to the watershed filter to force the proper regions
   // to be generated
-  wshed->GraftOutput( this->GetOutput() );
+  wshed->GraftOutput(this->GetOutput());
 
   wshed->Update();
 
   // graft the output of the watershed filter back onto this filter's
   // output. this is needed to get the appropriate regions passed
   // back.
-  this->GraftOutput( wshed->GetOutput() );
+  this->GraftOutput(wshed->GetOutput());
 }
 
 
-template< typename TInputImage, typename TOutputImage >
+template <typename TInputImage, typename TOutputImage>
 void
-MorphologicalWatershedImageFilter< TInputImage, TOutputImage >
-::PrintSelf(std::ostream & os, Indent indent) const
+MorphologicalWatershedImageFilter<TInputImage, TOutputImage>::PrintSelf(std::ostream & os, Indent indent) const
 {
   Superclass::PrintSelf(os, indent);
 
-  os << indent << "FullyConnected: "  << m_FullyConnected << std::endl;
-  os << indent << "MarkWatershedLine: "  << m_MarkWatershedLine << std::endl;
-  os << indent << "Level: "
-     << static_cast< typename NumericTraits< InputImagePixelType >::PrintType >( m_Level )
+  os << indent << "FullyConnected: " << m_FullyConnected << std::endl;
+  os << indent << "MarkWatershedLine: " << m_MarkWatershedLine << std::endl;
+  os << indent << "Level: " << static_cast<typename NumericTraits<InputImagePixelType>::PrintType>(m_Level)
      << std::endl;
 }
 
diff --git a/Modules/Segmentation/Watersheds/include/itkOneWayEquivalencyTable.h b/Modules/Segmentation/Watersheds/include/itkOneWayEquivalencyTable.h
index bcf8db7f83..1d97fc5ce9 100644
--- a/Modules/Segmentation/Watersheds/include/itkOneWayEquivalencyTable.h
+++ b/Modules/Segmentation/Watersheds/include/itkOneWayEquivalencyTable.h
@@ -20,7 +20,7 @@
 
 
 #include "itkProcessObject.h"
-#include "itksys/hash_map.hxx"
+#include <unordered_map>
 #include "ITKWatershedsExport.h"
 
 namespace itk
@@ -43,93 +43,127 @@ namespace itk
  * \sa EquivalencyTable
  * \ingroup ITKWatersheds
  */
-class ITKWatersheds_EXPORT OneWayEquivalencyTable:public DataObject
+class ITKWatersheds_EXPORT OneWayEquivalencyTable : public DataObject
 {
 public:
-  /**  Standard typedefs and smart pointer declarations.   */
-  typedef OneWayEquivalencyTable     Self;
-  typedef DataObject                 Superclass;
-  typedef SmartPointer< Self >       Pointer;
-  typedef SmartPointer< const Self > ConstPointer;
+  ITK_DISALLOW_COPY_AND_ASSIGN(OneWayEquivalencyTable);
+
+  /**  Standard type alias and smart pointer declarations.   */
+  using Self = OneWayEquivalencyTable;
+  using Superclass = DataObject;
+  using Pointer = SmartPointer<Self>;
+  using ConstPointer = SmartPointer<const Self>;
   itkNewMacro(Self);
   itkTypeMacro(OneWayEquivalencyTable, DataObject);
 
   /** Define the container type for this table */
-  typedef itksys::hash_map< unsigned long, unsigned long,
-                            itksys::hash< unsigned long > > HashTableType;
+  using HashTableType = std::unordered_map<unsigned long, unsigned long>;
 
-  typedef HashTableType::iterator       Iterator;
-  typedef HashTableType::const_iterator ConstIterator;
-  typedef HashTableType::value_type     ValueType;
+  using Iterator = HashTableType::iterator;
+  using ConstIterator = HashTableType::const_iterator;
+  using ValueType = HashTableType::value_type;
 
   /** "Flattens" the equivalency table by eliminating all redundant
    * and recursive equivalencies.  I.e. the set { 2=1; 3=2; 4=3 } is
    * converted to {4=1; 3=1; 2=1}.  */
-  void Flatten();
+  void
+  Flatten();
 
   /** Insert an equivalency into the table.  A return value of TRUE
-  * indicates that the equivalency did not previously exist in the
-  * table and was successfully added.  A FALSE return value indicates
-  * that the equivalency was not added to the table because a conflict
-  * with an existing entry occurred (most likely, the equivalency was
-  * already recorded directly or indirectly).
-  */
-  bool Add(unsigned long a, unsigned long b);
+   * indicates that the equivalency did not previously exist in the
+   * table and was successfully added.  A FALSE return value indicates
+   * that the equivalency was not added to the table because a conflict
+   * with an existing entry occurred (most likely, the equivalency was
+   * already recorded directly or indirectly).
+   */
+  bool
+  Add(unsigned long a, unsigned long b);
 
   /** Lookup an equivalency in the table.  If no entry is found in the
    * table, the method returns its the value of the argument.  Does
    * not recursively descent through equivalencies.  */
-  unsigned long Lookup(const unsigned long a) const
+  unsigned long
+  Lookup(const unsigned long a) const
   {
     ConstIterator result = m_HashMap.find(a);
 
-    if ( result == m_HashMap.end() ) { return a; }
-    else { return ( *result ).second; }
+    if (result == m_HashMap.end())
+    {
+      return a;
+    }
+    else
+    {
+      return (*result).second;
+    }
   }
 
   /** Lookup an equivalency in the table by recursing through all
    * successive equivalencies.  For example, if the follow entries
    * exist in the table {8=7, 7=6, 6=5}, then RecursiveLookup(8)
    * returns 5.  */
-  unsigned long RecursiveLookup(const unsigned long a) const;
+  unsigned long
+  RecursiveLookup(const unsigned long a) const;
 
   /** Returns TRUE if the label is found in the table and FALSE is the
    * label is not found in the table.  */
-  bool IsEntry(const unsigned long a) const
+  bool
+  IsEntry(const unsigned long a) const
   {
-    if ( m_HashMap.find(a) == m_HashMap.end() ) { return false; }
-    else { return true; }
+    if (m_HashMap.find(a) == m_HashMap.end())
+    {
+      return false;
+    }
+    else
+    {
+      return true;
+    }
   }
 
   /**  Erases the entry with key a.   */
-  void Erase(const unsigned long a)
-  {  m_HashMap.erase(a); }
+  void
+  Erase(const unsigned long a)
+  {
+    m_HashMap.erase(a);
+  }
 
   /** Erases all the entries in the table.   */
-  void Clear()
-  {      m_HashMap.clear();    }
+  void
+  Clear()
+  {
+    m_HashMap.clear();
+  }
 
   /** Returns TRUE if the table is empty, FALSE if it is not empty.   */
-  bool Empty() const
-  {      return m_HashMap.empty();    }
+  bool
+  Empty() const
+  {
+    return m_HashMap.empty();
+  }
 
   /** Returns an iterator pointing to the first element of the (unordered)
       table.    */
-  Iterator Begin() { return m_HashMap.begin(); }
+  Iterator
+  Begin()
+  {
+    return m_HashMap.begin();
+  }
 
   /** Returns and iterator pointing to one position past the last
    * element of the (unordered) table.  */
-  Iterator End()   { return m_HashMap.end();   }
+  Iterator
+  End()
+  {
+    return m_HashMap.end();
+  }
 
   /** Convenience method for debugging.   */
   //  void PrintHashTable();
 
 protected:
-  OneWayEquivalencyTable()  {}
-  ~OneWayEquivalencyTable() ITK_OVERRIDE {}
-  ITK_DISALLOW_COPY_AND_ASSIGN(OneWayEquivalencyTable);
-
-  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
+  OneWayEquivalencyTable() = default;
+  ~OneWayEquivalencyTable() override = default;
+  void
+  PrintSelf(std::ostream & os, Indent indent) const override;
 
   HashTableType m_HashMap;
 };
diff --git a/Modules/Segmentation/Watersheds/include/itkTobogganImageFilter.h b/Modules/Segmentation/Watersheds/include/itkTobogganImageFilter.h
index 026db2c32f..2c7879f856 100644
--- a/Modules/Segmentation/Watersheds/include/itkTobogganImageFilter.h
+++ b/Modules/Segmentation/Watersheds/include/itkTobogganImageFilter.h
@@ -35,50 +35,52 @@ namespace itk
  * \ingroup ITKWatersheds
  */
 
-template< typename TInputImage >
-class ITK_TEMPLATE_EXPORT TobogganImageFilter:
-  public ImageToImageFilter<
-    TInputImage,
-    Image< IdentifierType, TInputImage::ImageDimension > >
+template <typename TInputImage, typename TOutputImage = Image<IdentifierType, TInputImage::ImageDimension>>
+class ITK_TEMPLATE_EXPORT TobogganImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
 {
 public:
-  /** Standard "Self" typedef.   */
-  typedef TobogganImageFilter Self;
+  ITK_DISALLOW_COPY_AND_ASSIGN(TobogganImageFilter);
+
+  /** Standard "Self" type alias.   */
+  using Self = TobogganImageFilter;
 
   /** The type of input image.   */
-  typedef TInputImage InputImageType;
+  using InputImageType = TInputImage;
 
   /** Number of dimensions. */
-  itkStaticConstMacro(NDimensions, unsigned int, TInputImage::ImageDimension);
+  static constexpr unsigned int NDimensions = TInputImage::ImageDimension;
 
   /** The type of output image.   */
-  typedef Image< IdentifierType, itkGetStaticConstMacro(NDimensions) > OutputImageType;
+  using OutputImageType = TOutputImage;
 
   /** Output image pixel type. */
-  typedef typename OutputImageType::PixelType OutputImagePixelType;
+  using OutputImagePixelType = typename OutputImageType::PixelType;
 
   /** Input image pixel type. */
-  typedef typename InputImageType::PixelType InputImagePixelType;
+  using InputImagePixelType = typename InputImageType::PixelType;
 
   /** Dimension of the input and output images. */
-  enum { ImageDimension = InputImageType::ImageDimension };
-
-  /** Other convenient typedefs   */
-  typedef typename InputImageType::RegionType   RegionType;
-  typedef typename InputImageType::SizeType     SizeType;
-  typedef typename InputImageType::IndexType    IndexType;
-  typedef typename InputImageType::Pointer      InputImagePointer;
-  typedef typename InputImageType::ConstPointer InputImageConstPointer;
-  typedef typename OutputImageType::Pointer     OutputImagePointer;
-
-  /** Standard super class typedef support. */
-  typedef ImageToImageFilter< InputImageType, OutputImageType > Superclass;
+  enum
+  {
+    ImageDimension = InputImageType::ImageDimension
+  };
+
+  /** Other convenient type alias   */
+  using RegionType = typename InputImageType::RegionType;
+  using SizeType = typename InputImageType::SizeType;
+  using IndexType = typename InputImageType::IndexType;
+  using InputImagePointer = typename InputImageType::Pointer;
+  using InputImageConstPointer = typename InputImageType::ConstPointer;
+  using OutputImagePointer = typename OutputImageType::Pointer;
+
+  /** Standard super class type alias support */
+  using Superclass = ImageToImageFilter<InputImageType, OutputImageType>;
 
   /** Typedef support for the input image scalar value type. */
-  typedef typename InputImageType::PixelType ScalarType;
+  using ScalarType = typename InputImageType::PixelType;
 
-  /** Smart pointer typedef support  */
-  typedef SmartPointer< Self > Pointer;
+  /** Smart pointer type alias support  */
+  using Pointer = SmartPointer<Self>;
 
   /** Run-time type information (and related methods) */
   itkTypeMacro(TobogganImageFilter, ImageToImageFilter);
@@ -87,37 +89,35 @@ public:
   itkNewMacro(Self);
 
   /** Standard process object method.  This filter is not multithreaded. */
-  void GenerateData() ITK_OVERRIDE;
+  void
+  GenerateData() override;
 
-  void GenerateInputRequestedRegion() ITK_OVERRIDE;
+  void
+  GenerateInputRequestedRegion() override;
 
-  void EnlargeOutputRequestedRegion(DataObject *) ITK_OVERRIDE;
+  void
+  EnlargeOutputRequestedRegion(DataObject *) override;
 
   /** Neighborhood iterator type */
-  typedef ConstNeighborhoodIterator< TInputImage >
-  NeighborhoodIteratorType;
+  using NeighborhoodIteratorType = ConstNeighborhoodIterator<Image<float, 2>>;
 
 #ifdef ITK_USE_CONCEPT_CHECKING
   // Begin concept checking
-  itkConceptMacro( LessThanComparableCheck,
-                   ( Concept::LessThanComparable< InputImagePixelType > ) );
-  itkConceptMacro( OStreamWritableCheck,
-                   ( Concept::OStreamWritable< InputImagePixelType > ) );
+  itkConceptMacro(LessThanComparableCheck, (Concept::LessThanComparable<InputImagePixelType>));
+  itkConceptMacro(OStreamWritableCheck, (Concept::OStreamWritable<InputImagePixelType>));
   // End concept checking
 #endif
 
 protected:
-  TobogganImageFilter();
-  ~TobogganImageFilter() ITK_OVERRIDE {}
-  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
-
-private:
-  ITK_DISALLOW_COPY_AND_ASSIGN(TobogganImageFilter);
-};                                   // end of class
+  TobogganImageFilter() = default;
+  ~TobogganImageFilter() override = default;
+  void
+  PrintSelf(std::ostream & os, Indent indent) const override;
+}; // end of class
 } // end namespace itk
 
 #ifndef ITK_MANUAL_INSTANTIATION
-#include "itkTobogganImageFilter.hxx"
+#  include "itkTobogganImageFilter.hxx"
 #endif
 
 #endif
diff --git a/Modules/Segmentation/Watersheds/include/itkTobogganImageFilter.hxx b/Modules/Segmentation/Watersheds/include/itkTobogganImageFilter.hxx
index 789c319f87..f670afda5b 100644
--- a/Modules/Segmentation/Watersheds/include/itkTobogganImageFilter.hxx
+++ b/Modules/Segmentation/Watersheds/include/itkTobogganImageFilter.hxx
@@ -23,75 +23,66 @@
 
 namespace itk
 {
-template< typename TInputImage >
-TobogganImageFilter< TInputImage >
-::TobogganImageFilter()
-{}
 
-template< typename TInputImage >
+template <typename TInputImage, typename TOutputImage>
 void
-TobogganImageFilter< TInputImage >
-::GenerateInputRequestedRegion()
+TobogganImageFilter<TInputImage, TOutputImage>::GenerateInputRequestedRegion()
 {
   Superclass::GenerateInputRequestedRegion();
-  if ( this->GetInput() )
-    {
-    InputImagePointer image =
-      const_cast< typename Superclass::InputImageType * >( this->GetInput() );
+  if (this->GetInput())
+  {
+    InputImagePointer image = const_cast<typename Superclass::InputImageType *>(this->GetInput());
     image->SetRequestedRegionToLargestPossibleRegion();
-    }
+  }
 }
 
-template< typename TInputImage >
+template <typename TInputImage, typename TOutputImage>
 void
-TobogganImageFilter< TInputImage >
-::EnlargeOutputRequestedRegion(DataObject *data)
+TobogganImageFilter<TInputImage, TOutputImage>::EnlargeOutputRequestedRegion(DataObject * data)
 {
   Superclass::EnlargeOutputRequestedRegion(data);
   data->SetRequestedRegionToLargestPossibleRegion();
 }
 
-template< typename TInputImage >
+template <typename TInputImage, typename TOutputImage>
 void
-TobogganImageFilter< TInputImage >
-::PrintSelf(std::ostream & os, Indent indent) const
+TobogganImageFilter<TInputImage, TOutputImage>::PrintSelf(std::ostream & os, Indent indent) const
 {
   Superclass::PrintSelf(os, indent);
 }
 
-template< typename TInputImage >
+template <typename TInputImage, typename TOutputImage>
 void
-TobogganImageFilter< TInputImage >
-::GenerateData()
+TobogganImageFilter<TInputImage, TOutputImage>::GenerateData()
 {
-  InputImageConstPointer inputImage  = static_cast< InputImageConstPointer >( this->GetInput() );
-  OutputImagePointer     outputImage = this->GetOutput();
+  auto               inputImage = static_cast<InputImageConstPointer>(this->GetInput());
+  OutputImagePointer outputImage = this->GetOutput();
 
-  OutputImagePixelType z = NumericTraits< OutputImagePixelType >::ZeroValue();
-  OutputImagePixelType CurrentLabel = NumericTraits< OutputImagePixelType >::ZeroValue();
+  OutputImagePixelType z = NumericTraits<OutputImagePixelType>::ZeroValue();
+  OutputImagePixelType CurrentLabel = NumericTraits<OutputImagePixelType>::ZeroValue();
 
   CurrentLabel += 2;
 
   // Zero the output
-  outputImage->SetBufferedRegion( outputImage->GetRequestedRegion() );
+  outputImage->SetBufferedRegion(outputImage->GetRequestedRegion());
   outputImage->Allocate();
-  outputImage->FillBuffer (z);
+  outputImage->FillBuffer(z);
 
-  typedef ImageRegionConstIterator< InputImageType >  InputIterator;
-  typedef ImageRegionConstIterator< OutputImageType > OutputIterator;
+  using InputIterator = ImageRegionConstIterator<InputImageType>;
+  using OutputIterator = ImageRegionConstIterator<OutputImageType>;
 
-  InputIterator  inIt( inputImage, inputImage->GetRequestedRegion() );
-  OutputIterator outIt( outputImage, outputImage->GetRequestedRegion() );
+  InputIterator  inIt(inputImage, inputImage->GetRequestedRegion());
+  OutputIterator outIt(outputImage, outputImage->GetRequestedRegion());
 
   // Walk through the image
-  while ( !inIt.IsAtEnd() )
-    {
+  while (!inIt.IsAtEnd())
+  {
     // If we find an unlabeled pixel, start labeling
-    if ( outIt.Get() == z )
-      {
+    if (outIt.Get() == z)
+    {
       // Start labeling
-      std::vector< IndexType > Visited;
-      InputImagePixelType      MinimumNeighborValue = inIt.Get();
+      std::vector<IndexType> Visited;
+      InputImagePixelType    MinimumNeighborValue = inIt.Get();
 
       OutputImagePixelType MinimumNeighborClass;
       OutputImagePixelType LabelForRegion = CurrentLabel;
@@ -105,26 +96,25 @@ TobogganImageFilter< TInputImage >
       CurrentPositionIndex = outIt.GetIndex();
       // This is the first pixel we've visited
       Visited.clear();
-      Visited.push_back (CurrentPositionIndex);
-      itkDebugMacro (<< "Found unlabeled pixel at: " << CurrentPositionIndex
-                     << " Value: " << MinimumNeighborValue);
+      Visited.push_back(CurrentPositionIndex);
+      itkDebugMacro(<< "Found unlabeled pixel at: " << CurrentPositionIndex << " Value: " << MinimumNeighborValue);
       // Search along a steepest descent path to a local minimum
       do
-        {
+      {
         // We've touched this pixel
-        outputImage->SetPixel (CurrentPositionIndex, 1);
+        outputImage->SetPixel(CurrentPositionIndex, 1);
         MinimumNeighborIndex = CurrentPositionIndex;
         // DirectionImage->PutPixel ( CurrentPositionIndex, 1 );
         // Check the face connected neighbors
-        for ( Dimension = 0; Dimension < ImageDimension; Dimension++ )
+        for (Dimension = 0; Dimension < ImageDimension; Dimension++)
+        {
+          for (t = 1; t >= -1; t = t - 2)
           {
-          for ( t = 1; t >= -1; t = t - 2 )
-            {
             IndexType NeighborIndex;
             NeighborIndex = CurrentPositionIndex;
             NeighborIndex[Dimension] += t;
-            if ( outputImage->GetRequestedRegion().IsInside (NeighborIndex) )
-              {
+            if (outputImage->GetRequestedRegion().IsInside(NeighborIndex))
+            {
               // This is a valid index to check
               // Possibilities:
               // If NeighborClass == 0  -> Not been checked yet, check it
@@ -133,46 +123,44 @@ TobogganImageFilter< TInputImage >
               // If NeighborClass > 1   -> Found a new neighbor, but only if
               // it's minimum
               OutputImagePixelType NeighborClass;
-              NeighborClass = outputImage->GetPixel (NeighborIndex);
+              NeighborClass = outputImage->GetPixel(NeighborIndex);
               // See if we've already touched it
-              if ( NeighborClass != 1 )
+              if (NeighborClass != 1)
+              {
+                InputImagePixelType NeighborValue = inputImage->GetPixel(NeighborIndex);
+                if (NeighborValue < MinimumNeighborValue)
                 {
-                InputImagePixelType NeighborValue = inputImage->GetPixel (NeighborIndex);
-                if ( NeighborValue < MinimumNeighborValue )
-                  {
-                  MinimumNeighborValue = inputImage->GetPixel (NeighborIndex);
+                  MinimumNeighborValue = inputImage->GetPixel(NeighborIndex);
                   MinimumNeighborIndex = NeighborIndex;
-                  }
                 }
               }
             }
           }
+        }
         FoundMinimum = false;
-        if ( MinimumNeighborIndex != CurrentPositionIndex )
-          {
+        if (MinimumNeighborIndex != CurrentPositionIndex)
+        {
           // Add the neighbor to the Visited list
-          Visited.push_back (MinimumNeighborIndex);
+          Visited.push_back(MinimumNeighborIndex);
           CurrentPositionIndex = MinimumNeighborIndex;
-          }
+        }
         else
-          {
+        {
           FoundMinimum = true;
-          }
+        }
         // Get the true class of this pixel
-        MinimumNeighborClass = outputImage->GetPixel (MinimumNeighborIndex);
-        itkDebugMacro(<< "\tFound Neighbor at: " << MinimumNeighborIndex
-                      << " Value: " << MinimumNeighborValue
+        MinimumNeighborClass = outputImage->GetPixel(MinimumNeighborIndex);
+        itkDebugMacro(<< "\tFound Neighbor at: " << MinimumNeighborIndex << " Value: " << MinimumNeighborValue
                       << " Class: " << MinimumNeighborClass);
         // we've slid into a different class
-        if ( MinimumNeighborClass > 1 )
-          {
+        if (MinimumNeighborClass > 1)
+        {
           FoundMinimum = true;
-          }
         }
-      while ( !FoundMinimum );
+      } while (!FoundMinimum);
 
-      if ( MinimumNeighborClass == 1 )
-        {
+      if (MinimumNeighborClass == 1)
+      {
         // We need to flood fill from the last position we found
         // stored in CurrentPositionIndex.  Connect any pixels
         // having the same value as the minimum we found.
@@ -182,80 +170,78 @@ TobogganImageFilter< TInputImage >
         //   NeighborClass == LabelForRegion -> OK, just ignore
         //   otherwise, we have a problem
 
-        std::vector< IndexType > OpenList;
+        std::vector<IndexType> OpenList;
         OpenList.clear();
-        OpenList.push_back (CurrentPositionIndex);
-        itkDebugMacro (<< "\tFinished slide at: " << CurrentPositionIndex
-                       << " Value: " << MinimumNeighborValue
-                       << " Class: " << MinimumNeighborClass);
-        while ( OpenList.size() )
-          {
+        OpenList.push_back(CurrentPositionIndex);
+        itkDebugMacro(<< "\tFinished slide at: " << CurrentPositionIndex << " Value: " << MinimumNeighborValue
+                      << " Class: " << MinimumNeighborClass);
+        while (!OpenList.empty())
+        {
           // Pop the last one off
           IndexType SeedIndex = OpenList.back();
           OpenList.pop_back();
-          Visited.push_back (SeedIndex);
-          itkDebugMacro (<< "Flood fill, looking at " << SeedIndex);
+          Visited.push_back(SeedIndex);
+          itkDebugMacro(<< "Flood fill, looking at " << SeedIndex);
           // Look at the neighbors
           InputImagePixelType SeedValue;
-          SeedValue = inputImage->GetPixel (SeedIndex);
-          for ( Dimension = 0; Dimension < ImageDimension; Dimension++ )
+          SeedValue = inputImage->GetPixel(SeedIndex);
+          for (Dimension = 0; Dimension < ImageDimension; Dimension++)
+          {
+            for (t = -1; t <= 1; t = t + 2)
             {
-            for ( t = -1; t <= 1; t = t + 2 )
-              {
               IndexType NeighborIndex;
               NeighborIndex = SeedIndex;
               NeighborIndex[Dimension] += t;
-              if ( outputImage->GetRequestedRegion().IsInside (NeighborIndex) )
+              if (outputImage->GetRequestedRegion().IsInside(NeighborIndex))
+              {
+                if (inputImage->GetPixel(NeighborIndex) <= SeedValue)
                 {
-                if ( inputImage->GetPixel (NeighborIndex) <= SeedValue )
-                  {
                   // Found a match, check it's class
-                  OutputImagePixelType NeighborClass = outputImage->GetPixel (NeighborIndex);
+                  OutputImagePixelType NeighborClass = outputImage->GetPixel(NeighborIndex);
                   // We've never seen this pixel before, so add it to the open
                   // list
-                  if ( NeighborClass == z )
-                    {
+                  if (NeighborClass == z)
+                  {
                     // Add it to the open list
-                    OpenList.push_back (NeighborIndex);
-                    outputImage->SetPixel (NeighborIndex, 1);
-                    }
-                  if ( NeighborClass > 1 )
-                    {
+                    OpenList.push_back(NeighborIndex);
+                    outputImage->SetPixel(NeighborIndex, 1);
+                  }
+                  if (NeighborClass > 1)
+                  {
                     MinimumNeighborClass = NeighborClass;
-                    }
                   }
                 }
               }
             }
           }
         }
+      }
 
       // The minimum neighbor class will always be >= 1
-      if ( MinimumNeighborClass == 1 )
-        {
+      if (MinimumNeighborClass == 1)
+      {
         // If we found an unlabeled minimum,
         // Set the LabelForRegion, and increment CurrentLabel
         LabelForRegion = CurrentLabel;
         CurrentLabel++;
-        }
-      if ( MinimumNeighborClass > 1 )
-        {
+      }
+      if (MinimumNeighborClass > 1)
+      {
         // We bumped into another region, equivalent to finding the minimum
         LabelForRegion = MinimumNeighborClass;
         CurrentPositionIndex = MinimumNeighborIndex;
-        }
-      itkDebugMacro (<< "Filling in: " << static_cast< unsigned int >( Visited.size() )
-                     << " with: " << LabelForRegion);
+      }
+      itkDebugMacro(<< "Filling in: " << static_cast<unsigned int>(Visited.size()) << " with: " << LabelForRegion);
       // Loop over all the visited positions, setting their label
-      for ( i = 0; i < Visited.size(); i++ )
-        {
-        outputImage->SetPixel (Visited[i], LabelForRegion);
-        }
+      for (i = 0; i < Visited.size(); i++)
+      {
+        outputImage->SetPixel(Visited[i], LabelForRegion);
       }
+    }
     // On to the next pixel
     ++inIt;
     ++outIt;
-    }
+  }
 }
 } // end namespace itk
 
diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedBoundary.h b/Modules/Segmentation/Watersheds/include/itkWatershedBoundary.h
index 9774817414..32a94151c0 100644
--- a/Modules/Segmentation/Watersheds/include/itkWatershedBoundary.h
+++ b/Modules/Segmentation/Watersheds/include/itkWatershedBoundary.h
@@ -23,7 +23,7 @@
 #include <vector>
 #include "itkImage.h"
 #include "itkProcessObject.h"
-#include "itksys/hash_map.hxx"
+#include <unordered_map>
 
 namespace itk
 {
@@ -50,27 +50,28 @@ namespace watershed
  * \ingroup WatershedSegmentation
  * \ingroup ITKWatersheds
  */
-template< typename TScalar, unsigned int TDimension >
-class ITK_TEMPLATE_EXPORT Boundary:public DataObject
+template <typename TScalar, unsigned int TDimension>
+class ITK_TEMPLATE_EXPORT Boundary : public DataObject
 {
 public:
   /** The dimensionality of this boundary.  For example, if the boundary
    * of a set of planes, it has dimensionality 2.  If the boundary is
    * a set of lines, it has dimensionality 1.  Dimensionality is one less
    * than the image chunks from which the boundary is derived.   */
-  itkStaticConstMacro(Dimension, unsigned int, TDimension);
+  static constexpr unsigned int Dimension = TDimension;
 
   /** A pair of values used to index into the boundary data structure.
    * The IndexType.first is the dimension of the face and IndexType.second is a
    * binary value 0 or 1 indicating the LOW face or the HIGH face,
    * respectively.    */
-  typedef std::pair< unsigned, unsigned >     IndexType;
-  typedef Image< IdentifierType, TDimension > ImageType;
-  typedef typename ImageType::IndexType       ImageIndexType;
-  typedef TScalar                             ScalarType;
+  using IndexType = std::pair<unsigned, unsigned>;
+  using ImageType = Image<IdentifierType, TDimension>;
+  using ImageIndexType = typename ImageType::IndexType;
+  using ScalarType = TScalar;
 
   /** Data type stored at each pixel in a face.   */
-  struct face_pixel_t {
+  struct face_pixel_t
+  {
     /**Index of the direction of watershed flow through this pixel.
      * A negative value indicates that the flow does not move out
      * of the region.  A positive value is the index into the
@@ -92,11 +93,12 @@ public:
   };
 
   /**    */
-  struct flat_region_t {
+  struct flat_region_t
+  {
     /** Indices into the associated Face containing boundary pixels.  These
      * give access to spatial information, label and flow associated with
      * this boundary pixel connection.     */
-    std::list< IdentifierType > offset_list;
+    std::list<IdentifierType> offset_list;
 
     /** The value of the lowest point (indicating the steepest descent) along
      * the boundary of the flat region of which this pixel is a member.     */
@@ -112,64 +114,102 @@ public:
 
   /** The face data structure.  This is just an Image of face pixel
       types. */
-  typedef Image< face_pixel_t, TDimension > face_t;
+  using face_t = Image<face_pixel_t, TDimension>;
 
   /** A hash table holding flat region data structures.   */
-  typedef itksys::hash_map< IdentifierType, flat_region_t,
-                            itksys::hash< IdentifierType > > flat_hash_t;
-  typedef typename flat_hash_t::value_type                   FlatHashValueType;
+  using flat_hash_t = std::unordered_map<IdentifierType, flat_region_t>;
+  using FlatHashValueType = typename flat_hash_t::value_type;
 
-  /** Itk typedefs and macros defining smart pointer and type identification.
+  /** Itk type alias and macros defining smart pointer and type identification.
    */
-  typedef Boundary                   Self;
-  typedef DataObject                 Superclass;
-  typedef SmartPointer< Self >       Pointer;
-  typedef SmartPointer< const Self > ConstPointer;
+  using Self = Boundary;
+  using Superclass = DataObject;
+  using Pointer = SmartPointer<Self>;
+  using ConstPointer = SmartPointer<const Self>;
   itkNewMacro(Self);
   itkTypeMacro(WatershedBoundary, DataObject);
 
   /** The following averts an internal compiler error on microsoft compilers */
-  typedef typename face_t::Pointer FacePointer;
+  using FacePointer = typename face_t::Pointer;
 
   /** Returns the face at the specified index  */
-  FacePointer GetFace(const IndexType & idx)
-  {      return this->GetFace(idx.first, idx.second);    }
+  FacePointer
+  GetFace(const IndexType & idx)
+  {
+    return this->GetFace(idx.first, idx.second);
+  }
 
   /** Returns the face at the specified index, where dimension is
    * the number of the axial dimension and highlow is 0 for the LOW
    * face and 1 for the HIGH face.   */
-  FacePointer GetFace(unsigned dimension, unsigned highlow)
+  FacePointer
+  GetFace(unsigned dimension, unsigned highlow)
   {
-    if ( highlow == 0 ) { return m_Faces[dimension].first; }
-    else { return m_Faces[dimension].second; }
+    if (highlow == 0)
+    {
+      return m_Faces[dimension].first;
+    }
+    else
+    {
+      return m_Faces[dimension].second;
+    }
   }
 
-  void SetFace(FacePointer f, const IndexType & idx)
-  { this->SetFace(f, idx.first, idx.second); }
+  void
+  SetFace(FacePointer f, const IndexType & idx)
+  {
+    this->SetFace(f, idx.first, idx.second);
+  }
 
-  void SetFace(FacePointer f, unsigned dimension, unsigned highlow)
+  void
+  SetFace(FacePointer f, unsigned dimension, unsigned highlow)
   {
-    if ( highlow == 0 ) { m_Faces[dimension].first = f; }
-    else { m_Faces[dimension].second = f; }
+    if (highlow == 0)
+    {
+      m_Faces[dimension].first = f;
+    }
+    else
+    {
+      m_Faces[dimension].second = f;
+    }
     this->Modified();
   }
 
   /** Get/Set the table of flat region connections specified by the index. */
-  flat_hash_t * GetFlatHash(const IndexType & idx)
-  { return this->GetFlatHash(idx.first, idx.second); }
-  flat_hash_t * GetFlatHash(unsigned dimension, unsigned highlow)
+  flat_hash_t *
+  GetFlatHash(const IndexType & idx)
+  {
+    return this->GetFlatHash(idx.first, idx.second);
+  }
+  flat_hash_t *
+  GetFlatHash(unsigned dimension, unsigned highlow)
   {
-    if ( highlow == 0 ) { return &( m_FlatHashes[dimension].first ); }
-    else { return &( m_FlatHashes[dimension].second ); }
+    if (highlow == 0)
+    {
+      return &(m_FlatHashes[dimension].first);
+    }
+    else
+    {
+      return &(m_FlatHashes[dimension].second);
+    }
   }
 
-  void SetFlatHash(flat_hash_t & l, const IndexType & idx)
-  { this->SetFlatHash(l, idx.first, idx.second); }
-  void SetFlatHash(flat_hash_t & l, unsigned dimension,
-                   unsigned highlow)
+  void
+  SetFlatHash(flat_hash_t & l, const IndexType & idx)
+  {
+    this->SetFlatHash(l, idx.first, idx.second);
+  }
+  void
+  SetFlatHash(flat_hash_t & l, unsigned dimension, unsigned highlow)
   {
-    if ( highlow == 0 ) { m_FlatHashes[dimension].first = l; }
-    else { m_FlatHashes[dimension].second = l; }
+    if (highlow == 0)
+    {
+      m_FlatHashes[dimension].first = l;
+    }
+    else
+    {
+      m_FlatHashes[dimension].second = l;
+    }
     this->Modified();
   }
 
@@ -177,47 +217,69 @@ public:
    * invalid (false).  A valid face is assumed to be initialized
    * and contain information.  No assumptions are made about an
    * invalid face.   */
-  void SetValid(bool & l, const IndexType & idx)
-  { this->SetValid(l, idx.first, idx.second); }
-  void SetValid(bool b, unsigned dimension,
-                unsigned highlow)
+  void
+  SetValid(bool & l, const IndexType & idx)
   {
-    if ( highlow == 0 ) { m_Valid[dimension].first = b; }
-    else { m_Valid[dimension].second = b; }
+    this->SetValid(l, idx.first, idx.second);
+  }
+  void
+  SetValid(bool b, unsigned dimension, unsigned highlow)
+  {
+    if (highlow == 0)
+    {
+      m_Valid[dimension].first = b;
+    }
+    else
+    {
+      m_Valid[dimension].second = b;
+    }
     this->Modified();
   }
 
-  bool GetValid(const IndexType & idx) const
-  { return this->GetValid(idx.first, idx.second); }
-  bool GetValid(unsigned dimension, unsigned highlow) const
+  bool
+  GetValid(const IndexType & idx) const
+  {
+    return this->GetValid(idx.first, idx.second);
+  }
+  bool
+  GetValid(unsigned dimension, unsigned highlow) const
   {
-    if ( highlow == 0 ) { return m_Valid[dimension].first; }
-    else { return m_Valid[dimension].second; }
+    if (highlow == 0)
+    {
+      return m_Valid[dimension].first;
+    }
+    else
+    {
+      return m_Valid[dimension].second;
+    }
   }
 
 protected:
   Boundary();
-  ~Boundary() ITK_OVERRIDE {}
+  ~Boundary() override = default;
   Boundary(const Self &) {}
-  void operator=(const Self &) {}
-  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
+  void
+  operator=(const Self &)
+  {}
+  void
+  PrintSelf(std::ostream & os, Indent indent) const override;
 
   /** The Nx2 matrix of faces of this boundary.   */
-  std::vector< std::pair< FacePointer, FacePointer > > m_Faces;
+  std::vector<std::pair<FacePointer, FacePointer>> m_Faces;
 
   /** The Nx2 matrix flat region connections associated with
    * this boundary.   */
-  std::vector< std::pair< flat_hash_t, flat_hash_t > > m_FlatHashes;
+  std::vector<std::pair<flat_hash_t, flat_hash_t>> m_FlatHashes;
 
   /** The Nx2 matrix of boolean flags indicating which faces contain
    * information.    */
-  std::vector< std::pair< bool, bool > > m_Valid;
+  std::vector<std::pair<bool, bool>> m_Valid;
 };
 } // end namespace watershed
 } // end namespace itk
 
 #ifndef ITK_MANUAL_INSTANTIATION
-#include "itkWatershedBoundary.hxx"
+#  include "itkWatershedBoundary.hxx"
 #endif
 
 #endif
diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedBoundary.hxx b/Modules/Segmentation/Watersheds/include/itkWatershedBoundary.hxx
index 84cb9daa19..45c4224dc2 100644
--- a/Modules/Segmentation/Watersheds/include/itkWatershedBoundary.hxx
+++ b/Modules/Segmentation/Watersheds/include/itkWatershedBoundary.hxx
@@ -26,21 +26,20 @@ namespace itk
 {
 namespace watershed
 {
-template< typename TScalar, unsigned int TDimension >
-Boundary< TScalar, TDimension >
-::Boundary()
+template <typename TScalar, unsigned int TDimension>
+Boundary<TScalar, TDimension>::Boundary()
 {
   unsigned int i;
   FacePointer  p;
   flat_hash_t  f;
 
-  std::pair< FacePointer, FacePointer > i_pair;
-  std::pair< flat_hash_t, flat_hash_t > c_pair;
-  std::pair< bool, bool >               v_pair;
+  std::pair<FacePointer, FacePointer> i_pair;
+  std::pair<flat_hash_t, flat_hash_t> c_pair;
+  std::pair<bool, bool>               v_pair;
 
   // Initialize all the members of the lists, etc.
-  for ( i = 0; i < Dimension; ++i )
-    {
+  for (i = 0; i < Dimension; ++i)
+  {
     p = face_t::New();
     i_pair.first = p;
     c_pair.first = flat_hash_t();
@@ -54,14 +53,15 @@ Boundary< TScalar, TDimension >
     m_Faces.push_back(i_pair);
     m_FlatHashes.push_back(c_pair);
     m_Valid.push_back(v_pair);
-    }
+  }
 }
 
-template< typename TScalar,  unsigned int TDimension >
+template <typename TScalar, unsigned int TDimension>
 void
-Boundary< TScalar, TDimension >
-::PrintSelf(std::ostream & os, Indent indent) const
-{  Superclass::PrintSelf(os, indent); }
+Boundary<TScalar, TDimension>::PrintSelf(std::ostream & os, Indent indent) const
+{
+  Superclass::PrintSelf(os, indent);
+}
 } // end namespace watershed
 } // end namespace itk
 #endif
diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedBoundaryResolver.h b/Modules/Segmentation/Watersheds/include/itkWatershedBoundaryResolver.h
index bca50e7ccf..c80be267c2 100644
--- a/Modules/Segmentation/Watersheds/include/itkWatershedBoundaryResolver.h
+++ b/Modules/Segmentation/Watersheds/include/itkWatershedBoundaryResolver.h
@@ -60,39 +60,51 @@ namespace watershed
  * \ingroup WatershedSegmentation
  * \ingroup ITKWatersheds
  */
-template< typename TPixelType, unsigned int TDimension >
-class ITK_TEMPLATE_EXPORT BoundaryResolver:public ProcessObject
+template <typename TPixelType, unsigned int TDimension>
+class ITK_TEMPLATE_EXPORT BoundaryResolver : public ProcessObject
 {
 public:
   /** Set up smart pointer and object factory definitions.   */
-  typedef BoundaryResolver           Self;
-  typedef ProcessObject              Superclass;
-  typedef SmartPointer< Self >       Pointer;
-  typedef SmartPointer< const Self > ConstPointer;
+  using Self = BoundaryResolver;
+  using Superclass = ProcessObject;
+  using Pointer = SmartPointer<Self>;
+  using ConstPointer = SmartPointer<const Self>;
   itkNewMacro(Self);
   itkTypeMacro(WatershedBoundaryResolver, ProcessObject);
 
   /** Expose the image dimension at run time. */
-  itkStaticConstMacro(ImageDimension, unsigned int, TDimension);
+  static constexpr unsigned int ImageDimension = TDimension;
 
-  /** Some convenient typedefs.   */
-  typedef TPixelType                                   PixelType;
-  typedef Boundary< PixelType, TDimension >            BoundaryType;
-  typedef EquivalencyTable                             EquivalencyTableType;
-  typedef Segmenter< Image< TPixelType, TDimension > > SegmenterType;
-  typedef DataObject::Pointer                          DataObjectPointer;
+  /** Some convenient type alias.   */
+  using PixelType = TPixelType;
+  using BoundaryType = Boundary<PixelType, TDimension>;
+  using EquivalencyTableType = EquivalencyTable;
+  using SegmenterType = Segmenter<Image<TPixelType, TDimension>>;
+  using DataObjectPointer = DataObject::Pointer;
 
   /** Set/Get the first of two boundaries that are to be resolved.   */
-  void SetBoundaryA(BoundaryType *bd)
-  { this->ProcessObject::SetNthInput(0, bd); }
-  typename BoundaryType::Pointer GetBoundaryA()
-  { return static_cast< BoundaryType * >( this->GetInput(0) );  }
+  void
+  SetBoundaryA(BoundaryType * bd)
+  {
+    this->ProcessObject::SetNthInput(0, bd);
+  }
+  typename BoundaryType::Pointer
+  GetBoundaryA()
+  {
+    return static_cast<BoundaryType *>(this->GetInput(0));
+  }
 
   /** Set/Get the second of two boundaries that are to be resolved.  */
-  void SetBoundaryB(BoundaryType *bd)
-  { this->ProcessObject::SetNthInput(1, bd); }
-  typename BoundaryType::Pointer GetBoundaryB()
-  { return static_cast< BoundaryType * >( this->GetInput(1) );  }
+  void
+  SetBoundaryB(BoundaryType * bd)
+  {
+    this->ProcessObject::SetNthInput(1, bd);
+  }
+  typename BoundaryType::Pointer
+  GetBoundaryB()
+  {
+    return static_cast<BoundaryType *>(this->GetInput(1));
+  }
 
   /**  Set/Get the face of the boundary object that we are going to
    *  resolve. */
@@ -102,45 +114,53 @@ public:
   /** This method sets/gets the equivalency table used to store equivalencies
    *  among segments that are generated from the boundary resolution
    *  algorithm.  */
-  void SetEquivalencyTable(EquivalencyTableType::Pointer a)
-  { this->ProcessObject::SetNthOutput( 0, a.GetPointer() ); }
-  EquivalencyTableType::Pointer GetEquivalencyTable()
+  void
+  SetEquivalencyTable(EquivalencyTableType::Pointer a)
   {
-    return static_cast< EquivalencyTableType * >
-           ( this->ProcessObject::GetOutput(0) );
+    this->ProcessObject::SetNthOutput(0, a.GetPointer());
+  }
+  EquivalencyTableType::Pointer
+  GetEquivalencyTable()
+  {
+    return static_cast<EquivalencyTableType *>(this->ProcessObject::GetOutput(0));
   }
 
   /** Standard non-threaded pipeline method */
-  void GenerateData() ITK_OVERRIDE;
+  void
+  GenerateData() override;
 
   /** Standard itk::ProcessObject subclass method. */
-  typedef ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
+  using DataObjectPointerArraySizeType = ProcessObject::DataObjectPointerArraySizeType;
   using Superclass::MakeOutput;
-  DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE;
+  DataObjectPointer
+  MakeOutput(DataObjectPointerArraySizeType idx) override;
 
 protected:
-  BoundaryResolver():m_Face(0)
+  BoundaryResolver()
   {
-    EquivalencyTable::Pointer eq =
-      static_cast< EquivalencyTable * >( this->MakeOutput(0).GetPointer() );
+    EquivalencyTable::Pointer eq = static_cast<EquivalencyTable *>(this->MakeOutput(0).GetPointer());
 
     this->SetNumberOfRequiredOutputs(1);
-    this->ProcessObject::SetNthOutput( 0, eq.GetPointer() );
+    this->ProcessObject::SetNthOutput(0, eq.GetPointer());
   }
 
-  ~BoundaryResolver() ITK_OVERRIDE {}
+  ~BoundaryResolver() override = default;
   BoundaryResolver(const Self &) {}
-  void operator=(const Self &) {}
-  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
-
-  unsigned short m_Face;
-  void GenerateOutputRequestedRegion(DataObject *output) ITK_OVERRIDE;
+  void
+  operator=(const Self &)
+  {}
+  void
+  PrintSelf(std::ostream & os, Indent indent) const override;
+
+  unsigned short m_Face{ 0 };
+  void
+  GenerateOutputRequestedRegion(DataObject * output) override;
 };
 } // end namespace watershed
 } // end namespace itk
 
 #ifndef ITK_MANUAL_INSTANTIATION
-#include "itkWatershedBoundaryResolver.hxx"
+#  include "itkWatershedBoundaryResolver.hxx"
 #endif
 
 #endif
diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedBoundaryResolver.hxx b/Modules/Segmentation/Watersheds/include/itkWatershedBoundaryResolver.hxx
index 41f397e996..32ea817739 100644
--- a/Modules/Segmentation/Watersheds/include/itkWatershedBoundaryResolver.hxx
+++ b/Modules/Segmentation/Watersheds/include/itkWatershedBoundaryResolver.hxx
@@ -25,9 +25,9 @@ namespace itk
 {
 namespace watershed
 {
-template< typename TPixelType, unsigned int TDimension >
-void BoundaryResolver< TPixelType, TDimension >
-::GenerateData()
+template <typename TPixelType, unsigned int TDimension>
+void
+BoundaryResolver<TPixelType, TDimension>::GenerateData()
 {
   //
   // NOTE: This method does not yet support arbitrary connectivity
@@ -35,7 +35,7 @@ void BoundaryResolver< TPixelType, TDimension >
   //       See itkWatershedSegmenter for details. City-block style connectivity
   //       is assumed (ie 4-, 6- for 2d, 3d). jc 11/14/01
   //
-  typedef typename BoundaryType::face_t FaceType;
+  using FaceType = typename BoundaryType::face_t;
   typename BoundaryType::IndexType idxA;
   typename BoundaryType::IndexType idxB;
 
@@ -46,8 +46,8 @@ void BoundaryResolver< TPixelType, TDimension >
 
   idxA.first = this->GetFace();
   idxB.first = this->GetFace();
-  idxA.second = 1;  // HIGH face matches
-  idxB.second = 0;  // the LOW face.
+  idxA.second = 1; // HIGH face matches
+  idxB.second = 0; // the LOW face.
 
   // Initialize current minLabel
   // Initialize the current boundsMin
@@ -68,23 +68,21 @@ void BoundaryResolver< TPixelType, TDimension >
   // This constructs equivalencies between both flat regions and
   // non-flat regions.
   //
-  ImageRegionIterator< FaceType > itA( boundaryA->GetFace(idxA),
-                                       boundaryA->GetFace(idxA)->GetRequestedRegion() );
+  ImageRegionIterator<FaceType> itA(boundaryA->GetFace(idxA), boundaryA->GetFace(idxA)->GetRequestedRegion());
 
-  ImageRegionIterator< FaceType > itB( boundaryB->GetFace(idxB),
-                                       boundaryB->GetFace(idxB)->GetRequestedRegion() );
+  ImageRegionIterator<FaceType> itB(boundaryB->GetFace(idxB), boundaryB->GetFace(idxB)->GetRequestedRegion());
 
-  for ( itA.GoToBegin(), itB.GoToBegin(); !itA.IsAtEnd(); ++itA, ++itB )
+  for (itA.GoToBegin(), itB.GoToBegin(); !itA.IsAtEnd(); ++itA, ++itB)
+  {
+    if (itA.Get().flow != SegmenterType::NULL_FLOW)
     {
-    if ( itA.Get().flow != SegmenterType::NULL_FLOW )
-      {
       equivTable->Add(itA.Get().label, itB.Get().label);
-      }
-    if ( itB.Get().flow != SegmenterType::NULL_FLOW )
-      {
+    }
+    if (itB.Get().flow != SegmenterType::NULL_FLOW)
+    {
       equivTable->Add(itA.Get().label, itB.Get().label);
-      }
     }
+  }
 
   equivTable->Flatten();
 }
@@ -92,23 +90,21 @@ void BoundaryResolver< TPixelType, TDimension >
 // ------------------------------------------------------------
 // --------------------PIPELINE METHODS------------------------
 // ------------------------------------------------------------
-template< typename TPixelType, unsigned int TDimension >
-void BoundaryResolver< TPixelType, TDimension >
-::GenerateOutputRequestedRegion(DataObject *)
+template <typename TPixelType, unsigned int TDimension>
+void
+BoundaryResolver<TPixelType, TDimension>::GenerateOutputRequestedRegion(DataObject *)
 {}
 
-template< typename TPixelType, unsigned int TDimension >
-typename BoundaryResolver< TPixelType, TDimension >::DataObjectPointer
-BoundaryResolver< TPixelType, TDimension >
-::MakeOutput(DataObjectPointerArraySizeType)
+template <typename TPixelType, unsigned int TDimension>
+typename BoundaryResolver<TPixelType, TDimension>::DataObjectPointer
+  BoundaryResolver<TPixelType, TDimension>::MakeOutput(DataObjectPointerArraySizeType)
 {
   return EquivalencyTable::New().GetPointer();
 }
 
-template< typename TPixelType, unsigned int TDimension >
+template <typename TPixelType, unsigned int TDimension>
 void
-BoundaryResolver< TPixelType, TDimension >
-::PrintSelf(std::ostream & os, Indent indent) const
+BoundaryResolver<TPixelType, TDimension>::PrintSelf(std::ostream & os, Indent indent) const
 {
   Superclass::PrintSelf(os, indent);
 
diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedEquivalenceRelabeler.h b/Modules/Segmentation/Watersheds/include/itkWatershedEquivalenceRelabeler.h
index 6fcf219165..e6efe034c5 100644
--- a/Modules/Segmentation/Watersheds/include/itkWatershedEquivalenceRelabeler.h
+++ b/Modules/Segmentation/Watersheds/include/itkWatershedEquivalenceRelabeler.h
@@ -49,93 +49,103 @@ namespace watershed
  * \sa EquivalencyTable
  * \ingroup ITKWatersheds
  */
-template< typename TScalar, unsigned int TImageDimension >
-class ITK_TEMPLATE_EXPORT EquivalenceRelabeler:
-  public ProcessObject
+template <typename TScalar, unsigned int TImageDimension>
+class ITK_TEMPLATE_EXPORT EquivalenceRelabeler : public ProcessObject
 {
 public:
   /** Expose templated image dimension parameter at run time */
-  itkStaticConstMacro(ImageDimension, unsigned int, TImageDimension);
+  static constexpr unsigned int ImageDimension = TImageDimension;
 
-  /**  Some convenient typedefs.   */
-  typedef Image< IdentifierType, TImageDimension >          ImageType;
-  typedef EquivalenceRelabeler                              Self;
-  typedef ProcessObject                                     Superclass;
-  typedef TScalar                                           ScalarType;
-  typedef EquivalencyTable                                  EquivalencyTableType;
-  typedef Segmenter< Image< ScalarType, TImageDimension > > SegmenterType;
-  typedef DataObject::Pointer                               DataObjectPointer;
+  /**  Some convenient type alias.   */
+  using ImageType = Image<IdentifierType, TImageDimension>;
+  using Self = EquivalenceRelabeler;
+  using Superclass = ProcessObject;
+  using ScalarType = TScalar;
+  using EquivalencyTableType = EquivalencyTable;
+  using SegmenterType = Segmenter<Image<ScalarType, TImageDimension>>;
+  using DataObjectPointer = DataObject::Pointer;
 
   /**  Define smart pointers for this object.   */
-  typedef SmartPointer< Self >       Pointer;
-  typedef SmartPointer< const Self > ConstPointer;
+  using Pointer = SmartPointer<Self>;
+  using ConstPointer = SmartPointer<const Self>;
   itkNewMacro(Self);
   itkTypeMacro(WatershedEquivalenceRelabeler, ProcessObject);
 
   /** Set/Get the image to relabel.   */
-  void SetInputImage(ImageType *img)
-  { this->ProcessObject::SetNthInput(0, img); }
-  const ImageType * GetInputImage(void)
+  void
+  SetInputImage(ImageType * img)
   {
-    return static_cast< ImageType * >
-           ( this->ProcessObject::GetInput(0) );
+    this->ProcessObject::SetNthInput(0, img);
+  }
+  const ImageType *
+  GetInputImage()
+  {
+    return static_cast<ImageType *>(this->ProcessObject::GetInput(0));
   }
 
   /** Set/Get the output image */
-  void SetOutputImage(ImageType *img)
+  void
+  SetOutputImage(ImageType * img)
   {
     this->ProcessObject::SetNthOutput(0, img);
   }
 
-  typename ImageType::Pointer GetOutputImage()
+  typename ImageType::Pointer
+  GetOutputImage()
   {
-    return static_cast< ImageType * >
-           ( this->ProcessObject::GetOutput(0) );
+    return static_cast<ImageType *>(this->ProcessObject::GetOutput(0));
   }
 
   /** Set/Get the table to use in relabeling the input image.   */
-  void SetEquivalencyTable(EquivalencyTableType *et)
+  void
+  SetEquivalencyTable(EquivalencyTableType * et)
   {
     this->ProcessObject::SetNthInput(1, et);
   }
 
-  EquivalencyTableType::Pointer GetEquivalencyTable()
+  EquivalencyTableType::Pointer
+  GetEquivalencyTable()
   {
-    return static_cast< EquivalencyTableType * >
-           ( this->ProcessObject::GetInput(1) );
+    return static_cast<EquivalencyTableType *>(this->ProcessObject::GetInput(1));
   }
 
   /** Standard non-threaded pipeline method */
-  void GenerateData() ITK_OVERRIDE;
+  void
+  GenerateData() override;
 
   /** Standard itk::ProcessObject subclass method. */
-  typedef ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
+  using DataObjectPointerArraySizeType = ProcessObject::DataObjectPointerArraySizeType;
   using Superclass::MakeOutput;
-  DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE;
+  DataObjectPointer
+  MakeOutput(DataObjectPointerArraySizeType idx) override;
 
 protected:
   EquivalenceRelabeler()
   {
-    typename ImageType::Pointer img =
-      static_cast< ImageType * >( this->MakeOutput(0).GetPointer() );
+    typename ImageType::Pointer img = static_cast<ImageType *>(this->MakeOutput(0).GetPointer());
     this->SetNumberOfRequiredOutputs(1);
-    this->ProcessObject::SetNthOutput( 0, img.GetPointer() );
+    this->ProcessObject::SetNthOutput(0, img.GetPointer());
   }
 
-  ~EquivalenceRelabeler() ITK_OVERRIDE {}
+  ~EquivalenceRelabeler() override = default;
   EquivalenceRelabeler(const Self &) {}
-  void operator=(const Self &) {}
-  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
+  void
+  operator=(const Self &)
+  {}
+  void
+  PrintSelf(std::ostream & os, Indent indent) const override;
 
-  void GenerateOutputRequestedRegion(DataObject *output) ITK_OVERRIDE;
+  void
+  GenerateOutputRequestedRegion(DataObject * output) override;
 
-  void GenerateInputRequestedRegion() ITK_OVERRIDE;
+  void
+  GenerateInputRequestedRegion() override;
 };
 } // end namespace watershed
 } // end namespace itk
 
 #ifndef ITK_MANUAL_INSTANTIATION
-#include "itkWatershedEquivalenceRelabeler.hxx"
+#  include "itkWatershedEquivalenceRelabeler.hxx"
 #endif
 
 #endif
diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedEquivalenceRelabeler.hxx b/Modules/Segmentation/Watersheds/include/itkWatershedEquivalenceRelabeler.hxx
index 790e0aa099..8408aec721 100644
--- a/Modules/Segmentation/Watersheds/include/itkWatershedEquivalenceRelabeler.hxx
+++ b/Modules/Segmentation/Watersheds/include/itkWatershedEquivalenceRelabeler.hxx
@@ -23,97 +23,99 @@ namespace itk
 {
 namespace watershed
 {
-template< typename TScalar, unsigned int TImageDimension >
-void EquivalenceRelabeler< TScalar, TImageDimension >
-::GenerateData()
+template <typename TScalar, unsigned int TImageDimension>
+void
+EquivalenceRelabeler<TScalar, TImageDimension>::GenerateData()
 {
-  typename ImageType::ConstPointer input  = this->GetInputImage();
-  typename ImageType::Pointer output = this->GetOutputImage();
+  typename ImageType::ConstPointer input = this->GetInputImage();
+  typename ImageType::Pointer      output = this->GetOutputImage();
 
   typename EquivalencyTableType::Pointer eqT = this->GetEquivalencyTable();
 
-  output->SetBufferedRegion( output->GetRequestedRegion() );
+  output->SetBufferedRegion(output->GetRequestedRegion());
   output->Allocate();
 
   //
   // Copy input to output
   //
-  ImageRegionConstIterator< ImageType > it_a( input, output->GetRequestedRegion() );
-  ImageRegionIterator< ImageType >      it_b( output, output->GetRequestedRegion() );
+  ImageRegionConstIterator<ImageType> it_a(input, output->GetRequestedRegion());
+  ImageRegionIterator<ImageType>      it_b(output, output->GetRequestedRegion());
 
   it_a.GoToBegin();
   it_b.GoToBegin();
-  while ( !it_a.IsAtEnd() )
-    {
-    it_b.Set( it_a.Get() );
+  while (!it_a.IsAtEnd())
+  {
+    it_b.Set(it_a.Get());
     ++it_a;
     ++it_b;
-    }
+  }
 
   eqT->Flatten();
   SegmenterType::RelabelImage(output, output->GetRequestedRegion(), eqT);
 }
 
-template< typename TScalar, unsigned int VImageDimension >
-void EquivalenceRelabeler< TScalar, VImageDimension >
-::GenerateInputRequestedRegion()
+template <typename TScalar, unsigned int VImageDimension>
+void
+EquivalenceRelabeler<TScalar, VImageDimension>::GenerateInputRequestedRegion()
 {
   // call the superclass' implementation of this method
   Superclass::GenerateInputRequestedRegion();
 
   // get pointers to the input and output
-  ImageType *inputPtr  = const_cast< ImageType * >( this->GetInputImage() );
-  ImageType *outputPtr  = this->GetOutputImage();
+  auto *      inputPtr = const_cast<ImageType *>(this->GetInputImage());
+  ImageType * outputPtr = this->GetOutputImage();
 
-  if ( !inputPtr || !outputPtr )
-    {
+  if (!inputPtr || !outputPtr)
+  {
     return;
-    }
+  }
 
   //
   // FOR NOW WE'LL JUST SET THE INPUT REGION TO THE OUTPUT REGION
   // FOR STREAMING WITHIN THE PIPELINE NEED TO FIX THIS
   //
-  inputPtr->SetRequestedRegion( outputPtr->GetRequestedRegion() );
+  inputPtr->SetRequestedRegion(outputPtr->GetRequestedRegion());
 }
 
-template< typename TScalar, unsigned int TImageDimension >
-void EquivalenceRelabeler< TScalar, TImageDimension >
-::GenerateOutputRequestedRegion(DataObject *output)
+template <typename TScalar, unsigned int TImageDimension>
+void
+EquivalenceRelabeler<TScalar, TImageDimension>::GenerateOutputRequestedRegion(DataObject * output)
 {
   // Only the Image output need to be propagated through.
   // No choice but to use RTTI here.
   // All Image outputs set to the same RequestedRegion  other
   // outputs ignored.
-  ImageBase< ImageDimension > *imgData;
-  ImageBase< ImageDimension > *op;
-  imgData = dynamic_cast< ImageBase< ImageDimension > * >( output );
+  ImageBase<ImageDimension> * imgData;
+  ImageBase<ImageDimension> * op;
+  imgData = dynamic_cast<ImageBase<ImageDimension> *>(output);
 
-  if ( imgData )
+  if (imgData)
+  {
+    std::vector<ProcessObject::DataObjectPointer>::size_type idx;
+    for (idx = 0; idx < this->GetNumberOfIndexedOutputs(); ++idx)
     {
-    std::vector< ProcessObject::DataObjectPointer >::size_type idx;
-    for ( idx = 0; idx < this->GetNumberOfIndexedOutputs(); ++idx )
+      if (this->GetOutput(idx) && this->GetOutput(idx) != output)
       {
-      if ( this->GetOutput(idx) && this->GetOutput(idx) != output )
+        op = dynamic_cast<ImageBase<ImageDimension> *>(this->GetOutput(idx));
+        if (op)
         {
-        op = dynamic_cast< ImageBase< ImageDimension > * >( this->GetOutput(idx) );
-        if ( op ) { this->GetOutput(idx)->SetRequestedRegion(output); }
+          this->GetOutput(idx)->SetRequestedRegion(output);
         }
       }
     }
+  }
 }
 
-template< typename TScalar, unsigned int TImageDimension >
-void EquivalenceRelabeler< TScalar, TImageDimension >
-::PrintSelf(std::ostream & os, Indent indent) const
+template <typename TScalar, unsigned int TImageDimension>
+void
+EquivalenceRelabeler<TScalar, TImageDimension>::PrintSelf(std::ostream & os, Indent indent) const
 {
   Superclass::PrintSelf(os, indent);
 }
 
-template< typename TScalar, unsigned int TImageDimension >
-typename EquivalenceRelabeler< TScalar, TImageDimension >::DataObjectPointer
-EquivalenceRelabeler< TScalar, TImageDimension >
-::MakeOutput(DataObjectPointerArraySizeType)
+template <typename TScalar, unsigned int TImageDimension>
+typename EquivalenceRelabeler<TScalar, TImageDimension>::DataObjectPointer
+  EquivalenceRelabeler<TScalar, TImageDimension>::MakeOutput(DataObjectPointerArraySizeType)
 {
   return ImageType::New().GetPointer();
 }
diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedImageFilter.h b/Modules/Segmentation/Watersheds/include/itkWatershedImageFilter.h
index be18801514..b0457c3d78 100644
--- a/Modules/Segmentation/Watersheds/include/itkWatershedImageFilter.h
+++ b/Modules/Segmentation/Watersheds/include/itkWatershedImageFilter.h
@@ -138,46 +138,45 @@ namespace itk
  * Threshold and Level parameters are controlled through the class'
  * Get/SetThreshold() and Get/SetLevel() methods.
  *
- * \par Notes on streaming the watershed segmentation code
- *  Coming soon... 12/06/01
- *
- *
- *
  * \ingroup WatershedSegmentation
  * \ingroup ITKWatersheds
+ *
+ * \sphinx
+ * \sphinxexample{Segmentation/Watersheds/SegmentWithWatershedImageFilter,Watershed Image Filter}
+ * \endsphinx
  */
-template< typename TInputImage >
-class ITK_TEMPLATE_EXPORT WatershedImageFilter:
-  public ImageToImageFilter< TInputImage, Image< IdentifierType,
-                                                 TInputImage::ImageDimension > >
+template <typename TInputImage>
+class ITK_TEMPLATE_EXPORT WatershedImageFilter
+  : public ImageToImageFilter<TInputImage, Image<IdentifierType, TInputImage::ImageDimension>>
 {
 public:
-  /** Standard "Self" typedef.   */
-  typedef WatershedImageFilter Self;
+  ITK_DISALLOW_COPY_AND_ASSIGN(WatershedImageFilter);
+
+  /** Standard "Self" type alias.   */
+  using Self = WatershedImageFilter;
 
   /** The type of input image.   */
-  typedef TInputImage InputImageType;
+  using InputImageType = TInputImage;
 
   /** Dimension of the input and output images. */
-  itkStaticConstMacro (ImageDimension, unsigned int,
-                       TInputImage::ImageDimension);
+  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
 
   /** The type of output image.   */
-  typedef Image< IdentifierType, itkGetStaticConstMacro(ImageDimension) > OutputImageType;
+  using OutputImageType = Image<IdentifierType, Self::ImageDimension>;
 
-  /** Other convenient typedefs   */
-  typedef typename InputImageType::RegionType RegionType;
-  typedef typename InputImageType::SizeType   SizeType;
-  typedef typename InputImageType::IndexType  IndexType;
+  /** Other convenient type alias   */
+  using RegionType = typename InputImageType::RegionType;
+  using SizeType = typename InputImageType::SizeType;
+  using IndexType = typename InputImageType::IndexType;
 
-  /** Standard super class typedef support. */
-  typedef ImageToImageFilter< InputImageType, OutputImageType > Superclass;
+  /** Standard super class type alias support */
+  using Superclass = ImageToImageFilter<InputImageType, OutputImageType>;
 
   /** Typedef support for the input image scalar value type. */
-  typedef typename InputImageType::PixelType ScalarType;
+  using ScalarType = typename InputImageType::PixelType;
 
-  /** Smart pointer typedef support  */
-  typedef SmartPointer< Self > Pointer;
+  /** Smart pointer type alias support  */
+  using Pointer = SmartPointer<Self>;
 
   /** Run-time type information (and related methods) */
   itkTypeMacro(WatershedImageFilter, ImageToImageFilter);
@@ -186,47 +185,56 @@ public:
   itkNewMacro(Self);
 
   /** Standard process object method.  This filter is not multithreaded. */
-  void GenerateData() ITK_OVERRIDE;
+  void
+  GenerateData() override;
 
   /** Overloaded to link the input to this filter with the input of the
       mini-pipeline */
   using Superclass::SetInput;
-  void SetInput(const InputImageType *input) ITK_OVERRIDE
+  void
+  SetInput(const InputImageType * input) override
   {
     // if the input is changed, we'll need to clear the cached tree
     // when we execute
-    if ( input != this->GetInput(0) )
-      {
+    if (input != this->GetInput(0))
+    {
       m_InputChanged = true;
-      }
+    }
 
     // processObject is not const-correct so a const_cast is needed here
-    this->ProcessObject::SetNthInput( 0, const_cast< InputImageType * >( input ) );
-    m_Segmenter->SetInputImage( const_cast< InputImageType * >( input ) );
+    this->ProcessObject::SetNthInput(0, const_cast<InputImageType *>(input));
+    m_Segmenter->SetInputImage(const_cast<InputImageType *>(input));
   }
 
-  void SetInput(unsigned int i, const TInputImage *image) ITK_OVERRIDE
+  void
+  SetInput(unsigned int i, const TInputImage * image) override
   {
-    if ( i != 0 )
-                  { itkExceptionMacro(<< "Filter has only one input."); }
+    if (i != 0)
+    {
+      itkExceptionMacro(<< "Filter has only one input.");
+    }
     else
-                  { this->SetInput(image); }
+    {
+      this->SetInput(image);
+    }
   }
 
   /** Set/Get the input thresholding parameter.  Units are a percentage of
    * the maximum depth in the image. */
-  void SetThreshold(double);
+  void
+  SetThreshold(double);
 
   itkGetConstMacro(Threshold, double);
 
   /** Set/Get the flood level for generating the merge tree from the initial
    * segmentation   */
-  void SetLevel(double);
+  void
+  SetLevel(double);
 
   itkGetConstMacro(Level, double);
 
   /** Get the basic segmentation from the Segmenter member filter. */
-  typename watershed::Segmenter< InputImageType >::OutputImageType *
+  typename watershed::Segmenter<InputImageType>::OutputImageType *
   GetBasicSegmentation()
   {
     m_Segmenter->Update();
@@ -234,60 +242,57 @@ public:
   }
 
   /** Get the segmentation tree from from the TreeGenerator member filter. */
-  typename watershed::SegmentTreeGenerator< ScalarType >::SegmentTreeType *
+  typename watershed::SegmentTreeGenerator<ScalarType>::SegmentTreeType *
   GetSegmentTree()
   {
     return m_TreeGenerator->GetOutputSegmentTree();
   }
 
   // Override since the filter produces all of its output
-  void EnlargeOutputRequestedRegion(DataObject *data) ITK_OVERRIDE;
+  void
+  EnlargeOutputRequestedRegion(DataObject * data) override;
 
 #ifdef ITK_USE_CONCEPT_CHECKING
   // Begin concept checking
-  itkConceptMacro( InputEqualityComparableCheck,
-                   ( Concept::EqualityComparable< ScalarType > ) );
-  itkConceptMacro( InputAdditiveOperatorsCheck,
-                   ( Concept::AdditiveOperators< ScalarType > ) );
-  itkConceptMacro( DoubleInputMultiplyOperatorCheck,
-                   ( Concept::MultiplyOperator< double, ScalarType, ScalarType > ) );
-  itkConceptMacro( InputLessThanComparableCheck,
-                   ( Concept::LessThanComparable< ScalarType > ) );
+  itkConceptMacro(InputEqualityComparableCheck, (Concept::EqualityComparable<ScalarType>));
+  itkConceptMacro(InputAdditiveOperatorsCheck, (Concept::AdditiveOperators<ScalarType>));
+  itkConceptMacro(DoubleInputMultiplyOperatorCheck, (Concept::MultiplyOperator<double, ScalarType, ScalarType>));
+  itkConceptMacro(InputLessThanComparableCheck, (Concept::LessThanComparable<ScalarType>));
   // End concept checking
 #endif
 
 protected:
   WatershedImageFilter();
-  ~WatershedImageFilter() ITK_OVERRIDE {}
-  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
+  ~WatershedImageFilter() override = default;
+  void
+  PrintSelf(std::ostream & os, Indent indent) const override;
 
   /** An opportunity to Allocate/Deallocate bulk data.
    */
-  void PrepareOutputs() ITK_OVERRIDE;
+  void
+  PrepareOutputs() override;
 
 private:
-  ITK_DISALLOW_COPY_AND_ASSIGN(WatershedImageFilter);
-
   /** A Percentage of the maximum depth (max - min pixel value) in the input
    *  image.  This percentage will be used to threshold the minimum values in
    *  the image. */
-  double m_Threshold;
+  double m_Threshold{ 0.0 };
 
   /** The percentage of the maximum saliency value among adjacencies in the
    *  segments of the initial segmentation to which "flooding" of the image
    *  should occur.  A tree of segment merges is calculated up to this
    *  level. */
-  double m_Level;
+  double m_Level{ 0.0 };
 
   /** The component parts of the segmentation algorithm.  These objects
    * must save state between calls to GenerateData() so that the
    * computationally expensive execution of segment tree generation is
    * not unnecessarily repeated. */
-  typename watershed::Segmenter< InputImageType >::Pointer m_Segmenter;
+  typename watershed::Segmenter<InputImageType>::Pointer m_Segmenter;
 
-  typename watershed::SegmentTreeGenerator< ScalarType >::Pointer m_TreeGenerator;
+  typename watershed::SegmentTreeGenerator<ScalarType>::Pointer m_TreeGenerator;
 
-  typename watershed::Relabeler< ScalarType, itkGetStaticConstMacro(ImageDimension) >::Pointer m_Relabeler;
+  typename watershed::Relabeler<ScalarType, Self::ImageDimension>::Pointer m_Relabeler;
 
   unsigned long m_ObserverTag;
 
@@ -300,7 +305,7 @@ private:
 } // end namespace itk
 
 #ifndef ITK_MANUAL_INSTANTIATION
-#include "itkWatershedImageFilter.hxx"
+#  include "itkWatershedImageFilter.hxx"
 #endif
 
 #endif
diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedImageFilter.hxx b/Modules/Segmentation/Watersheds/include/itkWatershedImageFilter.hxx
index 7132d40d83..bc7663b360 100644
--- a/Modules/Segmentation/Watersheds/include/itkWatershedImageFilter.hxx
+++ b/Modules/Segmentation/Watersheds/include/itkWatershedImageFilter.hxx
@@ -21,84 +21,76 @@
 
 namespace itk
 {
-template< typename TInputImage >
+template <typename TInputImage>
 void
-WatershedImageFilter< TInputImage >
-::SetThreshold(double val)
+WatershedImageFilter<TInputImage>::SetThreshold(double val)
 {
-  if ( val < 0.0 )
-    {
+  if (val < 0.0)
+  {
     val = 0.0;
-    }
-  else if ( val > 1.0 )
-    {
+  }
+  else if (val > 1.0)
+  {
     val = 1.0;
-    }
+  }
 
-CLANG_PRAGMA_PUSH
-CLANG_SUPPRESS_Wfloat_equal
-  if ( val != m_Threshold )
-CLANG_PRAGMA_POP
-    {
+  CLANG_PRAGMA_PUSH
+  CLANG_SUPPRESS_Wfloat_equal if (val != m_Threshold) CLANG_PRAGMA_POP
+  {
     m_Threshold = val;
     m_Segmenter->SetThreshold(m_Threshold);
 
     m_ThresholdChanged = true;
     this->Modified();
-    }
+  }
 }
 
-template< typename TInputImage >
+template <typename TInputImage>
 void
-WatershedImageFilter< TInputImage >
-::SetLevel(double val)
+WatershedImageFilter<TInputImage>::SetLevel(double val)
 {
-  if ( val < 0.0 )
-    {
+  if (val < 0.0)
+  {
     val = 0.0;
-    }
-  else if ( val > 1.0 )
-    {
+  }
+  else if (val > 1.0)
+  {
     val = 1.0;
-    }
+  }
 
-CLANG_PRAGMA_PUSH    \
-CLANG_SUPPRESS_Wfloat_equal   \
-  if ( val != m_Level )
-CLANG_PRAGMA_POP    \
-    {
+  CLANG_PRAGMA_PUSH
+  CLANG_SUPPRESS_Wfloat_equal if (val != m_Level) CLANG_PRAGMA_POP
+  {
     m_Level = val;
     m_TreeGenerator->SetFloodLevel(m_Level);
     m_Relabeler->SetFloodLevel(m_Level);
 
     m_LevelChanged = true;
     this->Modified();
-    }
+  }
 }
 
-template< typename TInputImage >
-WatershedImageFilter< TInputImage >
-::WatershedImageFilter():m_Threshold(0.0), m_Level(0.0)
+template <typename TInputImage>
+WatershedImageFilter<TInputImage>::WatershedImageFilter()
 {
   // Set up the mini-pipeline for the first execution.
-  m_Segmenter    = watershed::Segmenter< InputImageType >::New();
-  m_TreeGenerator = watershed::SegmentTreeGenerator< ScalarType >::New();
-  m_Relabeler    = watershed::Relabeler< ScalarType, ImageDimension >::New();
+  m_Segmenter = watershed::Segmenter<InputImageType>::New();
+  m_TreeGenerator = watershed::SegmentTreeGenerator<ScalarType>::New();
+  m_Relabeler = watershed::Relabeler<ScalarType, ImageDimension>::New();
 
   m_Segmenter->SetDoBoundaryAnalysis(false);
   m_Segmenter->SetSortEdgeLists(true);
-  m_Segmenter->SetThreshold( this->GetThreshold() );
+  m_Segmenter->SetThreshold(this->GetThreshold());
 
-  m_TreeGenerator->SetInputSegmentTable( m_Segmenter->GetSegmentTable() );
+  m_TreeGenerator->SetInputSegmentTable(m_Segmenter->GetSegmentTable());
   m_TreeGenerator->SetMerge(false);
-  m_TreeGenerator->SetFloodLevel( this->GetLevel() );
+  m_TreeGenerator->SetFloodLevel(this->GetLevel());
 
-  m_Relabeler->SetInputSegmentTree( m_TreeGenerator->GetOutputSegmentTree() );
-  m_Relabeler->SetInputImage( m_Segmenter->GetOutputImage() );
-  m_Relabeler->SetFloodLevel( this->GetLevel() );
+  m_Relabeler->SetInputSegmentTree(m_TreeGenerator->GetOutputSegmentTree());
+  m_Relabeler->SetInputImage(m_Segmenter->GetOutputImage());
+  m_Relabeler->SetFloodLevel(this->GetLevel());
 
-  WatershedMiniPipelineProgressCommand::Pointer c =
-    WatershedMiniPipelineProgressCommand::New();
+  WatershedMiniPipelineProgressCommand::Pointer c = WatershedMiniPipelineProgressCommand::New();
   c->SetFilter(this);
   c->SetNumberOfFilters(3);
 
@@ -111,19 +103,17 @@ WatershedImageFilter< TInputImage >
   m_ThresholdChanged = true;
 }
 
-template< typename TInputImage >
+template <typename TInputImage>
 void
-WatershedImageFilter< TInputImage >
-::EnlargeOutputRequestedRegion(DataObject *data)
+WatershedImageFilter<TInputImage>::EnlargeOutputRequestedRegion(DataObject * data)
 {
   Superclass::EnlargeOutputRequestedRegion(data);
   data->SetRequestedRegionToLargestPossibleRegion();
 }
 
-template< typename TInputImage >
+template <typename TInputImage>
 void
-WatershedImageFilter< TInputImage >
-::PrepareOutputs()
+WatershedImageFilter<TInputImage>::PrepareOutputs()
 {
   // call the superclass' method to clear out the outputs
   Superclass::PrepareOutputs();
@@ -140,16 +130,14 @@ WatershedImageFilter< TInputImage >
   // Relabeler need to re-execute.  Plus, the
   // HighestCalculatedFloodLevel must be reset on the Tree Generator
   //
-  if ( m_InputChanged
-       || ( this->GetInput()->GetPipelineMTime() > m_GenerateDataMTime )
-       || m_ThresholdChanged )
-    {
+  if (m_InputChanged || (this->GetInput()->GetPipelineMTime() > m_GenerateDataMTime) || m_ThresholdChanged)
+  {
     m_Segmenter->PrepareOutputs();
     m_TreeGenerator->PrepareOutputs();
     m_Relabeler->PrepareOutputs();
 
     m_TreeGenerator->SetHighestCalculatedFloodLevel(0.0);
-    }
+  }
 
   // If the flood level changed but is below the Tree
   // Generator::HighestCalculatedFloodLevel, then only the Relabeler
@@ -159,46 +147,42 @@ WatershedImageFilter< TInputImage >
   // Generator::HighestCalculatedFloodLevel, then the Tree Generator +
   // Relabeler must execute.
   //
-  if ( m_LevelChanged )
+  if (m_LevelChanged)
+  {
+    if (m_Level <= m_TreeGenerator->GetHighestCalculatedFloodLevel())
     {
-    if ( m_Level <= m_TreeGenerator->GetHighestCalculatedFloodLevel() )
-      {
       m_Relabeler->PrepareOutputs();
-      }
+    }
     else
-      {
+    {
       m_TreeGenerator->PrepareOutputs();
       m_Relabeler->PrepareOutputs();
-      }
     }
+  }
 }
 
-template< typename TInputImage >
+template <typename TInputImage>
 void
-WatershedImageFilter< TInputImage >
-::GenerateData()
+WatershedImageFilter<TInputImage>::GenerateData()
 {
   // Set the largest possible region in the segmenter
-  m_Segmenter->SetLargestPossibleRegion( this->GetInput()
-                                         ->GetLargestPossibleRegion() );
-  m_Segmenter->GetOutputImage()
-  ->SetRequestedRegion( this->GetInput()->GetLargestPossibleRegion() );
+  m_Segmenter->SetLargestPossibleRegion(this->GetInput()->GetLargestPossibleRegion());
+  m_Segmenter->GetOutputImage()->SetRequestedRegion(this->GetInput()->GetLargestPossibleRegion());
 
   // Setup the progress command
   WatershedMiniPipelineProgressCommand::Pointer c =
-    dynamic_cast< WatershedMiniPipelineProgressCommand * >(
-      m_TreeGenerator->GetCommand(m_ObserverTag) );
+    dynamic_cast<WatershedMiniPipelineProgressCommand *>(m_TreeGenerator->GetCommand(m_ObserverTag));
   c->SetCount(0.0);
   c->SetNumberOfFilters(3);
 
   // Graft our output on the relabeler
-  m_Relabeler->GraftOutput( this->GetOutput() );
+  m_Relabeler->GraftOutput(this->GetOutput());
 
   // Update the mini-pipeline
   m_Relabeler->Update();
 
   // Graft the output of the relabeler back on this filter
-  this->GraftOutput( m_Relabeler->GetOutputImage() );
+  this->GraftOutput(m_Relabeler->GetOutputImage());
 
   // Keep track of when we last executed
   m_GenerateDataMTime.Modified();
@@ -209,10 +193,9 @@ WatershedImageFilter< TInputImage >
   m_ThresholdChanged = false;
 }
 
-template< typename TInputImage >
+template <typename TInputImage>
 void
-WatershedImageFilter< TInputImage >
-::PrintSelf(std::ostream & os, Indent indent) const
+WatershedImageFilter<TInputImage>::PrintSelf(std::ostream & os, Indent indent) const
 {
   Superclass::PrintSelf(os, indent);
   os << indent << "Threshold: " << m_Threshold << std::endl;
diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedMiniPipelineProgressCommand.h b/Modules/Segmentation/Watersheds/include/itkWatershedMiniPipelineProgressCommand.h
index 2f7c11badd..6032b00a25 100644
--- a/Modules/Segmentation/Watersheds/include/itkWatershedMiniPipelineProgressCommand.h
+++ b/Modules/Segmentation/Watersheds/include/itkWatershedMiniPipelineProgressCommand.h
@@ -31,28 +31,36 @@ namespace itk
  * implementing the mini-pipeline).
  * \ingroup ITKWatersheds
  */
-class ITKWatersheds_EXPORT WatershedMiniPipelineProgressCommand:public Command
+class ITKWatersheds_EXPORT WatershedMiniPipelineProgressCommand : public Command
 {
 public:
   /** Smart pointer declaration methods */
-  typedef WatershedMiniPipelineProgressCommand Self;
-  typedef Command                              Superclass;
-  typedef itk::SmartPointer< Self >            Pointer;
-  typedef itk::SmartPointer< const Self >      ConstPointer;
+  using Self = WatershedMiniPipelineProgressCommand;
+  using Superclass = Command;
+  using Pointer = itk::SmartPointer<Self>;
+  using ConstPointer = itk::SmartPointer<const Self>;
   itkTypeMacro(WatershedMiniPipelineProgressCommand, Command);
   itkNewMacro(Self);
 
   /** Standard Command virtual methods */
-  void Execute(Object *caller, const EventObject & event) ITK_OVERRIDE;
+  void
+  Execute(Object * caller, const EventObject & event) override;
 
-  void Execute(const Object *caller, const EventObject & event) ITK_OVERRIDE;
+  void
+  Execute(const Object * caller, const EventObject & event) override;
 
   /** Set/Get the filter whose UpdateProgress will be set by this
    * command object */
-  void SetFilter(ProcessObject *p)
-  { m_Filter = p; }
-  const ProcessObject * GetFilter()
-  { return m_Filter; }
+  void
+  SetFilter(ProcessObject * p)
+  {
+    m_Filter = p;
+  }
+  const ProcessObject *
+  GetFilter()
+  {
+    return m_Filter;
+  }
 
   /** Set/Get the base count for stepping through filter progress values */
   itkSetMacro(Count, double);
@@ -64,15 +72,15 @@ public:
   itkGetConstMacro(NumberOfFilters, unsigned int);
 
 protected:
-  WatershedMiniPipelineProgressCommand():m_Count(0.0), m_Filter(ITK_NULLPTR),
-    m_NumberOfFilters(1) {}
-  ~WatershedMiniPipelineProgressCommand() ITK_OVERRIDE {}
-  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
+  WatershedMiniPipelineProgressCommand() {}
+  ~WatershedMiniPipelineProgressCommand() override = default;
+  void
+  PrintSelf(std::ostream & os, Indent indent) const override;
 
 private:
-  double         m_Count;
-  ProcessObject *m_Filter;
-  unsigned int   m_NumberOfFilters;
+  double          m_Count{ 0.0 };
+  ProcessObject * m_Filter{ nullptr };
+  unsigned int    m_NumberOfFilters{ 1 };
 };
 } // end namespace itk
 
diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedRelabeler.h b/Modules/Segmentation/Watersheds/include/itkWatershedRelabeler.h
index 2293aa00a7..6d55e03cc2 100644
--- a/Modules/Segmentation/Watersheds/include/itkWatershedRelabeler.h
+++ b/Modules/Segmentation/Watersheds/include/itkWatershedRelabeler.h
@@ -60,74 +60,78 @@ namespace watershed
  * \sa itk::watershed::SegmentTree
  * \ingroup ITKWatersheds
  */
-template< typename TScalar, unsigned int TImageDimension >
-class ITK_TEMPLATE_EXPORT Relabeler:
-  public ProcessObject
+template <typename TScalar, unsigned int TImageDimension>
+class ITK_TEMPLATE_EXPORT Relabeler : public ProcessObject
 {
 public:
   /** Define smart pointers for this object */
-  typedef Relabeler                  Self;
-  typedef ProcessObject              Superclass;
-  typedef SmartPointer< Self >       Pointer;
-  typedef SmartPointer< const Self > ConstPointer;
+  using Self = Relabeler;
+  using Superclass = ProcessObject;
+  using Pointer = SmartPointer<Self>;
+  using ConstPointer = SmartPointer<const Self>;
 
   /** Method for creation through the object factory. */
   itkNewMacro(Self);
   itkTypeMacro(WatershedRelabeler, ProcessObject);
 
   /** Expose the ImageDimension template parameter at run time */
-  itkStaticConstMacro(ImageDimension, unsigned int, TImageDimension);
+  static constexpr unsigned int ImageDimension = TImageDimension;
 
-  /** Some convenient typedefs */
-  typedef TScalar                                           ScalarType;
-  typedef Image< IdentifierType, TImageDimension >          ImageType;
-  typedef SegmentTree< ScalarType >                         SegmentTreeType;
-  typedef Segmenter< Image< ScalarType, TImageDimension > > SegmenterType;
-  typedef DataObject::Pointer                               DataObjectPointer;
+  /** Some convenient type alias */
+  using ScalarType = TScalar;
+  using ImageType = Image<IdentifierType, TImageDimension>;
+  using SegmentTreeType = SegmentTree<ScalarType>;
+  using SegmenterType = Segmenter<Image<ScalarType, TImageDimension>>;
+  using DataObjectPointer = DataObject::Pointer;
 
   /** Standard itk::ProcessObject subclass method. */
-  typedef ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
+  using DataObjectPointerArraySizeType = ProcessObject::DataObjectPointerArraySizeType;
   using Superclass::MakeOutput;
-  DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE;
+  DataObjectPointer
+  MakeOutput(DataObjectPointerArraySizeType idx) override;
 
   /** Set/Get the input image */
-  void SetInputImage(ImageType *img)
+  void
+  SetInputImage(ImageType * img)
   {
     this->ProcessObject::SetNthInput(0, img);
   }
 
-  ImageType * GetInputImage(void)
+  ImageType *
+  GetInputImage()
   {
-    return itkDynamicCastInDebugMode< ImageType * >
-           ( this->ProcessObject::GetInput(0) );
+    return itkDynamicCastInDebugMode<ImageType *>(this->ProcessObject::GetInput(0));
   }
 
   /** Set/Get the output image */
-  void SetOutputImage(ImageType *img)
+  void
+  SetOutputImage(ImageType * img)
   {
     this->ProcessObject::SetNthOutput(0, img);
   }
 
-  ImageType * GetOutputImage(void)
+  ImageType *
+  GetOutputImage()
   {
-    return itkDynamicCastInDebugMode< ImageType * >
-           ( this->ProcessObject::GetOutput(0) );
+    return itkDynamicCastInDebugMode<ImageType *>(this->ProcessObject::GetOutput(0));
   }
 
   /** Set/Get the input tree that defines segment merges */
-  void SetInputSegmentTree(SegmentTreeType *et)
+  void
+  SetInputSegmentTree(SegmentTreeType * et)
   {
     this->ProcessObject::SetNthInput(1, et);
   }
 
-  SegmentTreeType * GetInputSegmentTree(void)
+  SegmentTreeType *
+  GetInputSegmentTree()
   {
-    return itkDynamicCastInDebugMode< SegmentTreeType * >
-           ( this->ProcessObject::GetInput(1) );
+    return itkDynamicCastInDebugMode<SegmentTreeType *>(this->ProcessObject::GetInput(1));
   }
 
   /** Standard non-threaded pipeline method */
-  void GenerateData() ITK_OVERRIDE;
+  void
+  GenerateData() override;
 
   /** Set/Get the percentage of the maximum saliency level
    * to merge to. */
@@ -135,27 +139,34 @@ public:
   itkGetConstMacro(FloodLevel, double);
 
   /** Standard ProcessObject method used in implementing mini-pipelines */
-  void GraftOutput(ImageType *graft);
+  void
+  GraftOutput(ImageType * graft);
 
-  void GraftNthOutput(unsigned int idx, ImageType *graft);
+  void
+  GraftNthOutput(unsigned int idx, ImageType * graft);
 
 protected:
   Relabeler();
-  ~Relabeler() ITK_OVERRIDE {}
+  ~Relabeler() override = default;
   Relabeler(const Self &) {}
-  void operator=(const Self &) {}
-  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
-
-  double m_FloodLevel;
-  void GenerateOutputRequestedRegion(DataObject *output) ITK_OVERRIDE;
-
-  void GenerateInputRequestedRegion() ITK_OVERRIDE;
+  void
+  operator=(const Self &)
+  {}
+  void
+  PrintSelf(std::ostream & os, Indent indent) const override;
+
+  double m_FloodLevel{ 0.0 };
+  void
+  GenerateOutputRequestedRegion(DataObject * output) override;
+
+  void
+  GenerateInputRequestedRegion() override;
 };
 } // end namespace watershed
 } // end namespace itk
 
 #ifndef ITK_MANUAL_INSTANTIATION
-#include "itkWatershedRelabeler.hxx"
+#  include "itkWatershedRelabeler.hxx"
 #endif
 
 #endif
diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedRelabeler.hxx b/Modules/Segmentation/Watersheds/include/itkWatershedRelabeler.hxx
index 36acb864a9..da988c053b 100644
--- a/Modules/Segmentation/Watersheds/include/itkWatershedRelabeler.hxx
+++ b/Modules/Segmentation/Watersheds/include/itkWatershedRelabeler.hxx
@@ -25,161 +25,161 @@ namespace itk
 {
 namespace watershed
 {
-template< typename TScalar, unsigned int TImageDimension >
-Relabeler< TScalar, TImageDimension >::Relabeler():m_FloodLevel(0.0)
+template <typename TScalar, unsigned int TImageDimension>
+Relabeler<TScalar, TImageDimension>::Relabeler()
 {
-  typename ImageType::Pointer img =
-    static_cast< ImageType * >( this->MakeOutput(0).GetPointer() );
+  typename ImageType::Pointer img = static_cast<ImageType *>(this->MakeOutput(0).GetPointer());
   this->SetNumberOfRequiredOutputs(1);
-  this->ProcessObject::SetNthOutput( 0, img.GetPointer() );
+  this->ProcessObject::SetNthOutput(0, img.GetPointer());
 }
 
-template< typename TScalar, unsigned int TImageDimension >
-typename Relabeler< TScalar, TImageDimension >::DataObjectPointer
-Relabeler< TScalar, TImageDimension >
-::MakeOutput( DataObjectPointerArraySizeType itkNotUsed(idx) )
+template <typename TScalar, unsigned int TImageDimension>
+typename Relabeler<TScalar, TImageDimension>::DataObjectPointer
+Relabeler<TScalar, TImageDimension>::MakeOutput(DataObjectPointerArraySizeType itkNotUsed(idx))
 {
   return ImageType::New().GetPointer();
 }
 
-template< typename TScalar, unsigned int TImageDimension >
-void Relabeler< TScalar, TImageDimension >
-::GenerateData()
+template <typename TScalar, unsigned int TImageDimension>
+void
+Relabeler<TScalar, TImageDimension>::GenerateData()
 {
   this->UpdateProgress(0.0);
-  typename ImageType::Pointer input  = this->GetInputImage();
-  typename ImageType::Pointer output  = this->GetOutputImage();
+  typename ImageType::Pointer input = this->GetInputImage();
+  typename ImageType::Pointer output = this->GetOutputImage();
 
-  typename SegmentTreeType::Pointer tree = this->GetInputSegmentTree();
+  typename SegmentTreeType::Pointer  tree = this->GetInputSegmentTree();
   typename SegmentTreeType::Iterator it;
-  EquivalencyTable::Pointer eqT = EquivalencyTable::New();
+  EquivalencyTable::Pointer          eqT = EquivalencyTable::New();
 
-  output->SetBufferedRegion( output->GetRequestedRegion() );
+  output->SetBufferedRegion(output->GetRequestedRegion());
   output->Allocate();
   //
   // Copy input to output
   //
-  ImageRegionIterator< ImageType > it_a( input, output->GetRequestedRegion() );
-  ImageRegionIterator< ImageType > it_b( output, output->GetRequestedRegion() );
+  ImageRegionIterator<ImageType> it_a(input, output->GetRequestedRegion());
+  ImageRegionIterator<ImageType> it_b(output, output->GetRequestedRegion());
   it_a.GoToBegin();
   it_b.GoToBegin();
-  while ( !it_a.IsAtEnd() )
-    {
-    it_b.Set( it_a.Get() );
+  while (!it_a.IsAtEnd())
+  {
+    it_b.Set(it_a.Get());
     ++it_a;
     ++it_b;
-    }
+  }
 
   this->UpdateProgress(0.1);
   //
   // Extract the merges up the requested level
   //
-  if ( tree->Empty() == true )
-    {
+  if (tree->Empty() == true)
+  {
     // itkWarningMacro("Empty input.  No relabeling was done.");
     return;
-    }
+  }
   ScalarType max = tree->Back().saliency;
-  ScalarType mergeLimit = static_cast< ScalarType >( m_FloodLevel * max );
+  auto       mergeLimit = static_cast<ScalarType>(m_FloodLevel * max);
 
   this->UpdateProgress(0.5);
 
   it = tree->Begin();
-  while ( it != tree->End() && ( *it ).saliency <= mergeLimit )
-    {
-    eqT->Add( ( *it ).from, ( *it ).to );
+  while (it != tree->End() && (*it).saliency <= mergeLimit)
+  {
+    eqT->Add((*it).from, (*it).to);
     it++;
-    }
+  }
 
   SegmenterType::RelabelImage(output, output->GetRequestedRegion(), eqT);
   this->UpdateProgress(1.0);
 }
 
-template< typename TScalar, unsigned int VImageDimension >
-void Relabeler< TScalar, VImageDimension >
-::GenerateInputRequestedRegion()
+template <typename TScalar, unsigned int VImageDimension>
+void
+Relabeler<TScalar, VImageDimension>::GenerateInputRequestedRegion()
 {
   // call the superclass' implementation of this method
   Superclass::GenerateInputRequestedRegion();
 
   // get pointers to the input and output
-  typename ImageType::Pointer inputPtr  = this->GetInputImage();
+  typename ImageType::Pointer inputPtr = this->GetInputImage();
   typename ImageType::Pointer outputPtr = this->GetOutputImage();
 
-  if ( !inputPtr || !outputPtr )
-    {
+  if (!inputPtr || !outputPtr)
+  {
     return;
-    }
+  }
 
   //
   // FOR NOW WE'LL JUST SET THE INPUT REGION TO THE OUTPUT REGION
   //
-  inputPtr->SetRequestedRegion( outputPtr->GetRequestedRegion() );
+  inputPtr->SetRequestedRegion(outputPtr->GetRequestedRegion());
 }
 
-template< typename TScalar, unsigned int TImageDimension >
-void Relabeler< TScalar, TImageDimension >
-::GenerateOutputRequestedRegion(DataObject *output)
+template <typename TScalar, unsigned int TImageDimension>
+void
+Relabeler<TScalar, TImageDimension>::GenerateOutputRequestedRegion(DataObject * output)
 {
   // Only the Image output need to be propagated through.
   // No choice but to use RTTI here.
   // All Image outputs set to the same RequestedRegion  other
   // outputs ignored.
-  ImageBase< ImageDimension > *imgData;
-  ImageBase< ImageDimension > *op;
-  imgData = dynamic_cast< ImageBase< ImageDimension > * >( output );
-
-  if ( imgData )
+  ImageBase<ImageDimension> * imgData;
+  ImageBase<ImageDimension> * op;
+  imgData = dynamic_cast<ImageBase<ImageDimension> *>(output);
+
+  if (imgData)
+  {
+    std::vector<ProcessObject::DataObjectPointer>::size_type idx;
+    for (idx = 0; idx < this->GetNumberOfIndexedOutputs(); ++idx)
     {
-    std::vector< ProcessObject::DataObjectPointer >::size_type idx;
-    for ( idx = 0; idx < this->GetNumberOfIndexedOutputs(); ++idx )
+      if (this->GetOutput(idx) && this->GetOutput(idx) != output)
       {
-      if ( this->GetOutput(idx) && this->GetOutput(idx) != output )
+        op = dynamic_cast<ImageBase<ImageDimension> *>(this->GetOutput(idx));
+        if (op)
         {
-        op = dynamic_cast< ImageBase< ImageDimension > * >( this->GetOutput(idx) );
-        if ( op ) { this->GetOutput(idx)->SetRequestedRegion(output); }
+          this->GetOutput(idx)->SetRequestedRegion(output);
         }
       }
     }
+  }
 }
 
-template< typename TScalar, unsigned int TImageDimension >
-void Relabeler< TScalar, TImageDimension >
-::GraftOutput(ImageType *graft)
+template <typename TScalar, unsigned int TImageDimension>
+void
+Relabeler<TScalar, TImageDimension>::GraftOutput(ImageType * graft)
 {
   this->GraftNthOutput(0, graft);
 }
 
-template< typename TScalar, unsigned int TImageDimension >
-void Relabeler< TScalar, TImageDimension >
-::GraftNthOutput(unsigned int idx, ImageType *graft)
+template <typename TScalar, unsigned int TImageDimension>
+void
+Relabeler<TScalar, TImageDimension>::GraftNthOutput(unsigned int idx, ImageType * graft)
 {
-  typedef typename ImageType::Pointer OutputImagePointer;
+  using OutputImagePointer = typename ImageType::Pointer;
 
-  if ( idx < this->GetNumberOfIndexedOutputs() )
-    {
+  if (idx < this->GetNumberOfIndexedOutputs())
+  {
     OutputImagePointer output = this->GetOutputImage();
 
-    if ( output && graft )
-      {
+    if (output && graft)
+    {
       // grab a handle to the bulk data of the specified data object
-      output->SetPixelContainer( graft->GetPixelContainer() );
+      output->SetPixelContainer(graft->GetPixelContainer());
 
       // copy the region ivars of the specified data object
-      output->SetRequestedRegion( graft->GetRequestedRegion() );
-      output->SetLargestPossibleRegion( graft->GetLargestPossibleRegion() );
-      output->SetBufferedRegion( graft->GetBufferedRegion() );
+      output->SetRequestedRegion(graft->GetRequestedRegion());
+      output->SetLargestPossibleRegion(graft->GetLargestPossibleRegion());
+      output->SetBufferedRegion(graft->GetBufferedRegion());
 
       // copy the meta-information
       output->CopyInformation(graft);
-      }
     }
+  }
 }
 
-template< typename TScalar, unsigned int TImageDimension >
+template <typename TScalar, unsigned int TImageDimension>
 void
-Relabeler< TScalar, TImageDimension >
-::PrintSelf(std::ostream & os, Indent indent) const
+Relabeler<TScalar, TImageDimension>::PrintSelf(std::ostream & os, Indent indent) const
 {
   Superclass::PrintSelf(os, indent);
   os << indent << "FloodLevel: " << m_FloodLevel << std::endl;
diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTable.h b/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTable.h
index de24dd6a22..ae4a46573c 100644
--- a/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTable.h
+++ b/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTable.h
@@ -43,183 +43,248 @@ namespace watershed
  * \sa itk::WatershedImageFilter
  * \ingroup ITKWatersheds
  */
-template< typename TScalar >
-class ITK_TEMPLATE_EXPORT SegmentTable:public DataObject
+template <typename TScalar>
+class ITK_TEMPLATE_EXPORT SegmentTable : public DataObject
 {
 public:
   /** Define smart pointers for this object */
-  typedef SegmentTable               Self;
-  typedef DataObject                 Superclass;
-  typedef SmartPointer< Self >       Pointer;
-  typedef SmartPointer< const Self > ConstPointer;
-  typedef TScalar                    ScalarType;
+  using Self = SegmentTable;
+  using Superclass = DataObject;
+  using Pointer = SmartPointer<Self>;
+  using ConstPointer = SmartPointer<const Self>;
+  using ScalarType = TScalar;
 
   itkNewMacro(Self);
   itkTypeMacro(WatershedSegmentTable, DataObject);
 
   /** The value type for lists of adjacencies contained in each table
       entry */
-  struct edge_pair_t {
-    edge_pair_t() {}
-    edge_pair_t(IdentifierType l, ScalarType s):label(l), height(s) {}
+  struct edge_pair_t
+  {
+    edge_pair_t() = default;
+    edge_pair_t(IdentifierType l, ScalarType s)
+      : label(l)
+      , height(s)
+    {}
     IdentifierType label;
-    ScalarType height;
+    ScalarType     height;
 
     /** Necessary operator for sorting the adjacency lists */
-    bool operator<(const edge_pair_t & o) const
+    bool
+    operator<(const edge_pair_t & o) const
     {
-      if ( this->height < o.height )
-        {
+      if (this->height < o.height)
+      {
         return true;
-        }
+      }
       else
-        {
+      {
         return false;
-        }
+      }
     }
   };
 
   /** Structure for storing lists of adjacencies (edges) and their
       saliencies. */
-  typedef std::list< edge_pair_t > edge_list_t;
+  using edge_list_t = std::list<edge_pair_t>;
 
   /** Structure holding information about each segment in an image. */
-  struct segment_t {
-    ScalarType min;
+  struct segment_t
+  {
+    ScalarType  min;
     edge_list_t edge_list;
   };
 
   /** Define the container type for the table */
-  typedef itksys::hash_map< IdentifierType, segment_t,
-    itksys::hash< IdentifierType > >           HashMapType;
-  typedef typename HashMapType::iterator       Iterator;
-  typedef typename HashMapType::const_iterator ConstIterator;
-  typedef typename HashMapType::value_type     ValueType;
-  typedef typename HashMapType::data_type      DataType;
+  using HashMapType = std::unordered_map<IdentifierType, segment_t>;
+  using Iterator = typename HashMapType::iterator;
+  using ConstIterator = typename HashMapType::const_iterator;
+  using ValueType = typename HashMapType::value_type;
+  using DataType = typename HashMapType::mapped_type;
 
   /** Inserts a segment into the table  */
-  bool Add(IdentifierType a, const segment_t & t);
+  bool
+  Add(IdentifierType a, const segment_t & t);
 
   /** Iterates through the table and removes edges
    * in every edge list whose saliencies are above the
    * specified maximum.  Requires that the edge lists
    * have been sorted prior to calling this method.   */
-  void PruneEdgeLists(ScalarType maximum_saliency);
+  void
+  PruneEdgeLists(ScalarType maximum_saliency);
 
   /** Lookup a segment in the table.  Returns a pointer to the
    * entry.  On failure, returns a null pointer.   */
-  segment_t * Lookup(const IdentifierType a)
+  segment_t *
+  Lookup(const IdentifierType a)
   {
     Iterator result = m_HashMap.find(a);
 
-    if ( result == m_HashMap.end() ) { return ITK_NULLPTR; }
-    else { return &( ( *result ).second ); }
+    if (result == m_HashMap.end())
+    {
+      return nullptr;
+    }
+    else
+    {
+      return &((*result).second);
+    }
   }
 
   /** Lookup a segment in the table.  Returns a const pointer
    * to the entry.  On failure, returns a null pointer.   */
-  const segment_t * Lookup(const IdentifierType a) const
+  const segment_t *
+  Lookup(const IdentifierType a) const
   {
     ConstIterator result = m_HashMap.find(a);
 
-    if ( result == m_HashMap.end() ) { return 0; }
-    else { return &( ( *result ).second ); }
+    if (result == m_HashMap.end())
+    {
+      return 0;
+    }
+    else
+    {
+      return &((*result).second);
+    }
   }
 
   /** Returns TRUE if the entry key is found in the table.  FALSE if the key is
    * not found in the table.   */
-  bool IsEntry(const IdentifierType a) const
+  bool
+  IsEntry(const IdentifierType a) const
   {
-    if ( m_HashMap.find(a) == m_HashMap.end() ) { return false; }
-    else { return true; }
+    if (m_HashMap.find(a) == m_HashMap.end())
+    {
+      return false;
+    }
+    else
+    {
+      return true;
+    }
   }
 
   /** Deletes an entry from the table.   */
-  void Erase(const IdentifierType a)
-  {  m_HashMap.erase(a); }
+  void
+  Erase(const IdentifierType a)
+  {
+    m_HashMap.erase(a);
+  }
 
   /** Removes all the entries in the table.   */
-  void Clear()
-  {      m_HashMap.clear();    }
+  void
+  Clear()
+  {
+    m_HashMap.clear();
+  }
 
   /** Returns true if the table is empty and false if the table is not empty.
    */
-  bool Empty() const
-  {      return m_HashMap.empty();    }
+  bool
+  Empty() const
+  {
+    return m_HashMap.empty();
+  }
 
   /** Sorts all the entries in the edge lists from least to greatest saliency.
    */
-  void SortEdgeLists();
+  void
+  SortEdgeLists();
 
   /** Returns the number of entries in the table.   */
-  typename HashMapType::size_type  Size() const
-  {      return m_HashMap.size();     }
+  typename HashMapType::size_type
+  Size() const
+  {
+    return m_HashMap.size();
+  }
 
   /** Merges two entries of the table.  from->to  */
   //  void Merge(const IdentifierType from, const IdentifierType to);
 
   /** Returns an iterator pointing to the first element in the (unordered)
       table. */
-  Iterator Begin() { return m_HashMap.begin(); }
+  Iterator
+  Begin()
+  {
+    return m_HashMap.begin();
+  }
 
   /** Returns an iterator pointing to one element past the last element in the
    * (unordered table).   */
-  Iterator End()   { return m_HashMap.end();   }
+  Iterator
+  End()
+  {
+    return m_HashMap.end();
+  }
 
   /** Returns a const iterator pointing to the first element in the (unordered)
    * table.  */
-  ConstIterator Begin() const { return m_HashMap.begin(); }
+  ConstIterator
+  Begin() const
+  {
+    return m_HashMap.begin();
+  }
 
   /** Returns a const iterator pointing to one element past the last element in
    * the  (unordered table).   */
-  ConstIterator End()   const { return m_HashMap.end();   }
+  ConstIterator
+  End() const
+  {
+    return m_HashMap.end();
+  }
 
   /** Convenience methods for debugging   */
-  unsigned int GetSegmentMemorySize() const
+  unsigned int
+  GetSegmentMemorySize() const
   {
-    return sizeof( segment_t );
+    return sizeof(segment_t);
   }
 
   //  void PrintHashTable() const;
 
   /** Set/Get the maximum depth of image on which this segment table is based.
    * (Should set really be calling modified? jc 11/16/01) */
-  void SetMaximumDepth(ScalarType s)
+  void
+  SetMaximumDepth(ScalarType s)
   {
     m_MaximumDepth = s;
     this->Modified();
   }
 
-  ScalarType GetMaximumDepth() const
-  { return m_MaximumDepth; }
+  ScalarType
+  GetMaximumDepth() const
+  {
+    return m_MaximumDepth;
+  }
 
   /** Copies the contents of another segment table into this segment table.
       This is really operator= in disguise, although superclass information is
       not copied. */
-  void Copy(const Self & o)
+  void
+  Copy(const Self & o)
   {
     m_HashMap = o.m_HashMap;
     m_MaximumDepth = o.m_MaximumDepth;
   }
 
 protected:
-  SegmentTable() :
-    m_MaximumDepth(0)
+  SegmentTable()
+    : m_MaximumDepth(0)
   {}
-  ~SegmentTable() ITK_OVERRIDE {}
+  ~SegmentTable() override = default;
 
   HashMapType m_HashMap;
 
   ScalarType m_MaximumDepth;
 
 private:
-  void operator=(const Self &) {}
+  void
+  operator=(const Self &)
+  {}
 };
 } // end namespace watershed
 } // end namespace itk
 
 #ifndef ITK_MANUAL_INSTANTIATION
-#include "itkWatershedSegmentTable.hxx"
+#  include "itkWatershedSegmentTable.hxx"
 #endif
 
 #endif
diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTable.hxx b/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTable.hxx
index a9eed11e49..c5bcff0cbb 100644
--- a/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTable.hxx
+++ b/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTable.hxx
@@ -24,49 +24,53 @@ namespace itk
 {
 namespace watershed
 {
-template< typename TScalar >
-void SegmentTable< TScalar >
-::PruneEdgeLists(ScalarType maximum_saliency)
+template <typename TScalar>
+void
+SegmentTable<TScalar>::PruneEdgeLists(ScalarType maximum_saliency)
 {
   Iterator it;
 
   typename edge_list_t::iterator e;
-  for ( it = this->Begin(); it != this->End(); ++it )
+  for (it = this->Begin(); it != this->End(); ++it)
+  {
+    for (e = (*it).second.edge_list.begin(); e != (*it).second.edge_list.end(); e++)
     {
-    for ( e = ( *it ).second.edge_list.begin();
-          e != ( *it ).second.edge_list.end();
-          e++ )
-      {
-      if ( ( e->height - ( *it ).second.min ) > maximum_saliency )
-        {   // dump the rest of the list, assumes list is sorted
+      if ((e->height - (*it).second.min) > maximum_saliency)
+      { // dump the rest of the list, assumes list is sorted
         e++;
-        ( *it ).second.edge_list.erase( e, ( *it ).second.edge_list.end() );
-        break;  // through with this segment
-        }
+        (*it).second.edge_list.erase(e, (*it).second.edge_list.end());
+        break; // through with this segment
       }
     }
+  }
 }
 
-template< typename TScalar >
-void SegmentTable< TScalar >
-::SortEdgeLists()
+template <typename TScalar>
+void
+SegmentTable<TScalar>::SortEdgeLists()
 {
   Iterator it;
 
-  for ( it = this->Begin(); it != this->End(); ++it )
-    {
-    ( *it ).second.edge_list.sort();
-    }
+  for (it = this->Begin(); it != this->End(); ++it)
+  {
+    (*it).second.edge_list.sort();
+  }
 }
 
-template< typename TScalar >
-bool SegmentTable< TScalar >
-::Add(IdentifierType a, const segment_t & t)
+template <typename TScalar>
+bool
+SegmentTable<TScalar>::Add(IdentifierType a, const segment_t & t)
 {
-  std::pair< Iterator, bool > result;
-  result = m_HashMap.insert( ValueType(a, t) );
-  if ( result.second == false ) { return false; }
-  else { return true; }
+  std::pair<Iterator, bool> result;
+  result = m_HashMap.insert(ValueType(a, t));
+  if (result.second == false)
+  {
+    return false;
+  }
+  else
+  {
+    return true;
+  }
 }
 } // end namespace watershed
 } // end namespace itk
diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTree.h b/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTree.h
index 83cb3fbbf4..1c0e8cadc4 100644
--- a/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTree.h
+++ b/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTree.h
@@ -43,128 +43,180 @@ namespace watershed
  *
  * \ingroup ITKWatersheds
  */
-template< typename TScalar >
-class ITK_TEMPLATE_EXPORT SegmentTree:public DataObject
+template <typename TScalar>
+class ITK_TEMPLATE_EXPORT SegmentTree : public DataObject
 {
 public:
   /** Define itk Smart Pointers for this object */
-  typedef SegmentTree                Self;
-  typedef DataObject                 Superclass;
-  typedef SmartPointer< Self >       Pointer;
-  typedef SmartPointer< const Self > ConstPointer;
+  using Self = SegmentTree;
+  using Superclass = DataObject;
+  using Pointer = SmartPointer<Self>;
+  using ConstPointer = SmartPointer<const Self>;
   itkNewMacro(Self);
   itkTypeMacro(WatershedSegmentTree, DataObject);
-  typedef TScalar ScalarType;
+  using ScalarType = TScalar;
 
   /** Elements of the list (nodes of the tree).  A record of a merge
    * between two segments (IdentifierType labels) at a particular
    * saliency.   */
-  struct merge_t {
+  struct merge_t
+  {
     IdentifierType from;
     IdentifierType to;
-    ScalarType saliency;
+    ScalarType     saliency;
   };
 
   /** Define the container type used in this list data structure */
-  typedef std::deque< merge_t >              DequeType;
-  typedef typename DequeType::iterator       Iterator;
-  typedef typename DequeType::const_iterator ConstIterator;
-  typedef typename DequeType::value_type     ValueType;
+  using DequeType = std::deque<merge_t>;
+  using Iterator = typename DequeType::iterator;
+  using ConstIterator = typename DequeType::const_iterator;
+  using ValueType = typename DequeType::value_type;
 
   /** Boolean comparison functor for use in sorting functions.  */
-  struct merge_comp:public std:: binary_function< bool, const merge_t &,
-                                                  const merge_t & > {
-    merge_comp() {}
-    bool operator()(const merge_t & a, const merge_t & b)
+  struct merge_comp : public std::binary_function<bool, const merge_t &, const merge_t &>
+  {
+    merge_comp() = default;
+    bool
+    operator()(const merge_t & a, const merge_t & b)
     {
       return b.saliency < a.saliency;
     }
   };
 
   /** Boolean comparison functor for use in sorting functions.   */
-  struct sort_comp:public std:: binary_function< bool, const merge_t &,
-                                                 const merge_t & > {
-    bool operator()(const merge_t & a, const merge_t & b)
+  struct sort_comp : public std::binary_function<bool, const merge_t &, const merge_t &>
+  {
+    bool
+    operator()(const merge_t & a, const merge_t & b)
     {
       return a.saliency < b.Saliency;
     }
   };
 
   /** Returns the size of the list.   */
-  typename DequeType::size_type Size() const
-  { return m_Deque.size(); }
+  typename DequeType::size_type
+  Size() const
+  {
+    return m_Deque.size();
+  }
 
   /** Returns TRUE if the SegmentTree is empty, FALSE if the SegmentTree is not
    * empty.    */
-  bool Empty() const
-  { return m_Deque.empty();    }
+  bool
+  Empty() const
+  {
+    return m_Deque.empty();
+  }
 
   /** Returns a const reference to the front of the list (node with the least
    * saliency value).    */
-  const merge_t & Front() const
-  { return m_Deque.front(); }
+  const merge_t &
+  Front() const
+  {
+    return m_Deque.front();
+  }
 
   /** Returns a const reference to the back of the list (node with the greatest
    * saliency value).   */
-  const merge_t & Back() const
-  { return m_Deque.back(); }
+  const merge_t &
+  Back() const
+  {
+    return m_Deque.back();
+  }
 
   /** Returns a reference to the front of the list   */
-  merge_t & Front()
-  { return m_Deque.front(); }
+  merge_t &
+  Front()
+  {
+    return m_Deque.front();
+  }
 
   /** Returns a reference to the back of the list   */
-  merge_t & Back()
-  { return m_Deque.back(); }
+  merge_t &
+  Back()
+  {
+    return m_Deque.back();
+  }
 
   /** Inserts a node at the front of the list.   */
-  void PushFront(const ValueType & t)
-  { m_Deque.push_front(t); }
+  void
+  PushFront(const ValueType & t)
+  {
+    m_Deque.push_front(t);
+  }
 
   /** Inserts a node at the back of the list   */
-  void PushBack(const ValueType & t)
-  { m_Deque.push_back(t); }
+  void
+  PushBack(const ValueType & t)
+  {
+    m_Deque.push_back(t);
+  }
 
   /** Erases the node at the front of the list.   */
-  void PopFront()
-  { m_Deque.pop_front(); }
+  void
+  PopFront()
+  {
+    m_Deque.pop_front();
+  }
 
   /** Erases the node at the back of the list.   */
-  void PopBack()
-  { m_Deque.pop_back(); }
+  void
+  PopBack()
+  {
+    m_Deque.pop_back();
+  }
 
   /** Returns an iterator pointing to the first element in the list.   */
-  Iterator Begin()
-  { return m_Deque.begin(); }
+  Iterator
+  Begin()
+  {
+    return m_Deque.begin();
+  }
 
   /** Returns a const iterator pointing to the first element in the list. */
-  ConstIterator Begin() const
-  { return m_Deque.begin(); }
+  ConstIterator
+  Begin() const
+  {
+    return m_Deque.begin();
+  }
 
   /** Returns an iterator pointing one element past the last element in the
    * list.    */
-  Iterator End()
-  { return m_Deque.end(); }
+  Iterator
+  End()
+  {
+    return m_Deque.end();
+  }
 
   /** Returns a const iterator pointing one element past the last element in the
    * list.    */
-  ConstIterator End() const
-  { return m_Deque.end(); }
+  ConstIterator
+  End() const
+  {
+    return m_Deque.end();
+  }
 
   /** Clears the Deque completely */
-  void Clear()
-  { m_Deque.clear(); }
+  void
+  Clear()
+  {
+    m_Deque.clear();
+  }
 
   /** Standard DataObject routine to initialize.  Returns the segment
    * tree to a default state, deallocating memory. */
-  void Initialize() ITK_OVERRIDE;
+  void
+  Initialize() override;
 
 protected:
-  SegmentTree() {}
-  ~SegmentTree() ITK_OVERRIDE {}
+  SegmentTree() = default;
+  ~SegmentTree() override = default;
   SegmentTree(const Self &) {}
-  void operator=(const Self &) {}
-  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
+  void
+  operator=(const Self &)
+  {}
+  void
+  PrintSelf(std::ostream & os, Indent indent) const override;
 
   DequeType m_Deque;
 };
@@ -172,7 +224,7 @@ protected:
 } // end namespace itk
 
 #ifndef ITK_MANUAL_INSTANTIATION
-#include "itkWatershedSegmentTree.hxx"
+#  include "itkWatershedSegmentTree.hxx"
 #endif
 
 #endif
diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTree.hxx b/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTree.hxx
index bec5a437e2..966b127929 100644
--- a/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTree.hxx
+++ b/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTree.hxx
@@ -26,10 +26,9 @@ namespace watershed
 {
 
 
-template< typename TScalar >
+template <typename TScalar>
 void
-SegmentTree< TScalar >
-::Initialize()
+SegmentTree<TScalar>::Initialize()
 {
   //
   // We don't modify ourselves because the "ReleaseData" methods depend upon
@@ -43,10 +42,9 @@ SegmentTree< TScalar >
   this->Clear();
 }
 
-template< typename TScalar >
+template <typename TScalar>
 void
-SegmentTree< TScalar >
-::PrintSelf(std::ostream & os, Indent indent) const
+SegmentTree<TScalar>::PrintSelf(std::ostream & os, Indent indent) const
 {
   Superclass::PrintSelf(os, indent);
 }
diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTreeGenerator.h b/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTreeGenerator.h
index 78ba8787c2..c36c313460 100644
--- a/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTreeGenerator.h
+++ b/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTreeGenerator.h
@@ -74,73 +74,77 @@ namespace watershed
  * \ingroup WatershedSegmentation
  * \ingroup ITKWatersheds
  */
-template< typename TScalar >
-class ITK_TEMPLATE_EXPORT SegmentTreeGenerator:public ProcessObject
+template <typename TScalar>
+class ITK_TEMPLATE_EXPORT SegmentTreeGenerator : public ProcessObject
 {
 public:
   /**  Standard itk smart pointer declarations    */
-  typedef SegmentTreeGenerator       Self;
-  typedef ProcessObject              Superclass;
-  typedef SmartPointer< Self >       Pointer;
-  typedef SmartPointer< const Self > ConstPointer;
+  using Self = SegmentTreeGenerator;
+  using Superclass = ProcessObject;
+  using Pointer = SmartPointer<Self>;
+  using ConstPointer = SmartPointer<const Self>;
 
   /** Method for creation through the object factory. */
   itkNewMacro(Self);
   itkTypeMacro(WatershedSegmentTreeGenerator, ProcessObject);
 
   /** Convenient type definitions */
-  typedef TScalar                    ScalarType;
-  typedef SegmentTable< ScalarType > SegmentTableType;
-  typedef SegmentTree< ScalarType >  SegmentTreeType;
-  typedef EquivalencyTable           EquivalencyTableType;
-  typedef OneWayEquivalencyTable     OneWayEquivalencyTableType;
-  typedef DataObject::Pointer        DataObjectPointer;
+  using ScalarType = TScalar;
+  using SegmentTableType = SegmentTable<ScalarType>;
+  using SegmentTreeType = SegmentTree<ScalarType>;
+  using EquivalencyTableType = EquivalencyTable;
+  using OneWayEquivalencyTableType = OneWayEquivalencyTable;
+  using DataObjectPointer = DataObject::Pointer;
 
   /** Typedefs to avoid internal compiler error bug on Microsoft VC++ */
-  typedef typename SegmentTableType::Pointer           SegmentTableTypePointer;
-  typedef typename OneWayEquivalencyTableType::Pointer OneWayEquivalencyTableTypePointer;
-  typedef typename SegmentTreeType::Pointer            SegmentTreeTypePointer;
+  using SegmentTableTypePointer = typename SegmentTableType::Pointer;
+  using OneWayEquivalencyTableTypePointer = typename OneWayEquivalencyTableType::Pointer;
+  using SegmentTreeTypePointer = typename SegmentTreeType::Pointer;
 
   /** Get/Set the input table of segments to process */
-  SegmentTableType * GetInputSegmentTable()
+  SegmentTableType *
+  GetInputSegmentTable()
   {
-    return static_cast< SegmentTableType * >( this->ProcessObject::GetInput(0) );
+    return static_cast<SegmentTableType *>(this->ProcessObject::GetInput(0));
   }
 
-  void SetInputSegmentTable(SegmentTableType *st)
+  void
+  SetInputSegmentTable(SegmentTableType * st)
   {
     // Reset the highest calculated flood level if we are given a
     // different input image.
-    if ( st != this->GetInput(0) )
-      {
+    if (st != this->GetInput(0))
+    {
       m_HighestCalculatedFloodLevel = 0.0;
-      }
+    }
     this->ProcessObject::SetNthInput(0, st);
   }
 
   /** Get/Set input table of equivalencies to pre-merge before
    * running the tree generator algorithm.  Only useful for
    * streaming applications */
-  void SetInputEquivalencyTable(EquivalencyTableType *eq)
+  void
+  SetInputEquivalencyTable(EquivalencyTableType * eq)
   {
     this->ProcessObject::SetNthInput(1, eq);
   }
 
-  EquivalencyTableType * GetInputEquivalencyTable()
+  EquivalencyTableType *
+  GetInputEquivalencyTable()
   {
-    return
-      static_cast< EquivalencyTableType * >( this->ProcessObject::GetInput(1) );
+    return static_cast<EquivalencyTableType *>(this->ProcessObject::GetInput(1));
   }
 
   /** Get/Set the output data */
-  SegmentTreeType * GetOutputSegmentTree()
+  SegmentTreeType *
+  GetOutputSegmentTree()
   {
-    return static_cast< SegmentTreeType * >
-           ( this->ProcessObject::GetOutput(0) );
+    return static_cast<SegmentTreeType *>(this->ProcessObject::GetOutput(0));
   }
 
   /** Standard non-threaded itk pipeline method */
-  void GenerateData() ITK_OVERRIDE;
+  void
+  GenerateData() override;
 
   /** Get/Set a boolean flag indicating whether or not to pre-merge the
     segments marked  as equivalent in the EquivalencyTable.  This is only
@@ -154,7 +158,8 @@ public:
    segment table was derived. A value of 0.0 calculates no merges.  A value of
    1.0 calculates all of the potential merges that can occur as the FloodLevel
    is increased to the  maximum saliency value.    */
-  void SetFloodLevel(double);
+  void
+  SetFloodLevel(double);
 
   itkGetConstMacro(FloodLevel, double);
 
@@ -174,32 +179,35 @@ public:
 
   /** Performs a merge of two segments in a SegmentTable according
    * to criteria specific to this algorithm.   */
-  static void MergeSegments(SegmentTableTypePointer,
-                            OneWayEquivalencyTableTypePointer,
-                            const IdentifierType,
-                            const IdentifierType);
+  static void
+  MergeSegments(SegmentTableTypePointer, OneWayEquivalencyTableTypePointer, const IdentifierType, const IdentifierType);
 
   /** This method should not be used.  It will be removed in future versions
    * of this filter. */
-  static void PruneMergeSegments(SegmentTableTypePointer,
-                                 OneWayEquivalencyTableTypePointer,
-                                 const IdentifierType,
-                                 const IdentifierType,
-                                 ScalarType);
+  static void
+  PruneMergeSegments(SegmentTableTypePointer,
+                     OneWayEquivalencyTableTypePointer,
+                     const IdentifierType,
+                     const IdentifierType,
+                     ScalarType);
 
   /** Standard itk::ProcessObject subclass method. */
-  typedef ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
+  using DataObjectPointerArraySizeType = ProcessObject::DataObjectPointerArraySizeType;
   using Superclass::MakeOutput;
-  DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE;
+  DataObjectPointer
+  MakeOutput(DataObjectPointerArraySizeType idx) override;
 
 protected:
   SegmentTreeGenerator();
-  ~SegmentTreeGenerator() ITK_OVERRIDE {}
+  ~SegmentTreeGenerator() override = default;
   SegmentTreeGenerator(const Self &) {}
-  void operator=(const Self &) {}
-  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
+  void
+  operator=(const Self &)
+  {}
+  void
+  PrintSelf(std::ostream & os, Indent indent) const override;
 
-  /** Generates an initial list of all potentential merges in
+  /** Generates an initial list of all potential merges in
    * the segment table.   */
   void CompileMergeList(SegmentTableTypePointer, SegmentTreeTypePointer);
 
@@ -207,20 +215,22 @@ protected:
    * flood level, recomputing new potential merges as it goes.   */
   void ExtractMergeHierarchy(SegmentTableTypePointer, SegmentTreeTypePointer);
 
-  void MergeEquivalencies();
+  void
+  MergeEquivalencies();
 
   /** Methods required by the itk pipeline */
-  void GenerateOutputRequestedRegion(DataObject *output) ITK_OVERRIDE;
+  void
+  GenerateOutputRequestedRegion(DataObject * output) override;
 
-  void GenerateInputRequestedRegion() ITK_OVERRIDE;
+  void
+  GenerateInputRequestedRegion() override;
 
 private:
-  bool   m_Merge;
-  double m_FloodLevel;
-  bool   m_ConsumeInput;
+  bool   m_Merge{ false };
+  double m_FloodLevel{ 0.0 };
+  bool   m_ConsumeInput{ false };
 
-  typedef itksys::hash_map< IdentifierType, bool,
-                            itksys::hash< IdentifierType > >  HashMapType;
+  using HashMapType = std::unordered_map<IdentifierType, bool>;
 
   OneWayEquivalencyTableType::Pointer m_MergedSegmentsTable;
 
@@ -228,13 +238,13 @@ private:
    *  calculated.  m_FloodLevel can be manipulated anywhere below this
    *  level without re-executing the filter, preventing unnecessary
    *  updates. */
-  double m_HighestCalculatedFloodLevel;
+  double m_HighestCalculatedFloodLevel{ 0.0 };
 };
 } // end namespace watershed
 } // end namespace itk
 
 #ifndef ITK_MANUAL_INSTANTIATION
-#include "itkWatershedSegmentTreeGenerator.hxx"
+#  include "itkWatershedSegmentTreeGenerator.hxx"
 #endif
 
 #endif
diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTreeGenerator.hxx b/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTreeGenerator.hxx
index 3c1227901a..7761f8c04b 100644
--- a/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTreeGenerator.hxx
+++ b/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTreeGenerator.hxx
@@ -26,120 +26,125 @@ namespace itk
 {
 namespace watershed
 {
-template< typename TScalar >
-SegmentTreeGenerator< TScalar >
-::SegmentTreeGenerator():m_Merge(false), m_FloodLevel(0.0),
-  m_ConsumeInput(false), m_HighestCalculatedFloodLevel(0.0)
+template <typename TScalar>
+SegmentTreeGenerator<TScalar>::SegmentTreeGenerator()
 {
-  typename SegmentTreeType::Pointer st =
-    static_cast< SegmentTreeType * >( this->MakeOutput(0).GetPointer() );
+  typename SegmentTreeType::Pointer st = static_cast<SegmentTreeType *>(this->MakeOutput(0).GetPointer());
   this->SetNumberOfRequiredOutputs(1);
-  this->ProcessObject::SetNthOutput( 0, st.GetPointer() );
+  this->ProcessObject::SetNthOutput(0, st.GetPointer());
   m_MergedSegmentsTable = OneWayEquivalencyTableType::New();
 }
 
-template< typename TScalar >
-typename SegmentTreeGenerator< TScalar >::DataObjectPointer
-SegmentTreeGenerator< TScalar >
-::MakeOutput( DataObjectPointerArraySizeType itkNotUsed(idx) )
+template <typename TScalar>
+typename SegmentTreeGenerator<TScalar>::DataObjectPointer
+SegmentTreeGenerator<TScalar>::MakeOutput(DataObjectPointerArraySizeType itkNotUsed(idx))
 {
   return SegmentTreeType::New().GetPointer();
 }
 
-template< typename TScalar >
-void SegmentTreeGenerator< TScalar >
-::SetFloodLevel(double val)
+template <typename TScalar>
+void
+SegmentTreeGenerator<TScalar>::SetFloodLevel(double val)
 {
   // Clamp level between 0.0 and 1.0
-  if ( val > 1.0 )         { m_FloodLevel = 1.0; }
-  else if ( val < 0.0 )
-    {
+  if (val > 1.0)
+  {
+    m_FloodLevel = 1.0;
+  }
+  else if (val < 0.0)
+  {
     m_FloodLevel = 0.0;
-    }
-  else                   { m_FloodLevel = val; }
+  }
+  else
+  {
+    m_FloodLevel = val;
+  }
 
   // Has this flood level increased over a level that has already been
   // calculated? If not, then we don't set the modified flag.  A decrease in
   // the flood level does not require re-execution of the filter.
-  if ( m_HighestCalculatedFloodLevel < m_FloodLevel )
-    {
+  if (m_HighestCalculatedFloodLevel < m_FloodLevel)
+  {
     this->Modified();
-    }
+  }
 }
 
-template< typename TScalar >
-void SegmentTreeGenerator< TScalar >
-::GenerateData()
+template <typename TScalar>
+void
+SegmentTreeGenerator<TScalar>::GenerateData()
 {
-  //Reset persistent ivars.
+  // Reset persistent ivars.
   m_MergedSegmentsTable->Clear();
   this->GetOutputSegmentTree()->Clear();
 
   typename SegmentTableType::Pointer input = this->GetInputSegmentTable();
-  typename SegmentTreeType::Pointer mergeList   = SegmentTreeType::New();
+  typename SegmentTreeType::Pointer  mergeList = SegmentTreeType::New();
   typename SegmentTableType::Pointer seg = SegmentTableType::New();
-  if ( m_ConsumeInput == true ) // do not copy input
-    {
+  if (m_ConsumeInput == true) // do not copy input
+  {
     input->Modified();
     input->SortEdgeLists();
 
-    if ( m_Merge == true )   {      this->MergeEquivalencies();    }
+    if (m_Merge == true)
+    {
+      this->MergeEquivalencies();
+    }
 
     this->CompileMergeList(input, mergeList);
     this->ExtractMergeHierarchy(input, mergeList);
-    }
+  }
   else
-    {
+  {
     seg->Copy(*input); // copy the input
     seg->SortEdgeLists();
-    if ( m_Merge == true )   {      this->MergeEquivalencies();    }
+    if (m_Merge == true)
+    {
+      this->MergeEquivalencies();
+    }
     this->CompileMergeList(seg, mergeList);
     this->ExtractMergeHierarchy(seg, mergeList);
-    }
+  }
   this->UpdateProgress(1.0);
 
   // Keep track of the highest flood level we calculated
-  if ( m_FloodLevel > m_HighestCalculatedFloodLevel )
-    {
+  if (m_FloodLevel > m_HighestCalculatedFloodLevel)
+  {
     m_HighestCalculatedFloodLevel = m_FloodLevel;
-    }
+  }
 }
 
-template< typename TScalar >
-void SegmentTreeGenerator< TScalar >
-::MergeEquivalencies()
+template <typename TScalar>
+void
+SegmentTreeGenerator<TScalar>::MergeEquivalencies()
 {
-  typename SegmentTableType::Pointer segTable = this->GetInputSegmentTable();
-  typename EquivalencyTableType::Pointer eqTable  =
-    this->GetInputEquivalencyTable();
+  typename SegmentTableType::Pointer      segTable = this->GetInputSegmentTable();
+  typename EquivalencyTableType::Pointer  eqTable = this->GetInputEquivalencyTable();
   typename EquivalencyTableType::Iterator it;
-  ScalarType threshold = static_cast< ScalarType >( m_FloodLevel * segTable->GetMaximumDepth() );
+  auto threshold = static_cast<ScalarType>(m_FloodLevel * segTable->GetMaximumDepth());
 
   eqTable->Flatten();
   IdentifierType counter = 0;
 
   segTable->PruneEdgeLists(threshold);
 
-  for ( it = eqTable->Begin(); it != eqTable->End(); ++it )
-    {
-    MergeSegments(segTable, m_MergedSegmentsTable,
-                  ( *it ).first, ( *it ).second);  // Merge first INTO second.
+  for (it = eqTable->Begin(); it != eqTable->End(); ++it)
+  {
+    MergeSegments(segTable, m_MergedSegmentsTable, (*it).first, (*it).second); // Merge first INTO second.
     // deletes first
-    if ( ( counter % 10000 ) == 0 )
-      {
+    if ((counter % 10000) == 0)
+    {
       segTable->PruneEdgeLists(threshold);
       m_MergedSegmentsTable->Flatten();
       counter = 0;
-      }
+    }
 
     counter++;
-    }
+  }
 }
 
-template< typename TScalar >
-void SegmentTreeGenerator< TScalar >
-::CompileMergeList(SegmentTableTypePointer segments,
-                   SegmentTreeTypePointer mergeList)
+template <typename TScalar>
+void
+SegmentTreeGenerator<TScalar>::CompileMergeList(SegmentTableTypePointer segments, SegmentTreeTypePointer mergeList)
 {
   typename SegmentTreeType::merge_t tempMerge;
 
@@ -148,113 +153,109 @@ void SegmentTreeGenerator< TScalar >
   // 1) Depth of B < L
   // 2) A is across the lowest edge of B
   typename SegmentTableType::Iterator segment_ptr;
-  IdentifierType labelFROM;
-  IdentifierType labelTO;
-  ScalarType    threshold = static_cast< ScalarType >( m_FloodLevel * segments->GetMaximumDepth() );
+  IdentifierType                      labelFROM;
+  IdentifierType                      labelTO;
+  auto                                threshold = static_cast<ScalarType>(m_FloodLevel * segments->GetMaximumDepth());
   m_MergedSegmentsTable->Flatten();
 
   segments->PruneEdgeLists(threshold);
 
-  for ( segment_ptr = segments->Begin(); segment_ptr != segments->End();
-        ++segment_ptr )
-    {
-    labelFROM = ( *segment_ptr ).first;
+  for (segment_ptr = segments->Begin(); segment_ptr != segments->End(); ++segment_ptr)
+  {
+    labelFROM = (*segment_ptr).first;
 
     // Must take into account any equivalencies that have already been
     // recorded.
-    labelTO =
-      m_MergedSegmentsTable->RecursiveLookup( ( *segment_ptr ).second.edge_list.front().label );
-    while ( labelTO == labelFROM ) // Pop off any bogus merges with ourself
-      {                            // that may have been left in this list.
-      ( *segment_ptr ).second.edge_list.pop_front();
-      labelTO =
-        m_MergedSegmentsTable->RecursiveLookup( ( *segment_ptr ).second.edge_list.front().label );
-      }
+    labelTO = m_MergedSegmentsTable->RecursiveLookup((*segment_ptr).second.edge_list.front().label);
+    while (labelTO == labelFROM) // Pop off any bogus merges with ourself
+    {                            // that may have been left in this list.
+      (*segment_ptr).second.edge_list.pop_front();
+      labelTO = m_MergedSegmentsTable->RecursiveLookup((*segment_ptr).second.edge_list.front().label);
+    }
 
     // Add this merge to our list if its saliency is below
     // the threshold.
-    tempMerge.from     = labelFROM;
-    tempMerge.to       = labelTO;
-    tempMerge.saliency = ( *segment_ptr ).second.edge_list.front().height
-                         - ( *segment_ptr ).second.min;
-    if ( tempMerge.saliency < threshold )
-      {
+    tempMerge.from = labelFROM;
+    tempMerge.to = labelTO;
+    tempMerge.saliency = (*segment_ptr).second.edge_list.front().height - (*segment_ptr).second.min;
+    if (tempMerge.saliency < threshold)
+    {
       mergeList->PushBack(tempMerge);
-      }
     }
+  }
 
   // Heapsort the list
-  typedef typename SegmentTreeType::merge_comp MergeComparison;
-  std::make_heap( mergeList->Begin(), mergeList->End(), MergeComparison() );
+  using MergeComparison = typename SegmentTreeType::merge_comp;
+  std::make_heap(mergeList->Begin(), mergeList->End(), MergeComparison());
 }
 
-template< typename TScalar >
-void SegmentTreeGenerator< TScalar >
-::ExtractMergeHierarchy(SegmentTableTypePointer segments,
-                        SegmentTreeTypePointer heap)
+template <typename TScalar>
+void
+SegmentTreeGenerator<TScalar>::ExtractMergeHierarchy(SegmentTableTypePointer segments, SegmentTreeTypePointer heap)
 {
   typename SegmentTreeType::Pointer list = this->GetOutputSegmentTree();
 
   // Merges segments up to a specified floodlevel according to the information
   // in the heap of merges.  As two segments are merged, calculates a new
   // possible merges and pushes it onto the heap.
-  ScalarType threshold = static_cast< ScalarType >( m_FloodLevel * segments->GetMaximumDepth() );
+  auto threshold = static_cast<ScalarType>(m_FloodLevel * segments->GetMaximumDepth());
 
   unsigned counter;
-  typedef typename SegmentTreeType::merge_comp MergeComparison;
-  typename SegmentTableType::DataType  * toSeg;
-  typename SegmentTreeType::ValueType tempMerge;
-  IdentifierType toSegLabel, fromSegLabel;
+  using MergeComparison = typename SegmentTreeType::merge_comp;
+  typename SegmentTableType::DataType * toSeg;
+  typename SegmentTreeType::ValueType   tempMerge;
+  IdentifierType                        toSegLabel, fromSegLabel;
 
-  if ( heap->Empty() ) { return; }
-  double initHeapSize = static_cast< double >( heap->Size() );
+  if (heap->Empty())
+  {
+    return;
+  }
+  auto initHeapSize = static_cast<double>(heap->Size());
 
   counter = 0;
   typename SegmentTreeType::ValueType topMerge = heap->Front();
 
-  while ( ( !heap->Empty() ) && ( topMerge.saliency <= threshold ) )
-    {
-    counter++;                  // Every so often we should eliminate
-    if ( counter == 10000 )     // all the recursion in our records
-      {                         // of which segments have merged.
+  while ((!heap->Empty()) && (topMerge.saliency <= threshold))
+  {
+    counter++;            // Every so often we should eliminate
+    if (counter == 10000) // all the recursion in our records
+    {                     // of which segments have merged.
       counter = 0;
       segments->PruneEdgeLists(threshold); // also we want to
       // keep the edge list size under control
-      }
-    if ( ( counter % 10000 ) == 0 )
-      {
+    }
+    if ((counter % 10000) == 0)
+    {
       m_MergedSegmentsTable->Flatten();
-      }
+    }
 
-    if ( ( counter % 1000 ) == 0 )
-      {
-      this->UpdateProgress( 1.0 - ( ( static_cast< double >( heap->Size() ) )
-                                    / initHeapSize ) );
-      }
+    if ((counter % 1000) == 0)
+    {
+      this->UpdateProgress(1.0 - ((static_cast<double>(heap->Size())) / initHeapSize));
+    }
 
-    std::pop_heap( heap->Begin(), heap->End(), MergeComparison() );
-    heap->PopBack();  // Popping the heap moves the top element to the end
+    std::pop_heap(heap->Begin(), heap->End(), MergeComparison());
+    heap->PopBack(); // Popping the heap moves the top element to the end
     // of the container structure, so we delete that here.
 
     // Recursively find the segments we are about to merge
     // (the labels identified here may have merged already)
     fromSegLabel = m_MergedSegmentsTable->RecursiveLookup(topMerge.from);
-    toSegLabel   = m_MergedSegmentsTable->RecursiveLookup(topMerge.to);
+    toSegLabel = m_MergedSegmentsTable->RecursiveLookup(topMerge.to);
 
     // If the two segments do not resolve to the same segment and the
     // "TO" segment has never been merged, then then merge them.
     // Otherwise, ignore this particular entry.
-    if ( fromSegLabel == topMerge.from && fromSegLabel != toSegLabel )
-      {
-      toSeg   = segments->Lookup(toSegLabel);
+    if (fromSegLabel == topMerge.from && fromSegLabel != toSegLabel)
+    {
+      toSeg = segments->Lookup(toSegLabel);
 
       topMerge.from = fromSegLabel;
-      topMerge.to   = toSegLabel;
-      list->PushBack(topMerge);  // Record this merge for posterity
+      topMerge.to = toSegLabel;
+      list->PushBack(topMerge); // Record this merge for posterity
 
       // Merge the segments
-      Self::MergeSegments(segments, m_MergedSegmentsTable,
-                          fromSegLabel, toSegLabel);
+      Self::MergeSegments(segments, m_MergedSegmentsTable, fromSegLabel, toSegLabel);
 
       // Now check for new possible merges in A.
       // All we have to do is look at the front of the
@@ -262,54 +263,54 @@ void SegmentTreeGenerator< TScalar >
 
       // Recursively look up the label to which we might
       // be merging to.
-      if ( !toSeg->edge_list.empty() )
-        {
-        tempMerge.from = toSegLabel;  // The new, composite segment
-        tempMerge.to   = m_MergedSegmentsTable->RecursiveLookup(
-          toSeg->edge_list.front().label);
-        while ( tempMerge.to == tempMerge.from )
-          {   // We don't want to merge to ourself.
+      if (!toSeg->edge_list.empty())
+      {
+        tempMerge.from = toSegLabel; // The new, composite segment
+        tempMerge.to = m_MergedSegmentsTable->RecursiveLookup(toSeg->edge_list.front().label);
+        while (tempMerge.to == tempMerge.from)
+        { // We don't want to merge to ourself.
           toSeg->edge_list.pop_front();
-          tempMerge.to = m_MergedSegmentsTable->RecursiveLookup(
-            toSeg->edge_list.front().label);
-          }
-        tempMerge.saliency =
-          ( toSeg->edge_list.front().height ) - toSeg->min;
+          tempMerge.to = m_MergedSegmentsTable->RecursiveLookup(toSeg->edge_list.front().label);
+        }
+        tempMerge.saliency = (toSeg->edge_list.front().height) - toSeg->min;
 
         heap->PushBack(tempMerge);
-        std::push_heap( heap->Begin(), heap->End(), MergeComparison() );
-        }
+        std::push_heap(heap->Begin(), heap->End(), MergeComparison());
       }
-    if ( !heap->Empty() )
-      {
+    }
+    if (!heap->Empty())
+    {
       topMerge = heap->Front();
-      }
     }
+  }
 }
 
-template< typename TScalar >
-void SegmentTreeGenerator< TScalar >
-::PruneMergeSegments(SegmentTableTypePointer segments,
-                     OneWayEquivalencyTableTypePointer eqT,
-                     const IdentifierType FROM, const IdentifierType TO,
-                     ScalarType )
+template <typename TScalar>
+void
+SegmentTreeGenerator<TScalar>::PruneMergeSegments(SegmentTableTypePointer           segments,
+                                                  OneWayEquivalencyTableTypePointer eqT,
+                                                  const IdentifierType              FROM,
+                                                  const IdentifierType              TO,
+                                                  ScalarType)
 {
-  typename SegmentTableType::edge_list_t::iterator edgeTOi, edgeFROMi,
-  edgeTEMPi;
-  HashMapType seen_table;
-  IdentifierType labelTO, labelFROM;
+  typename SegmentTableType::edge_list_t::iterator edgeTOi, edgeFROMi, edgeTEMPi;
+  HashMapType                                      seen_table;
+  IdentifierType                                   labelTO, labelFROM;
 
   // Lookup both entries.
   typename SegmentTableType::segment_t * from_seg = segments->Lookup(FROM);
-  typename SegmentTableType::segment_t * to_seg   = segments->Lookup(TO);
+  typename SegmentTableType::segment_t * to_seg = segments->Lookup(TO);
 
-  if ( from_seg == 0 || to_seg == 0 )
-    {
-    itkGenericExceptionMacro (<< "PruneMergeSegments:: An unexpected and fatal error has occurred.");
-    }
+  if (from_seg == 0 || to_seg == 0)
+  {
+    itkGenericExceptionMacro(<< "PruneMergeSegments:: An unexpected and fatal error has occurred.");
+  }
 
   // Compare the minimum values.
-  if ( ( from_seg->min ) < ( to_seg->min ) ) { ( to_seg->min ) = ( from_seg->min ); }
+  if ((from_seg->min) < (to_seg->min))
+  {
+    (to_seg->min) = (from_seg->min);
+  }
 
   // Add all the "FROM" edges to the "TO" edges.
 
@@ -323,90 +324,97 @@ void SegmentTreeGenerator< TScalar >
   // but rather will be resolved later through the one-way
   // equivalency table.
 
-  edgeTOi   = to_seg->edge_list.begin();
+  edgeTOi = to_seg->edge_list.begin();
   edgeFROMi = from_seg->edge_list.begin();
-  while ( edgeTOi != to_seg->edge_list.end()
-          && edgeFROMi != from_seg->edge_list.end() )
-    {
+  while (edgeTOi != to_seg->edge_list.end() && edgeFROMi != from_seg->edge_list.end())
+  {
     // Recursively resolve the labels we are seeing
-    labelTO   = eqT->RecursiveLookup(edgeTOi->label);
+    labelTO = eqT->RecursiveLookup(edgeTOi->label);
     labelFROM = eqT->RecursiveLookup(edgeFROMi->label);
 
     // Ignore any labels already in this list and
     // any pointers back to ourself.
     // This step is necessary to keep the edge lists from
     // growing exponentially in size as segments merge.
-    if ( seen_table.find(labelTO) != seen_table.end()
-         || labelTO == FROM )
-      {
+    if (seen_table.find(labelTO) != seen_table.end() || labelTO == FROM)
+    {
       edgeTEMPi = edgeTOi;
       edgeTEMPi++;
       to_seg->edge_list.erase(edgeTOi);
       edgeTOi = edgeTEMPi;
       continue;
-      }
-    if ( seen_table.find(labelFROM) != seen_table.end()
-         || labelFROM == TO )
-      {
+    }
+    if (seen_table.find(labelFROM) != seen_table.end() || labelFROM == TO)
+    {
       edgeFROMi++;
       continue;
-      }
+    }
 
     // Fix any changed labels since we have the chance
-    if ( labelTO   != edgeTOi->label  ) { edgeTOi->label = labelTO; }
-    if ( labelFROM != edgeFROMi->label ) { edgeFROMi->label = labelFROM; }
+    if (labelTO != edgeTOi->label)
+    {
+      edgeTOi->label = labelTO;
+    }
+    if (labelFROM != edgeFROMi->label)
+    {
+      edgeFROMi->label = labelFROM;
+    }
 
     // Which edge is next in the list?
-    if ( edgeFROMi->height < edgeTOi->height )
-      {
+    if (edgeFROMi->height < edgeTOi->height)
+    {
       to_seg->edge_list.insert(edgeTOi, *edgeFROMi);
-      seen_table.insert( HashMapType::value_type(labelFROM, true) );
+      seen_table.insert(HashMapType::value_type(labelFROM, true));
       edgeFROMi++;
-      }
+    }
     else
-      {
-      seen_table.insert( HashMapType::value_type(labelTO, true) );
+    {
+      seen_table.insert(HashMapType::value_type(labelTO, true));
       edgeTOi++;
-      }
     }
+  }
 
   // Process tail of the FROM list.
-  while ( edgeFROMi != from_seg->edge_list.end() )
-    {
+  while (edgeFROMi != from_seg->edge_list.end())
+  {
     labelFROM = eqT->RecursiveLookup(edgeFROMi->label);
-    if ( seen_table.find(labelFROM) != seen_table.end()
-         || labelFROM == TO )
-      {
+    if (seen_table.find(labelFROM) != seen_table.end() || labelFROM == TO)
+    {
       edgeFROMi++;
-      }
+    }
     else
+    {
+      if (labelFROM != edgeFROMi->label)
       {
-      if ( labelFROM != edgeFROMi->label ) { edgeFROMi->label = labelFROM; }
+        edgeFROMi->label = labelFROM;
+      }
       to_seg->edge_list.push_back(*edgeFROMi);
-      seen_table.insert( HashMapType::value_type(labelFROM, true) );
+      seen_table.insert(HashMapType::value_type(labelFROM, true));
       edgeFROMi++;
-      }
     }
+  }
 
   // Process tail of the TO list.
-  while ( edgeTOi != to_seg->edge_list.end() )
+  while (edgeTOi != to_seg->edge_list.end())
+  {
+    labelTO = eqT->RecursiveLookup(edgeTOi->label);
+    if (seen_table.find(labelTO) != seen_table.end() || labelTO == FROM)
     {
-    labelTO   = eqT->RecursiveLookup(edgeTOi->label);
-    if ( seen_table.find(labelTO) != seen_table.end()
-         || labelTO == FROM )
-      {
       edgeTEMPi = edgeTOi;
       edgeTEMPi++;
       to_seg->edge_list.erase(edgeTOi);
       edgeTOi = edgeTEMPi;
-      }
+    }
     else
+    {
+      if (labelTO != edgeTOi->label)
       {
-      if ( labelTO   != edgeTOi->label  ) { edgeTOi->label = labelTO; }
-      seen_table.insert( HashMapType::value_type(labelTO, true) );
-      edgeTOi++;
+        edgeTOi->label = labelTO;
       }
+      seen_table.insert(HashMapType::value_type(labelTO, true));
+      edgeTOi++;
     }
+  }
 
   // Now destroy the segment that was merged.
   segments->Erase(FROM);
@@ -415,30 +423,32 @@ void SegmentTreeGenerator< TScalar >
   eqT->Add(FROM, TO);
 }
 
-template< typename TScalar >
-void SegmentTreeGenerator< TScalar >
-::MergeSegments(SegmentTableTypePointer segments,
-                OneWayEquivalencyTableTypePointer eqT,
-                const IdentifierType FROM, const IdentifierType TO)
+template <typename TScalar>
+void
+SegmentTreeGenerator<TScalar>::MergeSegments(SegmentTableTypePointer           segments,
+                                             OneWayEquivalencyTableTypePointer eqT,
+                                             const IdentifierType              FROM,
+                                             const IdentifierType              TO)
 {
-  typename SegmentTableType::edge_list_t::iterator edgeTOi, edgeFROMi,
-  edgeTEMPi;
-  HashMapType seen_table;
-  IdentifierType labelTO, labelFROM;
+  typename SegmentTableType::edge_list_t::iterator edgeTOi, edgeFROMi, edgeTEMPi;
+  HashMapType                                      seen_table;
+  IdentifierType                                   labelTO, labelFROM;
 
   // Lookup both entries.
   typename SegmentTableType::segment_t * from_seg = segments->Lookup(FROM);
-  typename SegmentTableType::segment_t * to_seg   = segments->Lookup(TO);
+  typename SegmentTableType::segment_t * to_seg = segments->Lookup(TO);
 
-  if ( from_seg == ITK_NULLPTR || to_seg == ITK_NULLPTR )
-    {
-    itkGenericExceptionMacro (
-      <<
-      "itk::watershed::SegmentTreeGenerator::MergeSegments:: An unexpected and fatal error has occurred. This is probably the result of overthresholding of the input image.");
-    }
+  if (from_seg == nullptr || to_seg == nullptr)
+  {
+    itkGenericExceptionMacro(<< "itk::watershed::SegmentTreeGenerator::MergeSegments:: An unexpected and fatal error "
+                                "has occurred. This is probably the result of overthresholding of the input image.");
+  }
 
   // Compare the minimum values.
-  if ( ( from_seg->min ) < ( to_seg->min ) ) { ( to_seg->min ) = ( from_seg->min ); }
+  if ((from_seg->min) < (to_seg->min))
+  {
+    (to_seg->min) = (from_seg->min);
+  }
 
   // Add all the "FROM" edges to the "TO" edges.
 
@@ -452,90 +462,97 @@ void SegmentTreeGenerator< TScalar >
   // but rather will be resolved later through the one-way
   // equivalency table.
 
-  edgeTOi   = to_seg->edge_list.begin();
+  edgeTOi = to_seg->edge_list.begin();
   edgeFROMi = from_seg->edge_list.begin();
-  while ( edgeTOi != to_seg->edge_list.end()
-          && edgeFROMi != from_seg->edge_list.end() )
-    {
+  while (edgeTOi != to_seg->edge_list.end() && edgeFROMi != from_seg->edge_list.end())
+  {
     // Recursively resolve the labels we are seeing
-    labelTO   = eqT->RecursiveLookup(edgeTOi->label);
+    labelTO = eqT->RecursiveLookup(edgeTOi->label);
     labelFROM = eqT->RecursiveLookup(edgeFROMi->label);
 
     // Ignore any labels already in this list and
     // any pointers back to ourself.
     // This step is necessary to keep the edge lists from
     // growing exponentially in size as segments merge.
-    if ( seen_table.find(labelTO) != seen_table.end()
-         || labelTO == FROM )
-      {
+    if (seen_table.find(labelTO) != seen_table.end() || labelTO == FROM)
+    {
       edgeTEMPi = edgeTOi;
       edgeTEMPi++;
       to_seg->edge_list.erase(edgeTOi);
       edgeTOi = edgeTEMPi;
       continue;
-      }
-    if ( seen_table.find(labelFROM) != seen_table.end()
-         || labelFROM == TO )
-      {
+    }
+    if (seen_table.find(labelFROM) != seen_table.end() || labelFROM == TO)
+    {
       edgeFROMi++;
       continue;
-      }
+    }
 
     // Fix any changed labels since we have the chance
-    if ( labelTO   != edgeTOi->label  ) { edgeTOi->label = labelTO; }
-    if ( labelFROM != edgeFROMi->label ) { edgeFROMi->label = labelFROM; }
+    if (labelTO != edgeTOi->label)
+    {
+      edgeTOi->label = labelTO;
+    }
+    if (labelFROM != edgeFROMi->label)
+    {
+      edgeFROMi->label = labelFROM;
+    }
 
     // Which edge is next in the list?
-    if ( edgeFROMi->height < edgeTOi->height )
-      {
+    if (edgeFROMi->height < edgeTOi->height)
+    {
       to_seg->edge_list.insert(edgeTOi, *edgeFROMi);
-      seen_table.insert( HashMapType::value_type(labelFROM, true) );
+      seen_table.insert(HashMapType::value_type(labelFROM, true));
       edgeFROMi++;
-      }
+    }
     else
-      {
-      seen_table.insert( HashMapType::value_type(labelTO, true) );
+    {
+      seen_table.insert(HashMapType::value_type(labelTO, true));
       edgeTOi++;
-      }
     }
+  }
 
   // Process tail of the FROM list.
-  while ( edgeFROMi != from_seg->edge_list.end() )
-    {
+  while (edgeFROMi != from_seg->edge_list.end())
+  {
     labelFROM = eqT->RecursiveLookup(edgeFROMi->label);
-    if ( seen_table.find(labelFROM) != seen_table.end()
-         || labelFROM == TO )
-      {
+    if (seen_table.find(labelFROM) != seen_table.end() || labelFROM == TO)
+    {
       edgeFROMi++;
-      }
+    }
     else
+    {
+      if (labelFROM != edgeFROMi->label)
       {
-      if ( labelFROM != edgeFROMi->label ) { edgeFROMi->label = labelFROM; }
+        edgeFROMi->label = labelFROM;
+      }
       to_seg->edge_list.push_back(*edgeFROMi);
-      seen_table.insert( HashMapType::value_type(labelFROM, true) );
+      seen_table.insert(HashMapType::value_type(labelFROM, true));
       edgeFROMi++;
-      }
     }
+  }
 
   // Process tail of the TO list.
-  while ( edgeTOi != to_seg->edge_list.end() )
+  while (edgeTOi != to_seg->edge_list.end())
+  {
+    labelTO = eqT->RecursiveLookup(edgeTOi->label);
+    if (seen_table.find(labelTO) != seen_table.end() || labelTO == FROM)
     {
-    labelTO   = eqT->RecursiveLookup(edgeTOi->label);
-    if ( seen_table.find(labelTO) != seen_table.end()
-         || labelTO == FROM )
-      {
       edgeTEMPi = edgeTOi;
       edgeTEMPi++;
       to_seg->edge_list.erase(edgeTOi);
       edgeTOi = edgeTEMPi;
-      }
+    }
     else
+    {
+      if (labelTO != edgeTOi->label)
       {
-      if ( labelTO   != edgeTOi->label  ) { edgeTOi->label = labelTO; }
-      seen_table.insert( HashMapType::value_type(labelTO, true) );
-      edgeTOi++;
+        edgeTOi->label = labelTO;
       }
+      seen_table.insert(HashMapType::value_type(labelTO, true));
+      edgeTOi++;
     }
+  }
 
   // Now destroy the segment that was merged.
   segments->Erase(FROM);
@@ -544,14 +561,14 @@ void SegmentTreeGenerator< TScalar >
   eqT->Add(FROM, TO);
 }
 
-template< typename TScalar >
-void SegmentTreeGenerator< TScalar >
-::GenerateOutputRequestedRegion( DataObject *itkNotUsed(output) )
+template <typename TScalar>
+void
+SegmentTreeGenerator<TScalar>::GenerateOutputRequestedRegion(DataObject * itkNotUsed(output))
 {}
 
-template< typename TScalar >
-void SegmentTreeGenerator< TScalar >
-::GenerateInputRequestedRegion()
+template <typename TScalar>
+void
+SegmentTreeGenerator<TScalar>::GenerateInputRequestedRegion()
 {
   Superclass::GenerateInputRequestedRegion();
 
@@ -567,17 +584,15 @@ void SegmentTreeGenerator< TScalar >
   //    }
 }
 
-template< typename TScalar >
+template <typename TScalar>
 void
-SegmentTreeGenerator< TScalar >
-::PrintSelf(std::ostream & os, Indent indent) const
+SegmentTreeGenerator<TScalar>::PrintSelf(std::ostream & os, Indent indent) const
 {
   Superclass::PrintSelf(os, indent);
   os << indent << "FloodLevel: " << m_FloodLevel << std::endl;
   os << indent << "Merge: " << m_Merge << std::endl;
   os << indent << "ConsumeInput: " << m_ConsumeInput << std::endl;
-  os << indent << "HighestCalculatedFloodLevel: "
-     << m_HighestCalculatedFloodLevel << std::endl;
+  os << indent << "HighestCalculatedFloodLevel: " << m_HighestCalculatedFloodLevel << std::endl;
 }
 } // end namespace watershed
 } // end namespace itk
diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedSegmenter.h b/Modules/Segmentation/Watersheds/include/itkWatershedSegmenter.h
index 518e507c70..9452e421ac 100644
--- a/Modules/Segmentation/Watersheds/include/itkWatershedSegmenter.h
+++ b/Modules/Segmentation/Watersheds/include/itkWatershedSegmenter.h
@@ -84,95 +84,104 @@ namespace watershed
  * \ingroup WatershedSegmentation
  * \ingroup ITKWatersheds
  */
-template< typename TInputImage >
-class ITK_TEMPLATE_EXPORT Segmenter:
-  public ProcessObject
+template <typename TInputImage>
+class ITK_TEMPLATE_EXPORT Segmenter : public ProcessObject
 {
 public:
-  /** Standard self typedefs */
-  typedef Segmenter Self;
+  /** Standard self type alias */
+  using Self = Segmenter;
 
   /** Define image types and dimensionality  */
-  typedef TInputImage InputImageType;
-  itkStaticConstMacro(ImageDimension, unsigned int,
-                      TInputImage::ImageDimension);
-
-  typedef Image< IdentifierType, itkGetStaticConstMacro(ImageDimension) >
-  OutputImageType;
-  typedef typename InputImageType::RegionType ImageRegionType;
-  typedef typename InputImageType::PixelType  InputPixelType;
-  typedef Boundary< InputPixelType, itkGetStaticConstMacro(ImageDimension) >
-  BoundaryType;
-  typedef typename BoundaryType::IndexType         BoundaryIndexType;
-  typedef typename BoundaryType::FlatHashValueType BoundaryFlatHashValueType;
-  typedef SegmentTable< InputPixelType >           SegmentTableType;
-  typedef DataObject::Pointer                      DataObjectPointer;
+  using InputImageType = TInputImage;
+  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
+
+  using OutputImageType = Image<IdentifierType, Self::ImageDimension>;
+  using ImageRegionType = typename InputImageType::RegionType;
+  using InputPixelType = typename InputImageType::PixelType;
+  using BoundaryType = Boundary<InputPixelType, Self::ImageDimension>;
+  using BoundaryIndexType = typename BoundaryType::IndexType;
+  using BoundaryFlatHashValueType = typename BoundaryType::FlatHashValueType;
+  using SegmentTableType = SegmentTable<InputPixelType>;
+  using DataObjectPointer = DataObject::Pointer;
 
   /** Methods to implement smart pointers and work with the itk object factory
    */
-  typedef ProcessObject              Superclass;
-  typedef SmartPointer< Self >       Pointer;
-  typedef SmartPointer< const Self > ConstPointer;
+  using Superclass = ProcessObject;
+  using Pointer = SmartPointer<Self>;
+  using ConstPointer = SmartPointer<const Self>;
   itkNewMacro(Self);
   itkTypeMacro(WatershedSegmenter, ProcessObject);
 
   /** Typedefs necessary on microsoft VC++ to avoid internal compiler errors */
-  typedef typename InputImageType::Pointer   InputImageTypePointer;
-  typedef typename OutputImageType::Pointer  OutputImageTypePointer;
-  typedef typename SegmentTableType::Pointer SegmentTableTypePointer;
-  typedef typename BoundaryType::Pointer     BoundaryTypePointer;
+  using InputImageTypePointer = typename InputImageType::Pointer;
+  using OutputImageTypePointer = typename OutputImageType::Pointer;
+  using SegmentTableTypePointer = typename SegmentTableType::Pointer;
+  using BoundaryTypePointer = typename BoundaryType::Pointer;
 
   /** A constant used in the labeling algorithm.  */
-  itkStaticConstMacro(NULL_LABEL, IdentifierType, 0);
+  static constexpr IdentifierType NULL_LABEL = 0;
 
   /** A constant used in the labeling algorithm.  */
-  itkStaticConstMacro(NULL_FLOW, short, -1);
+  static constexpr short NULL_FLOW = -1;
 
   /** Get/Set the input image.   */
-  InputImageType * GetInputImage(void)
+  InputImageType *
+  GetInputImage()
   {
-    return itkDynamicCastInDebugMode< InputImageType * >
-           ( this->ProcessObject::GetInput(0) );
+    return itkDynamicCastInDebugMode<InputImageType *>(this->ProcessObject::GetInput(0));
   }
 
-  void SetInputImage(InputImageType *img)
-  {  this->ProcessObject::SetNthInput(0, img); }
+  void
+  SetInputImage(InputImageType * img)
+  {
+    this->ProcessObject::SetNthInput(0, img);
+  }
 
   /** Get/Set the labeled output image.  The output image is always of
     IdentifierType integers. */
-  OutputImageType * GetOutputImage(void)
+  OutputImageType *
+  GetOutputImage()
   {
-    return itkDynamicCastInDebugMode< OutputImageType * >
-           ( this->ProcessObject::GetOutput(0) );
+    return itkDynamicCastInDebugMode<OutputImageType *>(this->ProcessObject::GetOutput(0));
   }
 
-  void SetOutputImage(OutputImageType *img)
-  { this->ProcessObject::SetNthOutput(0, img);    }
+  void
+  SetOutputImage(OutputImageType * img)
+  {
+    this->ProcessObject::SetNthOutput(0, img);
+  }
 
   /** Get/Set the segment table.  The segment table is a table of segmentation
    * information identifying each region produced by the labeling algorithm. */
-  SegmentTableType * GetSegmentTable(void)
+  SegmentTableType *
+  GetSegmentTable()
   {
-    return itkDynamicCastInDebugMode< SegmentTableType * >
-           ( this->ProcessObject::GetOutput(1) );
+    return itkDynamicCastInDebugMode<SegmentTableType *>(this->ProcessObject::GetOutput(1));
   }
 
-  void SetSegmentTable(SegmentTableType *s)
-  { this->ProcessObject::SetNthOutput(1, s); }
+  void
+  SetSegmentTable(SegmentTableType * s)
+  {
+    this->ProcessObject::SetNthOutput(1, s);
+  }
 
   /** Returns the boundary information data necessary only for data streaming
     applications.  */
-  BoundaryType * GetBoundary(void)
+  BoundaryType *
+  GetBoundary()
   {
-    return itkDynamicCastInDebugMode< BoundaryType * >
-           ( this->ProcessObject::GetOutput(2) );
+    return itkDynamicCastInDebugMode<BoundaryType *>(this->ProcessObject::GetOutput(2));
   }
 
-  void SetBoundary(BoundaryType *b)
-  { this->ProcessObject::SetNthOutput(2, b); }
+  void
+  SetBoundary(BoundaryType * b)
+  {
+    this->ProcessObject::SetNthOutput(2, b);
+  }
 
   /** Standard non-threaded pipeline execution method. */
-  void GenerateData() ITK_OVERRIDE;
+  void
+  GenerateData() override;
 
   /** This method is necessary until the streaming mechanisms of the Itk
    * pipeline are full fleshed out.  It is only used for streaming
@@ -180,26 +189,32 @@ public:
    * complete volume being streamed.  The member variables controlled by
    * this method will not be modified by the Itk pipeline and are necessary
    * for analysis of boundaries.   */
-  void SetLargestPossibleRegion(ImageRegionType reg)
+  void
+  SetLargestPossibleRegion(ImageRegionType reg)
   {
-    if ( reg == m_LargestPossibleRegion ) { return; }
+    if (reg == m_LargestPossibleRegion)
+    {
+      return;
+    }
     m_LargestPossibleRegion = reg;
     this->Modified();
   }
 
-  ImageRegionType GetLargestPossibleRegion() const
-  { return m_LargestPossibleRegion; }
+  ImageRegionType
+  GetLargestPossibleRegion() const
+  {
+    return m_LargestPossibleRegion;
+  }
 
   /** Helper function.  Other classes may have occasion to use this. Relabels
       an image according to a table of equivalencies. */
-  static void RelabelImage(OutputImageTypePointer,
-                           ImageRegionType,
-                           EquivalencyTable::Pointer);
+  static void RelabelImage(OutputImageTypePointer, ImageRegionType, EquivalencyTable::Pointer);
 
   /** Standard itk::ProcessObject subclass method. */
-  typedef ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
+  using DataObjectPointerArraySizeType = ProcessObject::DataObjectPointerArraySizeType;
   using Superclass::MakeOutput;
-  DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE;
+  DataObjectPointer
+  MakeOutput(DataObjectPointerArraySizeType idx) override;
 
   /** Gets/Sets the initial label (IdentifierType integer value) used
    * by the labeling algorithm.  Only necessary for streaming applications. */
@@ -235,22 +250,23 @@ public:
 protected:
   /** Structure storing information about image flat regions.
    * Flat regions are connected pixels of the same value.  */
-  struct flat_region_t {
-    IdentifierType *min_label_ptr;
-    InputPixelType bounds_min;
+  struct flat_region_t
+  {
+    IdentifierType * min_label_ptr;
+    InputPixelType   bounds_min;
     //    InputPixelType  bounds_max; // <-- may not be necc.
     InputPixelType value;
-    bool is_on_boundary;
-    flat_region_t():is_on_boundary(false) {}
+    bool           is_on_boundary{ false };
+    flat_region_t() {}
   };
 
   /** Table for storing flat region information.  */
-  typedef itksys::hash_map< IdentifierType, flat_region_t, itksys::hash< IdentifierType > >
-  flat_region_table_t;
+  using flat_region_table_t = std::unordered_map<IdentifierType, flat_region_t>;
 
-  struct connectivity_t {
-    unsigned int size;
-    unsigned int *index;
+  struct connectivity_t
+  {
+    unsigned int                          size;
+    unsigned int *                        index;
     typename InputImageType::OffsetType * direction;
   };
 
@@ -258,54 +274,57 @@ protected:
    * generating the segment table,  even though the edge tables
    * are stored as ordered lists.  An "edge" in this context
    * is synonymous with a segment "adjacency".   */
-  typedef itksys::hash_map< IdentifierType, InputPixelType, itksys::hash< IdentifierType >
-                            > edge_table_t;
+  using edge_table_t = std::map<IdentifierType, InputPixelType>;
 
-  typedef itksys::hash_map< IdentifierType, edge_table_t, itksys::hash< IdentifierType >
-                         > edge_table_hash_t;
+  using edge_table_hash_t = std::unordered_map<IdentifierType, edge_table_t>;
 
   Segmenter();
   Segmenter(const Self &) {}
-  ~Segmenter() ITK_OVERRIDE;
-  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
+  ~Segmenter() override;
+  void
+  PrintSelf(std::ostream & os, Indent indent) const override;
 
-  void operator=(const Self &) {}
+  void
+  operator=(const Self &)
+  {}
 
   /** Constructs the connectivity list and the corresponding set of directional
    * Offset indices. */
-  virtual void GenerateConnectivity();
+  virtual void
+  GenerateConnectivity();
 
   /** This method asks for an image region that is one pixel larger
    * at each boundary than the region being processed.  This single pixel
    * expansion represents an overlap with adjacent image chunks   */
-  void GenerateInputRequestedRegion() ITK_OVERRIDE;
+  void
+  GenerateInputRequestedRegion() override;
 
-  void GenerateOutputRequestedRegion(DataObject *output) ITK_OVERRIDE;
+  void
+  GenerateOutputRequestedRegion(DataObject * output) override;
 
-  void UpdateOutputInformation() ITK_OVERRIDE;
+  void
+  UpdateOutputInformation() override;
 
   /**  Allocates boundary structure information and sets the
    * boundary data to null values.   */
-  void InitializeBoundary();
+  void
+  InitializeBoundary();
 
   /** Performs a gradient descent connected component analysis
    * at the boundaries of the images that border other
    * image chunks.  Useful only in data streaming applications.   */
-  void AnalyzeBoundaryFlow(InputImageTypePointer,
-                           flat_region_table_t &,
-                           InputPixelType);
+  void
+  AnalyzeBoundaryFlow(InputImageTypePointer, flat_region_table_t &, InputPixelType);
 
   /** Fills boundary pixels with a specified value.  Used by labeling
    * methods to build a very high "wall" around the image so that
    * gradient descent does not need to watch boundaries.   */
-  void BuildRetainingWall(InputImageTypePointer,
-                          ImageRegionType, InputPixelType);
+  void BuildRetainingWall(InputImageTypePointer, ImageRegionType, InputPixelType);
 
   /** Labels all the local minima in the image.  Also identifies and labels
    * connected  "flat" regions.   */
-  void LabelMinima(InputImageTypePointer,
-                   ImageRegionType, flat_region_table_t &,
-                   InputPixelType);
+  void
+  LabelMinima(InputImageTypePointer, ImageRegionType, flat_region_table_t &, InputPixelType);
 
   /** Follows each unlabeled pixel in the image down its path of steepest
    * descent.  Each pixel along that path is identified with the local minima
@@ -314,7 +333,8 @@ protected:
 
   /** Associates each flat region with a local minimum and relabels
     accordingly.  */
-  void DescendFlatRegions(flat_region_table_t &, ImageRegionType);
+  void
+  DescendFlatRegions(flat_region_table_t &, ImageRegionType);
 
   /** Adds entries to the output segment table for all labeled segments in the
    * image.  */
@@ -323,36 +343,35 @@ protected:
   /** Traverses each boundary and fills in the data needed for joining
    * streamed chunks of an image volume.  Only necessary for streaming
    * applications.   */
-  void CollectBoundaryInformation(flat_region_table_t &);
+  void
+  CollectBoundaryInformation(flat_region_table_t &);
 
   /** Helper function.  Thresholds low values and copies values from one image
    * into another. The source and destination regions must match in size (not
    * enforced).  For integral types, the dynamic range of the image is
    * adjusted such that the maximum value in the image is always at
    * least one less than the maximum value allowed for that data type. */
-  static void Threshold(InputImageTypePointer destination,
-                        InputImageTypePointer source,
-                        const ImageRegionType source_region,
-                        const ImageRegionType destination_region,
-                        InputPixelType threshold);
+  static void
+  Threshold(InputImageTypePointer destination,
+            InputImageTypePointer source,
+            const ImageRegionType source_region,
+            const ImageRegionType destination_region,
+            InputPixelType        threshold);
 
   /** Helper function.  Finds the minimum and maximum values in an image. */
-  static void MinMax(InputImageTypePointer img,
-                     ImageRegionType region,
-                     InputPixelType & min,
-                     InputPixelType & max);
+  static void
+  MinMax(InputImageTypePointer img, ImageRegionType region, InputPixelType & min, InputPixelType & max);
 
   /** Helper function. Finds the minimum and maximum values in an image.   */
-  static void MergeFlatRegions(flat_region_table_t &, EquivalencyTable::Pointer);
+  static void
+  MergeFlatRegions(flat_region_table_t &, EquivalencyTable::Pointer);
 
   /** Helper functions for filling in regions with values   */
-  static void SetInputImageValues(InputImageTypePointer img,
-                                  const ImageRegionType region,
-                                  InputPixelType value);
+  static void
+  SetInputImageValues(InputImageTypePointer img, const ImageRegionType region, InputPixelType value);
 
-  static void SetOutputImageValues(OutputImageTypePointer img,
-                                   const ImageRegionType region,
-                                   IdentifierType value);
+  static void
+  SetOutputImageValues(OutputImageTypePointer img, const ImageRegionType region, IdentifierType value);
 
   /** This is a debugging method.  Will be removed. 11/14/01 jc   */
   //  bool CheckLabeledBoundaries();
@@ -370,17 +389,17 @@ private:
    *  streaming applications*/
   ImageRegionType m_LargestPossibleRegion;
 
-  bool            m_SortEdgeLists;
-  bool            m_DoBoundaryAnalysis;
-  double          m_Threshold;
-  double          m_MaximumFloodLevel;
-  IdentifierType  m_CurrentLabel;
+  bool           m_SortEdgeLists;
+  bool           m_DoBoundaryAnalysis;
+  double         m_Threshold;
+  double         m_MaximumFloodLevel;
+  IdentifierType m_CurrentLabel;
 };
 } // end namespace watershed
 } // end namespace itk
 
 #ifndef ITK_MANUAL_INSTANTIATION
-#include "itkWatershedSegmenter.hxx"
+#  include "itkWatershedSegmenter.hxx"
 #endif
 
 #endif
diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedSegmenter.hxx b/Modules/Segmentation/Watersheds/include/itkWatershedSegmenter.hxx
index cf1aa0116c..a301227f42 100644
--- a/Modules/Segmentation/Watersheds/include/itkWatershedSegmenter.hxx
+++ b/Modules/Segmentation/Watersheds/include/itkWatershedSegmenter.hxx
@@ -36,15 +36,16 @@ namespace watershed
   ----------------------------------------------------------------------------
 */
 
-template< typename TInputImage >
-Segmenter< TInputImage >::~Segmenter()
+template <typename TInputImage>
+Segmenter<TInputImage>::~Segmenter()
 {
   delete[] m_Connectivity.index;
   delete[] m_Connectivity.direction;
 }
 
-template< typename TInputImage >
-void Segmenter< TInputImage >::GenerateData()
+template <typename TInputImage>
+void
+Segmenter<TInputImage>::GenerateData()
 {
   //
   // Allocate all the necessary temporary data structures and variables that
@@ -54,17 +55,17 @@ void Segmenter< TInputImage >::GenerateData()
   unsigned int i;
 
   this->UpdateProgress(0.0);
-  if ( m_DoBoundaryAnalysis == false )
-    {
+  if (m_DoBoundaryAnalysis == false)
+  {
     this->GetSegmentTable()->Clear();
     this->SetCurrentLabel(1);
-    }
+  }
 
   flat_region_table_t flatRegions;
 
-  typename InputImageType::Pointer input   = this->GetInputImage();
+  typename InputImageType::Pointer  input = this->GetInputImage();
   typename OutputImageType::Pointer output = this->GetOutputImage();
-  typename BoundaryType::Pointer boundary  = this->GetBoundary();
+  typename BoundaryType::Pointer    boundary = this->GetBoundary();
 
   // ------------------------------------------------------------------------
   //
@@ -88,31 +89,30 @@ void Segmenter< TInputImage >::GenerateData()
   // out a pixel when we threshold so that we can construct the retaining wall
   // along those faces.
   //
-  ImageRegionType regionToProcess       = output->GetRequestedRegion();
+  ImageRegionType regionToProcess = output->GetRequestedRegion();
   ImageRegionType largestPossibleRegion = this->GetLargestPossibleRegion();
-  ImageRegionType thresholdImageRegion  = regionToProcess;
-  ImageRegionType thresholdLargestPossibleRegion =
-    this->GetLargestPossibleRegion();
+  ImageRegionType thresholdImageRegion = regionToProcess;
+  ImageRegionType thresholdLargestPossibleRegion = this->GetLargestPossibleRegion();
 
   // First we have to find the boundaries and adjust the threshold image size
   typename ImageRegionType::IndexType tidx = thresholdImageRegion.GetIndex();
-  typename ImageRegionType::SizeType tsz = thresholdImageRegion.GetSize();
+  typename ImageRegionType::SizeType  tsz = thresholdImageRegion.GetSize();
   typename ImageRegionType::IndexType tlidx = thresholdLargestPossibleRegion.GetIndex();
-  typename ImageRegionType::SizeType tlsz = thresholdLargestPossibleRegion.GetSize();
-  for ( i = 0; i < ImageDimension; ++i )
-    {
-    ImageRegionType reg;
+  typename ImageRegionType::SizeType  tlsz = thresholdLargestPossibleRegion.GetSize();
+  for (i = 0; i < ImageDimension; ++i)
+  {
+    ImageRegionType                     reg;
     typename ImageRegionType::IndexType idx = regionToProcess.GetIndex();
-    typename ImageRegionType::SizeType sz  = regionToProcess.GetSize();
+    typename ImageRegionType::SizeType  sz = regionToProcess.GetSize();
 
     // Set LOW face
     idx[i] = regionToProcess.GetIndex()[i];
-    sz[i]  = 1;
+    sz[i] = 1;
     reg.SetSize(sz);
     reg.SetIndex(idx);
 
-    if ( reg.GetIndex()[i] == largestPossibleRegion.GetIndex()[i] )
-      {
+    if (reg.GetIndex()[i] == largestPossibleRegion.GetIndex()[i])
+    {
       // This is facing a true data set boundary
       tsz[i] += 1; // we need to pad our threshold image on this face
       tidx[i] -= 1;
@@ -120,34 +120,33 @@ void Segmenter< TInputImage >::GenerateData()
       tlidx[i] -= 1;
 
       boundary->SetValid(false, i, 0);
-      }
+    }
     else
-      {
+    {
       // This is an overlap with another data chunk in the data set
       // Mark this boundary face as valid.
       boundary->SetValid(true, i, 0);
-      }
+    }
 
     // Set HIGH face
-    idx[i] = ( regionToProcess.GetIndex()[i] + regionToProcess.GetSize()[i] ) - 1;
+    idx[i] = (regionToProcess.GetIndex()[i] + regionToProcess.GetSize()[i]) - 1;
     reg.SetSize(sz);
     reg.SetIndex(idx);
-    if ( ( reg.GetIndex()[i] + reg.GetSize()[i] )
-         == ( largestPossibleRegion.GetIndex()[i]
-              + largestPossibleRegion.GetSize()[i] ) )
-      {
+    if ((reg.GetIndex()[i] + reg.GetSize()[i]) ==
+        (largestPossibleRegion.GetIndex()[i] + largestPossibleRegion.GetSize()[i]))
+    {
       // This is facing a true data set boundary
       tsz[i] += 1;  // we need to pad our threshold image on this face
       tlsz[i] += 1; // we need to pad our threshold image on this face
       boundary->SetValid(false, i, 1);
-      }
+    }
     else
-      {
+    {
       // This is an overlap with another data chunk in the data set
       // Mark this face as valid in the boundary.
       boundary->SetValid(true, i, 1);
-      }
     }
+  }
   thresholdImageRegion.SetSize(tsz);
   thresholdImageRegion.SetIndex(tidx);
   thresholdLargestPossibleRegion.SetSize(tlsz);
@@ -177,30 +176,37 @@ void Segmenter< TInputImage >::GenerateData()
   Self::MinMax(input, regionToProcess, minimum, maximum);
   // cap the maximum in the image so that we can always define a pixel
   // value that is one greater than the maximum value in the image.
-  if ( NumericTraits< InputPixelType >::IsInteger
+  if (NumericTraits<InputPixelType>::IsInteger
+        // clang-format off
 CLANG_PRAGMA_PUSH
 CLANG_SUPPRESS_Wfloat_equal
-       && maximum == NumericTraits< InputPixelType >::max() )
+      // clang-format on
+      && maximum == NumericTraits<InputPixelType>::max())
+    // clang-format off
 CLANG_PRAGMA_POP
+    // clang-format on
     {
-    maximum -= NumericTraits< InputPixelType >::OneValue();
+      maximum -= NumericTraits<InputPixelType>::OneValue();
     }
   // threshold the image.
-  Self::Threshold( thresholdImage, input, regionToProcess, regionToProcess,
-                   static_cast< InputPixelType >( ( m_Threshold * ( maximum - minimum ) ) + minimum ) );
+  Self::Threshold(thresholdImage,
+                  input,
+                  regionToProcess,
+                  regionToProcess,
+                  static_cast<InputPixelType>((m_Threshold * (maximum - minimum)) + minimum));
 
   //
   // Redefine the regionToProcess in terms of the threshold image.  The region
   // to  process represents all the pixels contained within the 1 pixel padded
   // boundary of the threshold image.
   //
-  typename ImageRegionType::SizeType irsz;
+  typename ImageRegionType::SizeType  irsz;
   typename ImageRegionType::IndexType iridx;
-  for ( i = 0; i < ImageDimension; ++i )
-    {
-    irsz[i]  = thresholdImageRegion.GetSize()[i] - 2;
+  for (i = 0; i < ImageDimension; ++i)
+  {
+    irsz[i] = thresholdImageRegion.GetSize()[i] - 2;
     iridx[i] = thresholdImageRegion.GetIndex()[i] + 1;
-    }
+  }
   regionToProcess.SetIndex(iridx);
   regionToProcess.SetSize(irsz);
 
@@ -222,7 +228,7 @@ CLANG_PRAGMA_POP
   // At this point we are ready to define the output
   // buffer and allocate memory for the output image.
   //
-  output->SetBufferedRegion( thresholdImage->GetBufferedRegion() );
+  output->SetBufferedRegion(thresholdImage->GetBufferedRegion());
   output->Allocate();
   Self::SetOutputImageValues(output, output->GetBufferedRegion(), Self::NULL_LABEL);
 
@@ -231,23 +237,26 @@ CLANG_PRAGMA_POP
   // flow at the boundaries from the requested region of the threshold
   // image.
   //
-  typename BoundaryType::IndexType b_idx;
-  ImageRegionType reg_b;
+  typename BoundaryType::IndexType    b_idx;
+  ImageRegionType                     reg_b;
   typename ImageRegionType::IndexType idx_b;
-  typename ImageRegionType::SizeType sz_b;
+  typename ImageRegionType::SizeType  sz_b;
 
-  for ( b_idx.first = 0; b_idx.first < ImageDimension; ++b_idx.first )
+  for (b_idx.first = 0; b_idx.first < ImageDimension; ++b_idx.first)
+  {
+    for (b_idx.second = 0; b_idx.second < 2; ++b_idx.second)
     {
-    for ( b_idx.second = 0; b_idx.second < 2; ++b_idx.second )
+      if (boundary->GetValid(b_idx) == false)
       {
-      if ( boundary->GetValid(b_idx) == false ) { continue; }
+        continue;
+      }
       idx_b = thresholdImage->GetRequestedRegion().GetIndex();
       sz_b = thresholdImage->GetRequestedRegion().GetSize();
 
-      if ( b_idx.second == 1 ) // HIGH face must adjust start index
-        {
+      if (b_idx.second == 1) // HIGH face must adjust start index
+      {
         idx_b[b_idx.first] += sz_b[b_idx.first] - 1;
-        }
+      }
 
       sz_b[b_idx.first] = 1;
 
@@ -258,8 +267,8 @@ CLANG_PRAGMA_POP
       boundary->GetFace(b_idx)->SetRequestedRegion(reg_b);
       boundary->GetFace(b_idx)->SetBufferedRegion(reg_b);
       boundary->GetFace(b_idx)->Allocate();
-      }
     }
+  }
   this->UpdateProgress(0.1);
 
   //
@@ -268,12 +277,11 @@ CLANG_PRAGMA_POP
   // flat-region connectivity) and constructs the appropriate Boundary
   // data structures.
   //
-  if ( m_DoBoundaryAnalysis == true )
-    {
+  if (m_DoBoundaryAnalysis == true)
+  {
     this->InitializeBoundary();
-    this->AnalyzeBoundaryFlow(thresholdImage, flatRegions, maximum
-                              + NumericTraits< InputPixelType >::OneValue());
-    }
+    this->AnalyzeBoundaryFlow(thresholdImage, flatRegions, maximum + NumericTraits<InputPixelType>::OneValue());
+  }
 
   this->UpdateProgress(0.2);
 
@@ -284,145 +292,149 @@ CLANG_PRAGMA_POP
   // All overlap boundary information will be overwritten, but is no longer
   // needed now.
   //
-  this->BuildRetainingWall(thresholdImage,
-                           thresholdImage->GetBufferedRegion(),
-                           maximum + NumericTraits< InputPixelType >::OneValue());
+  this->BuildRetainingWall(
+    thresholdImage, thresholdImage->GetBufferedRegion(), maximum + NumericTraits<InputPixelType>::OneValue());
 
   //
   // Label all the local minima pixels in the image.  This function also
   // labels flat regions, defined as regions where connected pixels all have
   // the same value.
   //
-  this->LabelMinima(thresholdImage, thresholdImage->GetRequestedRegion(),
-                    flatRegions, maximum + NumericTraits< InputPixelType >::OneValue());
+  this->LabelMinima(thresholdImage,
+                    thresholdImage->GetRequestedRegion(),
+                    flatRegions,
+                    maximum + NumericTraits<InputPixelType>::OneValue());
   this->UpdateProgress(0.3);
 
-  this->GradientDescent( thresholdImage, thresholdImage->GetRequestedRegion() );
+  this->GradientDescent(thresholdImage, thresholdImage->GetRequestedRegion());
   this->UpdateProgress(0.4);
 
-  this->DescendFlatRegions( flatRegions, thresholdImage->GetRequestedRegion() );
+  this->DescendFlatRegions(flatRegions, thresholdImage->GetRequestedRegion());
   this->UpdateProgress(0.5);
 
-  this->UpdateSegmentTable( thresholdImage, thresholdImage->GetRequestedRegion() );
+  this->UpdateSegmentTable(thresholdImage, thresholdImage->GetRequestedRegion());
   this->UpdateProgress(0.6);
 
-  if ( m_DoBoundaryAnalysis == true )
-          {  this->CollectBoundaryInformation(flatRegions); }
+  if (m_DoBoundaryAnalysis == true)
+  {
+    this->CollectBoundaryInformation(flatRegions);
+  }
   this->UpdateProgress(0.7);
 
-  if ( m_SortEdgeLists == true )
-          {  this->GetSegmentTable()->SortEdgeLists(); }
+  if (m_SortEdgeLists == true)
+  {
+    this->GetSegmentTable()->SortEdgeLists();
+  }
   this->UpdateProgress(0.8);
 
   this->GetSegmentTable()->SetMaximumDepth(maximum - minimum);
   this->UpdateProgress(1.0);
 }
 
-template< typename TInputImage >
-void Segmenter< TInputImage >
-::CollectBoundaryInformation(flat_region_table_t & flatRegions)
+template <typename TInputImage>
+void
+Segmenter<TInputImage>::CollectBoundaryInformation(flat_region_table_t & flatRegions)
 {
   typename OutputImageType::Pointer output = this->GetOutputImage();
-  typename BoundaryType::Pointer boundary  = this->GetBoundary();
+  typename BoundaryType::Pointer    boundary = this->GetBoundary();
 
-  ImageRegionIterator< typename BoundaryType::face_t > faceIt;
-  ImageRegionIterator< OutputImageType >                   labelIt;
+  ImageRegionIterator<typename BoundaryType::face_t> faceIt;
+  ImageRegionIterator<OutputImageType>               labelIt;
 
-  typename BoundaryType::face_t::Pointer face;
-  typename BoundaryType::flat_hash_t           * flats;
+  typename BoundaryType::face_t::Pointer       face;
+  typename BoundaryType::flat_hash_t *         flats;
   typename BoundaryType::flat_hash_t::iterator flats_it;
-  typename BoundaryType::flat_region_t flr;
-  typename flat_region_table_t::iterator flrt_it;
+  typename BoundaryType::flat_region_t         flr;
+  typename flat_region_table_t::iterator       flrt_it;
 
   typename BoundaryType::IndexType idx;
-  ImageRegionType region;
+  ImageRegionType                  region;
 
-  for ( idx.first = 0; idx.first < ImageDimension; ( idx.first )++ )
+  for (idx.first = 0; idx.first < ImageDimension; (idx.first)++)
+  {
+    for (idx.second = 0; idx.second < 2; (idx.second)++)
     {
-    for ( idx.second = 0; idx.second < 2; ( idx.second )++ )
+      if (boundary->GetValid(idx) == false)
       {
-      if ( boundary->GetValid(idx) == false ) { continue; }
+        continue;
+      }
 
-      face  = boundary->GetFace(idx);
+      face = boundary->GetFace(idx);
       flats = boundary->GetFlatHash(idx);
       region = face->GetRequestedRegion();
 
       // Grab all the labels of the boundary pixels.
-      faceIt = ImageRegionIterator< typename BoundaryType::face_t >(face,
-                                                                        region);
-      labelIt = ImageRegionIterator< OutputImageType >(output, region);
+      faceIt = ImageRegionIterator<typename BoundaryType::face_t>(face, region);
+      labelIt = ImageRegionIterator<OutputImageType>(output, region);
       faceIt.GoToBegin();
       labelIt.GoToBegin();
-      while ( !faceIt.IsAtEnd() )
-        {
-        faceIt.Value(). label = labelIt.Get();
+      while (!faceIt.IsAtEnd())
+      {
+        faceIt.Value().label = labelIt.Get();
 
         // Is this a flat region that flows out?
-        flrt_it = flatRegions.find( labelIt.Get() );
-        if ( faceIt.Get().flow != NULL_FLOW
-             && flrt_it != flatRegions.end() )
-          {
+        flrt_it = flatRegions.find(labelIt.Get());
+        if (faceIt.Get().flow != NULL_FLOW && flrt_it != flatRegions.end())
+        {
           // Have we already entered this
           // flat region into the boundary?
-          flats_it = flats->find( labelIt.Get() );
-          if ( flats_it == flats->end() )  // NO
-            {
-            flr.bounds_min = ( *flrt_it ).second.bounds_min;
-            flr.min_label  = *( ( *flrt_it ).second.min_label_ptr );
-            flr.value      = ( *flrt_it ).second.value;
-            flr.offset_list.push_back(
-              face->ComputeOffset( faceIt.GetIndex() ) );
-            flats->insert(
-              BoundaryFlatHashValueType(labelIt.Get(), flr) );
+          flats_it = flats->find(labelIt.Get());
+          if (flats_it == flats->end()) // NO
+          {
+            flr.bounds_min = (*flrt_it).second.bounds_min;
+            flr.min_label = *((*flrt_it).second.min_label_ptr);
+            flr.value = (*flrt_it).second.value;
+            flr.offset_list.push_back(face->ComputeOffset(faceIt.GetIndex()));
+            flats->insert(BoundaryFlatHashValueType(labelIt.Get(), flr));
             flr.offset_list.clear();
-            }
+          }
           else // YES
-            {
-            ( *flats_it ).second.offset_list.push_back( face->ComputeOffset( faceIt.GetIndex() ) );
-            }
+          {
+            (*flats_it).second.offset_list.push_back(face->ComputeOffset(faceIt.GetIndex()));
           }
+        }
 
         ++faceIt;
         ++labelIt;
-        }
       }
     }
+  }
 }
 
-template< typename TInputImage >
-void Segmenter< TInputImage >
-::InitializeBoundary()
+template <typename TInputImage>
+void
+Segmenter<TInputImage>::InitializeBoundary()
 {
-  ImageRegionIterator< typename BoundaryType::face_t > faceIt;
   typename BoundaryType::face_t::Pointer face;
-  typename BoundaryType::face_pixel_t fps;
-  BoundaryIndexType idx;
+  typename BoundaryType::face_pixel_t    fps;
+  BoundaryIndexType                      idx;
 
-  fps.flow  = NULL_FLOW;
+  fps.flow = NULL_FLOW;
   fps.label = NULL_LABEL;
 
-  for ( idx.first = 0; idx.first < ImageDimension; ++( idx.first ) )
+  for (idx.first = 0; idx.first < ImageDimension; ++(idx.first))
+  {
+    for (idx.second = 0; idx.second < 2; ++(idx.second))
     {
-    for ( idx.second = 0; idx.second < 2; ++( idx.second ) )
+      if (this->GetBoundary()->GetValid(idx) == false)
       {
-      if ( this->GetBoundary()->GetValid(idx) == false ) { continue; }
+        continue;
+      }
       this->GetBoundary()->GetFlatHash(idx)->clear();
       face = this->GetBoundary()->GetFace(idx);
-      faceIt = ImageRegionIterator< typename BoundaryType::face_t >
-                 ( face, face->GetBufferedRegion() );
-      for ( faceIt.GoToBegin(); !faceIt.IsAtEnd(); ++faceIt )
-        {
-        faceIt.Set(fps);
-        }
+      if (face != nullptr)
+      {
+        face->FillBuffer(fps);
       }
     }
+  }
 }
 
-template< typename TInputImage >
-void Segmenter< TInputImage >
-::AnalyzeBoundaryFlow(InputImageTypePointer thresholdImage,
-                      flat_region_table_t & flatRegions,
-                      InputPixelType max)
+template <typename TInputImage>
+void
+Segmenter<TInputImage>::AnalyzeBoundaryFlow(InputImageTypePointer thresholdImage,
+                                            flat_region_table_t & flatRegions,
+                                            InputPixelType        max)
 {
   //
   // NOTE: For ease of initial implementation, this method does
@@ -431,194 +443,193 @@ void Segmenter< TInputImage >
   unsigned int nCenter, i, nPos, cPos;
   bool         isSteepest;
 
-  ConstNeighborhoodIterator< InputImageType >              searchIt;
-  NeighborhoodIterator< OutputImageType >                  labelIt;
-  ImageRegionIterator< typename BoundaryType::face_t > faceIt;
+  ConstNeighborhoodIterator<InputImageType>          searchIt;
+  NeighborhoodIterator<OutputImageType>              labelIt;
+  ImageRegionIterator<typename BoundaryType::face_t> faceIt;
 
-  BoundaryIndexType idx;
-  ImageRegionType   region;
-  typename ConstNeighborhoodIterator< InputImageType >::RadiusType rad;
+  BoundaryIndexType                                              idx;
+  ImageRegionType                                                region;
+  typename ConstNeighborhoodIterator<InputImageType>::RadiusType rad;
 
   typename BoundaryType::face_pixel_t fps;
-  flat_region_t tempFlatRegion;
+  flat_region_t                       tempFlatRegion;
 
-  typename OutputImageType::Pointer output   = this->GetOutputImage();
-  typename BoundaryType::Pointer boundary = this->GetBoundary();
+  typename OutputImageType::Pointer output = this->GetOutputImage();
+  typename BoundaryType::Pointer    boundary = this->GetBoundary();
 
-  for ( i = 0; i < ImageDimension; ++i )
-    {
+  for (i = 0; i < ImageDimension; ++i)
+  {
     rad[i] = 1;
-    }
+  }
   fps.label = NULL_LABEL;
 
   EquivalencyTable::Pointer eqTable = EquivalencyTable::New();
 
   // Process each boundary region.
-  for ( idx.first = 0; idx.first < ImageDimension; ++( idx.first ) )
+  for (idx.first = 0; idx.first < ImageDimension; ++(idx.first))
+  {
+    for (idx.second = 0; idx.second < 2; ++(idx.second))
     {
-    for ( idx.second = 0; idx.second < 2; ++( idx.second ) )
-      {
       // Skip irrelevant boundaries
-      if ( boundary->GetValid(idx) == false ) { continue; }
+      if (boundary->GetValid(idx) == false)
+      {
+        continue;
+      }
 
       typename BoundaryType::face_t::Pointer face = boundary->GetFace(idx);
       region = face->GetRequestedRegion();
 
-      searchIt =
-        ConstNeighborhoodIterator< InputImageType >(rad, thresholdImage, region);
-      labelIt = NeighborhoodIterator< OutputImageType >(rad, output, region);
-      faceIt  = ImageRegionIterator< typename BoundaryType::face_t >(face, region);
+      searchIt = ConstNeighborhoodIterator<InputImageType>(rad, thresholdImage, region);
+      labelIt = NeighborhoodIterator<OutputImageType>(rad, output, region);
+      faceIt = ImageRegionIterator<typename BoundaryType::face_t>(face, region);
 
       nCenter = searchIt.Size() / 2;
       searchIt.GoToBegin();
       labelIt.GoToBegin();
 
-      if ( ( idx ).second == 0 )
-        {
+      if ((idx).second == 0)
+      {
         // Low face
-        cPos = m_Connectivity.index[( idx ).first];
-        }
+        cPos = m_Connectivity.index[(idx).first];
+      }
       else
-        {
+      {
         // High face
-        cPos = m_Connectivity.index[( ImageDimension - 1 )
-                                    + ( ImageDimension - ( idx ).first )];
-        }
+        cPos = m_Connectivity.index[(ImageDimension - 1) + (ImageDimension - (idx).first)];
+      }
 
-      while ( !searchIt.IsAtEnd() )
-        {
+      while (!searchIt.IsAtEnd())
+      {
         // Is this a flat connection?
-        if ( Math::AlmostEquals( searchIt.GetPixel(nCenter), searchIt.GetPixel(cPos) ) )
-          {
+        if (Math::AlmostEquals(searchIt.GetPixel(nCenter), searchIt.GetPixel(cPos)))
+        {
           // Fill in the boundary flow information.
           // Labels will be collected later.
-          fps.flow   = static_cast< short >( cPos );
+          fps.flow = static_cast<short>(cPos);
           faceIt.Set(fps);
 
           // Are we touching flat regions
           // that have already been labeled?
-          bool _labeled    = false;
-          bool _connected  = false;
-          for ( i = 0; i < m_Connectivity.size; i++ )
-            {
+          bool _labeled = false;
+          bool _connected = false;
+          for (i = 0; i < m_Connectivity.size; i++)
+          {
             nPos = m_Connectivity.index[i];
-            if (   Math::AlmostEquals( searchIt.GetPixel(nCenter), searchIt.GetPixel(nPos) )
-                   && labelIt.GetPixel(nPos) != Self::NULL_LABEL
-                   && labelIt.GetPixel(nPos) != labelIt.GetPixel(nCenter)
-                   )
-              {
+            if (Math::AlmostEquals(searchIt.GetPixel(nCenter), searchIt.GetPixel(nPos)) &&
+                labelIt.GetPixel(nPos) != Self::NULL_LABEL && labelIt.GetPixel(nPos) != labelIt.GetPixel(nCenter))
+            {
               _connected = true;
-              if ( _labeled == false )
-                {
-                labelIt.SetPixel( nCenter,
-                                  labelIt.GetPixel(nPos) );
+              if (_labeled == false)
+              {
+                labelIt.SetPixel(nCenter, labelIt.GetPixel(nPos));
                 _labeled = true;
-                }
+              }
               else
-                {
-                eqTable->Add( labelIt.GetPixel(nCenter), labelIt.GetPixel(nPos) );
-                }
+              {
+                eqTable->Add(labelIt.GetPixel(nCenter), labelIt.GetPixel(nPos));
               }
             }
-          if ( _connected == false ) // Add a new flat region.
-            {
+          }
+          if (_connected == false) // Add a new flat region.
+          {
             labelIt.SetPixel(nCenter, m_CurrentLabel);
 
             // Add a flat region to the (global) flat region table
-            tempFlatRegion.bounds_min    = max;
-            tempFlatRegion.min_label_ptr = output->GetBufferPointer()
-                                           + output->ComputeOffset( labelIt.GetIndex() );
-            tempFlatRegion.value         = searchIt.GetPixel(nCenter);
+            tempFlatRegion.bounds_min = max;
+            tempFlatRegion.min_label_ptr = output->GetBufferPointer() + output->ComputeOffset(labelIt.GetIndex());
+            tempFlatRegion.value = searchIt.GetPixel(nCenter);
             tempFlatRegion.is_on_boundary = true;
-            flatRegions[m_CurrentLabel]  = tempFlatRegion;
+            flatRegions[m_CurrentLabel] = tempFlatRegion;
 
             m_CurrentLabel++;
-            }
           }
-        else  // Is cPos the path of steepest descent?
+        }
+        else // Is cPos the path of steepest descent?
+        {
+          if (searchIt.GetPixel(cPos) < searchIt.GetPixel(nCenter))
           {
-          if ( searchIt.GetPixel(cPos) < searchIt.GetPixel(nCenter) )
-            {
             isSteepest = true;
-            for ( i = 0; i < m_Connectivity.size; i++ )
-              {
+            for (i = 0; i < m_Connectivity.size; i++)
+            {
               nPos = m_Connectivity.index[i];
-              if ( searchIt.GetPixel(nPos) < searchIt.GetPixel(cPos) )
-                {
+              if (searchIt.GetPixel(nPos) < searchIt.GetPixel(cPos))
+              {
                 isSteepest = false;
                 break;
-                }
               }
             }
-          else { isSteepest = false; }
+          }
+          else
+          {
+            isSteepest = false;
+          }
 
-          if ( isSteepest == true )
-            {
+          if (isSteepest == true)
+          {
             // Label this pixel. It will be safely treated as a local
             // minimum by the rest of the segmentation algorithm.
             labelIt.SetPixel(nCenter, m_CurrentLabel);
 
             // Add the connectivity information
             // to the boundary data structure.
-            fps.flow  = static_cast< short >( cPos );
+            fps.flow = static_cast<short>(cPos);
             faceIt.Set(fps);
 
             // Since we've labeled this pixel, we need to check to
             // make sure this is not also a flat region.  If it is,
             // then it must be entered into the flat region table
             // or we could have problems later on.
-            for ( i = 0; i < m_Connectivity.size; i++ )
-              {
+            for (i = 0; i < m_Connectivity.size; i++)
+            {
               nPos = m_Connectivity.index[i];
-              if ( Math::AlmostEquals( searchIt.GetPixel(nPos),
-                   searchIt.GetPixel(nCenter) ) )
-                {
+              if (Math::AlmostEquals(searchIt.GetPixel(nPos), searchIt.GetPixel(nCenter)))
+              {
                 tempFlatRegion.bounds_min = max;
-                tempFlatRegion.min_label_ptr =
-                  output->GetBufferPointer()
-                  + output->ComputeOffset( labelIt.GetIndex() );
-                tempFlatRegion.value =
-                  searchIt.GetPixel(nCenter);
+                tempFlatRegion.min_label_ptr = output->GetBufferPointer() + output->ComputeOffset(labelIt.GetIndex());
+                tempFlatRegion.value = searchIt.GetPixel(nCenter);
                 tempFlatRegion.is_on_boundary = false;
                 flatRegions[m_CurrentLabel] = tempFlatRegion;
                 break;
-                }
               }
-            m_CurrentLabel++;
             }
+            m_CurrentLabel++;
           }
+        }
 
         ++searchIt;
         ++labelIt;
         ++faceIt;
-        }
       }
     }
+  }
 
   eqTable->Flatten();
 
   // Now relabel any equivalent regions in the boundaries.
-  for ( idx.first = 0; idx.first < ImageDimension; ++( idx.first ) )
+  for (idx.first = 0; idx.first < ImageDimension; ++(idx.first))
+  {
+    for (idx.second = 0; idx.second < 2; ++(idx.second))
     {
-    for ( idx.second = 0; idx.second < 2; ++( idx.second ) )
-      {
       // Skip irrelevant boundaries
-      if ( boundary->GetValid(idx) == false ) { continue; }
+      if (boundary->GetValid(idx) == false)
+      {
+        continue;
+      }
 
       typename BoundaryType::face_t::Pointer face = boundary->GetFace(idx);
       region = face->GetRequestedRegion();
 
       Self::RelabelImage(output, region, eqTable);
-      }
     }
+  }
 
   // Merge the flat regions in the table
   Self::MergeFlatRegions(flatRegions, eqTable);
 }
 
-template< typename TInputImage >
-void Segmenter< TInputImage >
-::GenerateConnectivity()
+template <typename TInputImage>
+void
+Segmenter<TInputImage>::GenerateConnectivity()
 {
   unsigned int i, j, nSize, nCenter, stride;
   int          d;
@@ -634,44 +645,45 @@ void Segmenter< TInputImage >
   //
   // Algorithms assume this order to the connectivity.
   //
-  typename ConstNeighborhoodIterator< InputImageType >::RadiusType rad;
-  for ( i = 0; i < ImageDimension; ++i )
-    {
+  typename ConstNeighborhoodIterator<InputImageType>::RadiusType rad;
+  for (i = 0; i < ImageDimension; ++i)
+  {
     rad[i] = 1;
-    }
-  ConstNeighborhoodIterator< InputImageType > it( rad, this->GetInputImage(),
-                                                  this->GetInputImage()->GetRequestedRegion() );
-  nSize   = it.Size();
+  }
+  ConstNeighborhoodIterator<InputImageType> it(rad, this->GetInputImage(), this->GetInputImage()->GetRequestedRegion());
+  nSize = it.Size();
   nCenter = nSize >> 1;
 
-  for ( i = 0; i < m_Connectivity.size; i++ ) // initialize move list
+  for (i = 0; i < m_Connectivity.size; i++) // initialize move list
+  {
+    for (j = 0; j < ImageDimension; j++)
     {
-    for ( j = 0; j < ImageDimension; j++ )
-      {
       m_Connectivity.direction[i][j] = 0;
-      }
     }
+  }
   i = 0;
-  for ( d = ImageDimension - 1; d >= 0; d-- )
-    {
+  for (d = ImageDimension - 1; d >= 0; d--)
+  {
     stride = it.GetStride(d);
     m_Connectivity.index[i] = nCenter - stride;
     m_Connectivity.direction[i][d] = -1;
     i++;
-    }
-  for ( d = 0; d < static_cast< int >( ImageDimension ); d++ )
-    {
+  }
+  for (d = 0; d < static_cast<int>(ImageDimension); d++)
+  {
     stride = it.GetStride(d);
     m_Connectivity.index[i] = nCenter + stride;
     m_Connectivity.direction[i][d] = 1;
     i++;
-    }
+  }
 }
 
-template< typename TInputImage >
-void Segmenter< TInputImage >
-::LabelMinima(InputImageTypePointer img, ImageRegionType region,
-              typename Self::flat_region_table_t & flatRegions, InputPixelType Max)
+template <typename TInputImage>
+void
+Segmenter<TInputImage>::LabelMinima(InputImageTypePointer                img,
+                                    ImageRegionType                      region,
+                                    typename Self::flat_region_table_t & flatRegions,
+                                    InputPixelType                       Max)
 {
   unsigned int   i, nSize, nCenter, nPos = 0;
   bool           foundSinglePixelMinimum, foundFlatRegion;
@@ -680,92 +692,91 @@ void Segmenter< TInputImage >
   flat_region_t tempFlatRegion;
 
   typename flat_region_table_t::iterator flatPtr;
-  InputPixelType            currentValue;
-  EquivalencyTable::Pointer equivalentLabels = EquivalencyTable::New();
+  InputPixelType                         currentValue;
+  EquivalencyTable::Pointer              equivalentLabels = EquivalencyTable::New();
 
   typename OutputImageType::Pointer output = this->GetOutputImage();
 
   // Set up the iterators.
-  typename ConstNeighborhoodIterator< InputImageType >::RadiusType rad;
-  for ( i = 0; i < ImageDimension; ++i )
-    {
+  typename ConstNeighborhoodIterator<InputImageType>::RadiusType rad;
+  for (i = 0; i < ImageDimension; ++i)
+  {
     rad[i] = 1;
-    }
-  ConstNeighborhoodIterator< InputImageType > searchIt(rad, img, region);
-  NeighborhoodIterator< OutputImageType >     labelIt(rad, output, region);
-  nSize   = searchIt.Size();
+  }
+  ConstNeighborhoodIterator<InputImageType> searchIt(rad, img, region);
+  NeighborhoodIterator<OutputImageType>     labelIt(rad, output, region);
+  nSize = searchIt.Size();
   nCenter = nSize >> 1;
 
   // Sweep through the images.  Label all local minima
   // and record information for all the flat regions.
-  for ( searchIt.GoToBegin(), labelIt.GoToBegin();
-        !searchIt.IsAtEnd(); ++searchIt, ++labelIt )
-    {
+  for (searchIt.GoToBegin(), labelIt.GoToBegin(); !searchIt.IsAtEnd(); ++searchIt, ++labelIt)
+  {
     foundSinglePixelMinimum = true;
     foundFlatRegion = false;
 
     // If this pixel has been labeled already,
     // skip directly to the next iteration.
-    if ( labelIt.GetPixel(nCenter) != Self::NULL_LABEL ) { continue; }
+    if (labelIt.GetPixel(nCenter) != Self::NULL_LABEL)
+    {
+      continue;
+    }
 
     // Compare current pixel value with its neighbors.
     currentValue = searchIt.GetPixel(nCenter);
 
-    for ( i = 0; i < m_Connectivity.size; ++i )
-      {
+    for (i = 0; i < m_Connectivity.size; ++i)
+    {
       nPos = m_Connectivity.index[i];
-      if ( Math::AlmostEquals( currentValue, searchIt.GetPixel(nPos) ) )
-        {
-        foundFlatRegion  = true;
+      if (Math::AlmostEquals(currentValue, searchIt.GetPixel(nPos)))
+      {
+        foundFlatRegion = true;
         break;
-        }
-      else if ( currentValue > searchIt.GetPixel(nPos) )
-        {
+      }
+      else if (currentValue > searchIt.GetPixel(nPos))
+      {
         foundSinglePixelMinimum = false;
-        }
       }
+    }
 
-    if ( foundFlatRegion )
-      {
-      if ( labelIt.GetPixel(nPos) != Self::NULL_LABEL ) // If the flat region is
-                                                        // already
-        {                                               // labeled, label this
-                                                        // to match.
-        labelIt.SetPixel( nCenter, labelIt.GetPixel(nPos) );
-        }
+    if (foundFlatRegion)
+    {
+      if (labelIt.GetPixel(nPos) != Self::NULL_LABEL) // If the flat region is
+                                                      // already
+      {                                               // labeled, label this
+                                                      // to match.
+        labelIt.SetPixel(nCenter, labelIt.GetPixel(nPos));
+      }
       else // Add a new flat region to the table.
-        {  // Initialize its contents.
-        labelIt.SetPixel(nCenter,  m_CurrentLabel);
+      {    // Initialize its contents.
+        labelIt.SetPixel(nCenter, m_CurrentLabel);
         nPos = m_Connectivity.index[0];
 
-        tempFlatRegion.bounds_min        = maxValue;
-        tempFlatRegion.min_label_ptr     = labelIt[nPos];
-        tempFlatRegion.value             = currentValue;
-        flatRegions[m_CurrentLabel]      = tempFlatRegion;
+        tempFlatRegion.bounds_min = maxValue;
+        tempFlatRegion.min_label_ptr = labelIt[nPos];
+        tempFlatRegion.value = currentValue;
+        flatRegions[m_CurrentLabel] = tempFlatRegion;
         m_CurrentLabel = m_CurrentLabel + 1;
-        }
+      }
 
       // While we're at it, check to see if we have just linked two flat
       // regions with the same height value.  Save that info for later.
-      for ( i++; i < m_Connectivity.size; ++i )
-        {
+      for (i++; i < m_Connectivity.size; ++i)
+      {
         nPos = m_Connectivity.index[i];
-        if (   Math::AlmostEquals( searchIt.GetPixel(nCenter), searchIt.GetPixel(nPos) )
-               && labelIt.GetPixel(nPos) != Self::NULL_LABEL
-               && labelIt.GetPixel(nPos) != labelIt.GetPixel(nCenter)
-               )
-          {
-          equivalentLabels->Add( labelIt.GetPixel(nCenter),
-                                 labelIt.GetPixel(nPos) );
-          }
+        if (Math::AlmostEquals(searchIt.GetPixel(nCenter), searchIt.GetPixel(nPos)) &&
+            labelIt.GetPixel(nPos) != Self::NULL_LABEL && labelIt.GetPixel(nPos) != labelIt.GetPixel(nCenter))
+        {
+          equivalentLabels->Add(labelIt.GetPixel(nCenter), labelIt.GetPixel(nPos));
         }
       }
-    else if ( foundSinglePixelMinimum )
-      {
-      labelIt.SetPixel(nCenter,  m_CurrentLabel);
+    }
+    else if (foundSinglePixelMinimum)
+    {
+      labelIt.SetPixel(nCenter, m_CurrentLabel);
       m_CurrentLabel = m_CurrentLabel + 1;
-      }
     }
+  }
 
   // Merge the flat regions that we identified as connected components.
   Self::MergeFlatRegions(flatRegions, equivalentLabels);
@@ -777,42 +788,43 @@ void Segmenter< TInputImage >
 
   // Now make another pass to establish the
   // boundary values for the flat regions.
-  for ( searchIt.GoToBegin(), labelIt.GoToBegin();
-        !searchIt.IsAtEnd(); ++searchIt, ++labelIt )
-    {
-    flatPtr = flatRegions.find( labelIt.GetPixel(nCenter) );
-    if ( flatPtr != flatRegions.end() ) // If we are in a flat region
-      {                                 // Search the connectivity neighborhood
-                                        // for lesser boundary pixels.
-      for ( i = 0; i < m_Connectivity.size; ++i )
-        {
+  for (searchIt.GoToBegin(), labelIt.GoToBegin(); !searchIt.IsAtEnd(); ++searchIt, ++labelIt)
+  {
+    flatPtr = flatRegions.find(labelIt.GetPixel(nCenter));
+    if (flatPtr != flatRegions.end()) // If we are in a flat region
+    {                                 // Search the connectivity neighborhood
+                                      // for lesser boundary pixels.
+      for (i = 0; i < m_Connectivity.size; ++i)
+      {
         nPos = m_Connectivity.index[i];
 
-        if  ( labelIt.GetPixel(nPos) != labelIt.GetPixel(nCenter)
-              && searchIt.GetPixel(nPos) < ( *flatPtr ).second.bounds_min )
-          { // If this is a boundary pixel && has a lesser value than
-            // the currently recorded value...
-          ( *flatPtr ).second.bounds_min = searchIt.GetPixel(nPos);
-          ( *flatPtr ).second.min_label_ptr = labelIt[nPos];
-          }
-        if ( Math::AlmostEquals( searchIt.GetPixel(nCenter), searchIt.GetPixel(nPos) ) )
+        if (labelIt.GetPixel(nPos) != labelIt.GetPixel(nCenter) &&
+            searchIt.GetPixel(nPos) < (*flatPtr).second.bounds_min)
+        { // If this is a boundary pixel && has a lesser value than
+          // the currently recorded value...
+          (*flatPtr).second.bounds_min = searchIt.GetPixel(nPos);
+          (*flatPtr).second.min_label_ptr = labelIt[nPos];
+        }
+        if (Math::AlmostEquals(searchIt.GetPixel(nCenter), searchIt.GetPixel(nPos)))
+        {
+          if (labelIt.GetPixel(nPos) != NULL_LABEL)
           {
-          if ( labelIt.GetPixel(nPos) != NULL_LABEL )
-            {
             // Pick up any equivalencies we missed before.
-            equivalentLabels->Add( labelIt.GetPixel(nCenter),
-                                   labelIt.GetPixel(nPos) );
-            }
+            equivalentLabels->Add(labelIt.GetPixel(nCenter), labelIt.GetPixel(nPos));
+          }
           // If the following is encountered, it means that there is a
           // logic flaw in the first pass of this algorithm where flat
           // regions are initially detected and linked.
 #ifndef NDEBUG
-          else { itkDebugMacro("An unexpected but non-fatal error has occurred."); }
-#endif
+          else
+          {
+            itkDebugMacro("An unexpected but non-fatal error has occurred.");
           }
+#endif
         }
       }
     }
+  }
 
   // Merge the flat regions that we identified as connected components.
   Self::MergeFlatRegions(flatRegions, equivalentLabels);
@@ -821,78 +833,74 @@ void Segmenter< TInputImage >
   Self::RelabelImage(output, region, equivalentLabels);
 }
 
-template< typename TInputImage >
-void Segmenter< TInputImage >
-::GradientDescent(InputImageTypePointer img,
-                  ImageRegionType region)
+template <typename TInputImage>
+void
+Segmenter<TInputImage>::GradientDescent(InputImageTypePointer img, ImageRegionType region)
 {
   typename OutputImageType::Pointer output = this->GetOutputImage();
 
-  InputPixelType minVal;
-  unsigned int   i, nPos;
+  InputPixelType                      minVal;
+  unsigned int                        i, nPos;
   typename InputImageType::OffsetType moveIndex;
-  IdentifierType                 newLabel;
-  std::stack< IdentifierType * > updateStack;
+  IdentifierType                      newLabel;
+  std::stack<IdentifierType *>        updateStack;
 
   //
   // Set up our iterators.
   //
-  typename ConstNeighborhoodIterator< InputImageType >::RadiusType rad;
-  typename NeighborhoodIterator< OutputImageType >::RadiusType zeroRad;
-  for ( i = 0; i < ImageDimension; ++i )
-    {
+  typename ConstNeighborhoodIterator<InputImageType>::RadiusType rad;
+  typename NeighborhoodIterator<OutputImageType>::RadiusType     zeroRad;
+  for (i = 0; i < ImageDimension; ++i)
+  {
     rad[i] = 1;
     zeroRad[i] = 0;
-    }
-  ConstNeighborhoodIterator< InputImageType >
-  valueIt(rad, img, region);
-  NeighborhoodIterator< OutputImageType >
-                                         labelIt(zeroRad, output, region);
-  ImageRegionIterator< OutputImageType > it(output, region);
+  }
+  ConstNeighborhoodIterator<InputImageType> valueIt(rad, img, region);
+  NeighborhoodIterator<OutputImageType>     labelIt(zeroRad, output, region);
+  ImageRegionIterator<OutputImageType>      it(output, region);
 
   //
   // Sweep through the image and trace all unlabeled
   // pixels to a labeled region
   //
-  for ( it.GoToBegin(); !it.IsAtEnd(); ++it )
+  for (it.GoToBegin(); !it.IsAtEnd(); ++it)
+  {
+    if (it.Get() == NULL_LABEL)
     {
-    if ( it.Get() == NULL_LABEL )
-      {
-      valueIt.SetLocation( it.GetIndex() );
-      labelIt.SetLocation( it.GetIndex() );
-      newLabel = NULL_LABEL;               // Follow the path of steep-
-      while ( newLabel == NULL_LABEL )     // est descent until a label
-        {                                  // is found.
-        updateStack.push( labelIt.GetCenterPointer() );
+      valueIt.SetLocation(it.GetIndex());
+      labelIt.SetLocation(it.GetIndex());
+      newLabel = NULL_LABEL;         // Follow the path of steep-
+      while (newLabel == NULL_LABEL) // est descent until a label
+      {                              // is found.
+        updateStack.push(labelIt.GetCenterPointer());
         minVal = valueIt.GetPixel(m_Connectivity.index[0]);
         moveIndex = m_Connectivity.direction[0];
-        for ( unsigned int ii = 1; ii < m_Connectivity.size; ++ii )
-          {
+        for (unsigned int ii = 1; ii < m_Connectivity.size; ++ii)
+        {
           nPos = m_Connectivity.index[ii];
-          if ( valueIt.GetPixel(nPos) < minVal )
-            {
+          if (valueIt.GetPixel(nPos) < minVal)
+          {
             minVal = valueIt.GetPixel(nPos);
             moveIndex = m_Connectivity.direction[ii];
-            }
           }
+        }
         valueIt += moveIndex;
         labelIt += moveIndex;
         newLabel = labelIt.GetPixel(0);
-        }
+      }
 
-      while ( !updateStack.empty() ) // Update all the pixels we've traversed
-        {
-        *( updateStack.top() ) = newLabel;
+      while (!updateStack.empty()) // Update all the pixels we've traversed
+      {
+        *(updateStack.top()) = newLabel;
         updateStack.pop();
-        }
       }
     }
+  }
 }
 
-template< typename TInputImage >
-void Segmenter< TInputImage >
-::DescendFlatRegions(flat_region_table_t & flatRegionTable,
-                     ImageRegionType imageRegion)
+template <typename TInputImage>
+void
+Segmenter<TInputImage>::DescendFlatRegions(flat_region_table_t & flatRegionTable, ImageRegionType imageRegion)
 {
   typename OutputImageType::Pointer output = this->GetOutputImage();
   // Assumes all pixels are labeled in the image.  Steps through the flat
@@ -901,172 +909,163 @@ void Segmenter< TInputImage >
   // relabeled to reflect these equivalencies.
   EquivalencyTable::Pointer equivalentLabels = EquivalencyTable::New();
 
-  for ( typename flat_region_table_t::const_iterator region = flatRegionTable.begin();
-        region != flatRegionTable.end(); ++region )
+  for (typename flat_region_table_t::const_iterator region = flatRegionTable.begin(); region != flatRegionTable.end();
+       ++region)
+  {
+    if (((*region).second.bounds_min < (*region).second.value) && (!(*region).second.is_on_boundary))
     {
-    if ( ( ( *region ).second.bounds_min < ( *region ).second.value )
-         && ( !( *region ).second.is_on_boundary ) )
-      {
-      equivalentLabels->Add( ( *region ).first, *( ( *region ).second.min_label_ptr ) );
-      }
+      equivalentLabels->Add((*region).first, *((*region).second.min_label_ptr));
     }
+  }
 
   equivalentLabels->Flatten();
   Self::RelabelImage(output, imageRegion, equivalentLabels);
 }
 
-template< typename TInputImage >
-void Segmenter< TInputImage >
-::UpdateSegmentTable(InputImageTypePointer input, ImageRegionType region)
+template <typename TInputImage>
+void
+Segmenter<TInputImage>::UpdateSegmentTable(InputImageTypePointer input, ImageRegionType region)
 {
   edge_table_hash_t edgeHash;
   edge_table_t      tempEdgeTable;
 
   typename edge_table_hash_t::iterator edge_table_entry_ptr;
-  typename edge_table_t::iterator edge_ptr;
+  typename edge_table_t::iterator      edge_ptr;
 
-  unsigned int i, nPos;
-  typename NeighborhoodIterator< OutputImageType >::RadiusType hoodRadius;
-  typename SegmentTableType::segment_t * segment_ptr;
-  typename SegmentTableType::segment_t temp_segment;
-  IdentifierType segment_label;
+  unsigned int                                               i, nPos;
+  typename NeighborhoodIterator<OutputImageType>::RadiusType hoodRadius;
+  typename SegmentTableType::segment_t *                     segment_ptr;
+  typename SegmentTableType::segment_t                       temp_segment;
+  IdentifierType                                             segment_label;
 
   InputPixelType lowest_edge;
 
   // Grab the data we need.
-  typename OutputImageType::Pointer output    = this->GetOutputImage();
+  typename OutputImageType::Pointer  output = this->GetOutputImage();
   typename SegmentTableType::Pointer segments = this->GetSegmentTable();
 
   // Set up some iterators.
-  for ( i = 0; i < ImageDimension; i++ )
-    {
+  for (i = 0; i < ImageDimension; i++)
+  {
     hoodRadius[i] = 1;
-    }
-  ConstNeighborhoodIterator< InputImageType > searchIt(hoodRadius, input, region);
-  NeighborhoodIterator< OutputImageType >     labelIt(hoodRadius, output, region);
+  }
+  ConstNeighborhoodIterator<InputImageType> searchIt(hoodRadius, input, region);
+  NeighborhoodIterator<OutputImageType>     labelIt(hoodRadius, output, region);
 
   IdentifierType hoodCenter = searchIt.Size() >> 1;
 
-  for ( searchIt.GoToBegin(), labelIt.GoToBegin(); !searchIt.IsAtEnd();
-        ++searchIt, ++labelIt )
-    {
+  for (searchIt.GoToBegin(), labelIt.GoToBegin(); !searchIt.IsAtEnd(); ++searchIt, ++labelIt)
+  {
     segment_label = labelIt.GetPixel(hoodCenter);
 
     // Find the segment corresponding to this label
     // and update its minimum value if necessary.
     segment_ptr = segments->Lookup(segment_label);
     edge_table_entry_ptr = edgeHash.find(segment_label);
-    if ( segment_ptr == ITK_NULLPTR ) // This segment not yet identified.
-      {                     // So add it to the table.
+    if (segment_ptr == nullptr) // This segment not yet identified.
+    {                           // So add it to the table.
       temp_segment.min = searchIt.GetPixel(hoodCenter);
       segments->Add(segment_label, temp_segment);
-      typedef typename edge_table_hash_t::value_type ValueType;
-      edgeHash.insert( ValueType(segment_label,
-                                 tempEdgeTable) );
+      using ValueType = typename edge_table_hash_t::value_type;
+      edgeHash.insert(ValueType(segment_label, tempEdgeTable));
 
       edge_table_entry_ptr = edgeHash.find(segment_label);
-      }
-    else if ( searchIt.GetPixel(hoodCenter) < segment_ptr->min )
-      {
+    }
+    else if (searchIt.GetPixel(hoodCenter) < segment_ptr->min)
+    {
       segment_ptr->min = searchIt.GetPixel(hoodCenter);
-      }
+    }
 
     // Look up each neighboring segment in this segment's edge table.
     // If an edge exists, compare (and reset) the minimum edge value.
     // Note that edges are located *between* two adjacent pixels and
     // the value is taken to be the maximum of the two adjacent pixel
     // values.
-    for ( i = 0; i < m_Connectivity.size; ++i )
-      {
+    for (i = 0; i < m_Connectivity.size; ++i)
+    {
       nPos = m_Connectivity.index[i];
-      if ( labelIt.GetPixel(nPos) != segment_label
-           && labelIt.GetPixel(nPos) != NULL_LABEL )
+      if (labelIt.GetPixel(nPos) != segment_label && labelIt.GetPixel(nPos) != NULL_LABEL)
+      {
+        if (searchIt.GetPixel(nPos) < searchIt.GetPixel(hoodCenter))
         {
-        if ( searchIt.GetPixel(nPos) < searchIt.GetPixel(hoodCenter) )
-          {
           lowest_edge = searchIt.GetPixel(hoodCenter); // We want the
-          }
+        }
         else
-          {
-          lowest_edge = searchIt.GetPixel(nPos);       // max of the
-          }
+        {
+          lowest_edge = searchIt.GetPixel(nPos); // max of the
+        }
         // adjacent pixels
 
-        edge_ptr = ( *edge_table_entry_ptr ).second.find( labelIt.GetPixel(nPos) );
-        if ( edge_ptr == ( *edge_table_entry_ptr ).second.end() )
-          {     // This edge has not been identified yet.
-          typedef typename edge_table_t::value_type ValueType;
-          ( *edge_table_entry_ptr ).second.insert(
-            ValueType(labelIt.GetPixel(nPos), lowest_edge) );
-          }
-        else if ( lowest_edge < ( *edge_ptr ).second )
-          {
-          ( *edge_ptr ).second = lowest_edge;
-          }
+        edge_ptr = (*edge_table_entry_ptr).second.find(labelIt.GetPixel(nPos));
+        if (edge_ptr == (*edge_table_entry_ptr).second.end())
+        { // This edge has not been identified yet.
+          using ValueType = typename edge_table_t::value_type;
+          (*edge_table_entry_ptr).second.insert(ValueType(labelIt.GetPixel(nPos), lowest_edge));
+        }
+        else if (lowest_edge < (*edge_ptr).second)
+        {
+          (*edge_ptr).second = lowest_edge;
         }
       }
     }
+  }
 
   //
   // Copy all of the edge tables into the edge lists of the
   // segment table.
   //
-  IdentifierType listsz;
+  IdentifierType                                   listsz;
   typename SegmentTableType::edge_list_t::iterator list_ptr;
-  for ( edge_table_entry_ptr = edgeHash.begin();
-        edge_table_entry_ptr != edgeHash.end();
-        edge_table_entry_ptr++ )
-    {
+  for (edge_table_entry_ptr = edgeHash.begin(); edge_table_entry_ptr != edgeHash.end(); ++edge_table_entry_ptr)
+  {
     // Lookup the corresponding segment entry
-    segment_ptr = segments->Lookup( ( *edge_table_entry_ptr ).first );
-    if ( segment_ptr == ITK_NULLPTR )
-      {
-      itkGenericExceptionMacro (<< "UpdateSegmentTable:: An unexpected and fatal error has occurred.");
-      }
+    segment_ptr = segments->Lookup((*edge_table_entry_ptr).first);
+    if (segment_ptr == nullptr)
+    {
+      itkGenericExceptionMacro(<< "UpdateSegmentTable:: An unexpected and fatal error has occurred.");
+    }
 
     // Copy into the segment list
-    listsz = static_cast< IdentifierType >( ( *edge_table_entry_ptr ).second.size() );
+    listsz = static_cast<IdentifierType>((*edge_table_entry_ptr).second.size());
     segment_ptr->edge_list.resize(listsz);
-    edge_ptr = ( *edge_table_entry_ptr ).second.begin();
+    edge_ptr = (*edge_table_entry_ptr).second.begin();
     list_ptr = segment_ptr->edge_list.begin();
-    while ( edge_ptr != ( *edge_table_entry_ptr ).second.end() )
-      {
-      list_ptr->label = ( *edge_ptr ).first;
-      list_ptr->height = ( *edge_ptr ).second;
-      edge_ptr++;
-      list_ptr++;
-      }
+    while (edge_ptr != (*edge_table_entry_ptr).second.end())
+    {
+      list_ptr->label = (*edge_ptr).first;
+      list_ptr->height = (*edge_ptr).second;
+      ++edge_ptr;
+      ++list_ptr;
+    }
 
     // Clean up memory as we go
-    ( *edge_table_entry_ptr ).second.clear();
-    }
+    (*edge_table_entry_ptr).second.clear();
+  }
 }
 
-template< typename TInputImage >
-void Segmenter< TInputImage >
-::BuildRetainingWall(InputImageTypePointer img,
-                     ImageRegionType region,
-                     InputPixelType value)
+template <typename TInputImage>
+void
+Segmenter<TInputImage>::BuildRetainingWall(InputImageTypePointer img, ImageRegionType region, InputPixelType value)
 {
   unsigned int i;
 
-  typename ImageRegionType::SizeType sz;
+  typename ImageRegionType::SizeType  sz;
   typename ImageRegionType::IndexType idx;
-  ImageRegionType reg;
+  ImageRegionType                     reg;
 
   // Loop through the dimensions and populate the LOW and HIGH faces regions.
-  for ( i = 0; i < ImageDimension; ++i )
-    {
-    idx = region.GetIndex();       // LOW face
-    sz  = region.GetSize();
+  for (i = 0; i < ImageDimension; ++i)
+  {
+    idx = region.GetIndex(); // LOW face
+    sz = region.GetSize();
     sz[i] = 1;
     reg.SetIndex(idx);
     reg.SetSize(sz);
     Segmenter::SetInputImageValues(img, reg, value);
-    idx[i] = region.GetSize()[i] + region.GetIndex()[i] - 1;  // HIGH face
+    idx[i] = region.GetSize()[i] + region.GetIndex()[i] - 1; // HIGH face
     reg.SetIndex(idx);
     Segmenter::SetInputImageValues(img, reg, value);
-    }
+  }
 }
 
 /*
@@ -1074,57 +1073,60 @@ void Segmenter< TInputImage >
   Algorithm helper methods and debugging methods
   ----------------------------------------------------------------------------
 */
-template< typename TInputImage >
-void Segmenter< TInputImage >
-::SetInputImageValues(InputImageTypePointer img,
-                      ImageRegionType region,
-                      InputPixelType value)
+template <typename TInputImage>
+void
+Segmenter<TInputImage>::SetInputImageValues(InputImageTypePointer img, ImageRegionType region, InputPixelType value)
 {
-  ImageRegionIterator< InputImageType > it(img, region);
+  ImageRegionIterator<InputImageType> it(img, region);
   it.GoToBegin();
-  while ( !it.IsAtEnd() )
-    {
+  while (!it.IsAtEnd())
+  {
     it.Set(value);
     ++it;
-    }
+  }
 }
 
-template< typename TInputImage >
-void Segmenter< TInputImage >
-::SetOutputImageValues(OutputImageTypePointer img,
-                       ImageRegionType region,
-                       IdentifierType value)
+template <typename TInputImage>
+void
+Segmenter<TInputImage>::SetOutputImageValues(OutputImageTypePointer img, ImageRegionType region, IdentifierType value)
 {
-  ImageRegionIterator< OutputImageType > it(img, region);
+  ImageRegionIterator<OutputImageType> it(img, region);
   it.GoToBegin();
-  while ( !it.IsAtEnd() )
-    {
+  while (!it.IsAtEnd())
+  {
     it.Set(value);
     ++it;
-    }
+  }
 }
 
-template< typename TInputImage >
-void Segmenter< TInputImage >
-::MinMax(InputImageTypePointer img, ImageRegionType region,
-         InputPixelType & min, InputPixelType & max)
+template <typename TInputImage>
+void
+Segmenter<TInputImage>::MinMax(InputImageTypePointer img,
+                               ImageRegionType       region,
+                               InputPixelType &      min,
+                               InputPixelType &      max)
 {
-  ImageRegionIterator< InputImageType > it(img, region);
+  ImageRegionIterator<InputImageType> it(img, region);
   it.GoToBegin();
   min = it.Value();
   max = it.Value();
-  while ( !it.IsAtEnd() )
+  while (!it.IsAtEnd())
+  {
+    if (it.Get() > max)
     {
-    if ( it.Get() > max ) { max = it.Get(); }
-    if ( it.Get() < min ) { min = it.Get(); }
-    ++it;
+      max = it.Get();
+    }
+    if (it.Get() < min)
+    {
+      min = it.Get();
     }
+    ++it;
+  }
 }
 
-template< typename TInputImage >
-void Segmenter< TInputImage >
-::MergeFlatRegions(flat_region_table_t & regions,
-                   EquivalencyTable::Pointer eqTable)
+template <typename TInputImage>
+void
+Segmenter<TInputImage>::MergeFlatRegions(flat_region_table_t & regions, EquivalencyTable::Pointer eqTable)
 {
   // Note that the labels must have no interdependencies.  That is,
   // every key must map to a value that is not itself a key in the
@@ -1134,106 +1136,103 @@ void Segmenter< TInputImage >
   eqTable->Flatten();
 
   typename flat_region_table_t::iterator a, b;
-  for ( EquivalencyTable::ConstIterator it = eqTable->Begin();
-        it != eqTable->End(); ++it )
+  for (EquivalencyTable::ConstIterator it = eqTable->Begin(); it != eqTable->End(); ++it)
+  {
+    if (((a = regions.find((*it).first)) == regions.end()) || ((b = regions.find((*it).second)) == regions.end()))
     {
-    if ( ( ( a = regions.find( ( *it ).first ) ) == regions.end() )
-         || ( ( b = regions.find( ( *it ).second ) ) == regions.end() ) )
-      {
-      itkGenericExceptionMacro (<< "MergeFlatRegions:: An unexpected and fatal error has occurred.");
-      }
+      itkGenericExceptionMacro(<< "MergeFlatRegions:: An unexpected and fatal error has occurred.");
+    }
 
-    if ( ( *a ).second.bounds_min < ( *b ).second.bounds_min )
-      {
-      ( *b ).second.bounds_min = ( *a ).second.bounds_min;
-      ( *b ).second.min_label_ptr = ( *a ).second.min_label_ptr;
-      }
+    if ((*a).second.bounds_min < (*b).second.bounds_min)
+    {
+      (*b).second.bounds_min = (*a).second.bounds_min;
+      (*b).second.min_label_ptr = (*a).second.min_label_ptr;
+    }
 
     regions.erase(a);
-    }
+  }
 }
 
-template< typename TInputImage >
-void Segmenter< TInputImage >
-::RelabelImage(OutputImageTypePointer img,
-               ImageRegionType region,
-               EquivalencyTable::Pointer eqTable)
+template <typename TInputImage>
+void
+Segmenter<TInputImage>::RelabelImage(OutputImageTypePointer    img,
+                                     ImageRegionType           region,
+                                     EquivalencyTable::Pointer eqTable)
 {
   eqTable->Flatten();
 
-  IdentifierType                         temp;
-  ImageRegionIterator< OutputImageType > it(img, region);
+  IdentifierType                       temp;
+  ImageRegionIterator<OutputImageType> it(img, region);
 
   it.GoToBegin();
-  while ( !it.IsAtEnd() )
+  while (!it.IsAtEnd())
+  {
+    temp = eqTable->Lookup(it.Get());
+    if (temp != it.Get())
     {
-    temp = eqTable->Lookup( it.Get() );
-    if ( temp != it.Get() )  { it.Set(temp); }
-    ++it;
+      it.Set(temp);
     }
+    ++it;
+  }
 }
 
-template< typename TInputImage >
-void Segmenter< TInputImage >::Threshold(InputImageTypePointer destination,
-                                         InputImageTypePointer source,
-                                         const ImageRegionType source_region,
-                                         const ImageRegionType destination_region,
-                                         InputPixelType threshold)
+template <typename TInputImage>
+void
+Segmenter<TInputImage>::Threshold(InputImageTypePointer destination,
+                                  InputImageTypePointer source,
+                                  const ImageRegionType source_region,
+                                  const ImageRegionType destination_region,
+                                  InputPixelType        threshold)
 {
-  ImageRegionIterator< InputImageType > dIt(destination, destination_region);
-  ImageRegionIterator< InputImageType > sIt(source, source_region);
+  ImageRegionIterator<InputImageType> dIt(destination, destination_region);
+  ImageRegionIterator<InputImageType> sIt(source, source_region);
 
   dIt.GoToBegin();
   sIt.GoToBegin();
 
   // Assumes that source_region and destination region are the same size.  Does
   // no checking!!
-  if ( NumericTraits< InputPixelType >::is_integer )
-    {
+  if (NumericTraits<InputPixelType>::is_integer)
+  {
     // integral data type, if any pixel is at the maximum possible
     // value for the data type, then drop the value by one intensity
     // value. This the watershed algorithm to construct a "barrier" or
     // "wall" around the image that will stop the watershed without
     // requiring a expensive boundary condition checks.
-    while ( !dIt.IsAtEnd() )
-      {
+    while (!dIt.IsAtEnd())
+    {
       InputPixelType tmp = sIt.Get();
-      if ( tmp < threshold )
-        {
+      if (tmp < threshold)
+      {
         dIt.Set(threshold);
-        }
-CLANG_PRAGMA_PUSH
-CLANG_SUPPRESS_Wfloat_equal
-      else if ( tmp == NumericTraits< InputPixelType >::max() )
-CLANG_PRAGMA_POP
-        {
-        dIt.Set(tmp - NumericTraits< InputPixelType >::OneValue());
-        }
-      else
-        {
-        dIt.Set(tmp);
-        }
+      }
+      CLANG_PRAGMA_PUSH
+      CLANG_SUPPRESS_Wfloat_equal else if (tmp == NumericTraits<InputPixelType>::max()) CLANG_PRAGMA_POP
+      {
+        dIt.Set(tmp - NumericTraits<InputPixelType>::OneValue());
+      }
+      else { dIt.Set(tmp); }
       ++dIt;
       ++sIt;
-      }
     }
+  }
   else
-    {
+  {
     // floating point data, no need to worry about overflow
-    while ( !dIt.IsAtEnd() )
+    while (!dIt.IsAtEnd())
+    {
+      if (sIt.Get() < threshold)
       {
-      if ( sIt.Get() < threshold )
-        {
         dIt.Set(threshold);
-        }
+      }
       else
-        {
-        dIt.Set( sIt.Get() );
-        }
+      {
+        dIt.Set(sIt.Get());
+      }
       ++dIt;
       ++sIt;
-      }
     }
+  }
 }
 
 /*
@@ -1241,29 +1240,31 @@ CLANG_PRAGMA_POP
   Pipeline methods
   ----------------------------------------------------------------------------
 */
-template< typename TInputImage >
-typename Segmenter< TInputImage >::DataObjectPointer
-Segmenter< TInputImage >
-::MakeOutput(DataObjectPointerArraySizeType idx)
+template <typename TInputImage>
+typename Segmenter<TInputImage>::DataObjectPointer
+Segmenter<TInputImage>::MakeOutput(DataObjectPointerArraySizeType idx)
 {
-  if ( idx == 0 )
-    {
+  if (idx == 0)
+  {
     return OutputImageType::New().GetPointer();
-    }
-  else if ( idx == 1 )
-    {
+  }
+  else if (idx == 1)
+  {
     return SegmentTableType::New().GetPointer();
-    }
-  else if ( idx == 2 )
-    {
+  }
+  else if (idx == 2)
+  {
     return BoundaryType::New().GetPointer();
-    }
-  else { return ITK_NULLPTR; }
+  }
+  else
+  {
+    return nullptr;
+  }
 }
 
-template< typename TInputImage >
+template <typename TInputImage>
 void
-Segmenter< TInputImage >::UpdateOutputInformation()
+Segmenter<TInputImage>::UpdateOutputInformation()
 {
   unsigned int i;
 
@@ -1271,28 +1272,26 @@ Segmenter< TInputImage >::UpdateOutputInformation()
   Superclass::UpdateOutputInformation();
 
   // get pointers to the input and output
-  typename InputImageType::Pointer inputPtr = this->GetInputImage();
+  typename InputImageType::Pointer  inputPtr = this->GetInputImage();
   typename OutputImageType::Pointer outputPtr = this->GetOutputImage();
 
-  if ( !inputPtr || !outputPtr )
-    {
+  if (!inputPtr || !outputPtr)
+  {
     return;
-    }
+  }
   // we need to compute the output spacing, the output image size, and the
   // output image start index
-  const typename InputImageType::SizeType &   inputSize =
-    inputPtr->GetLargestPossibleRegion().GetSize();
-  const typename InputImageType::IndexType &  inputStartIndex =
-    inputPtr->GetLargestPossibleRegion().GetIndex();
+  const typename InputImageType::SizeType &  inputSize = inputPtr->GetLargestPossibleRegion().GetSize();
+  const typename InputImageType::IndexType & inputStartIndex = inputPtr->GetLargestPossibleRegion().GetIndex();
 
-  typename OutputImageType::SizeType outputSize;
+  typename OutputImageType::SizeType  outputSize;
   typename OutputImageType::IndexType outputStartIndex;
 
-  for ( i = 0; i < OutputImageType::ImageDimension; i++ )
-    {
+  for (i = 0; i < OutputImageType::ImageDimension; i++)
+  {
     outputSize[i] = inputSize[i];
-    outputStartIndex[i]  = inputStartIndex[i];
-    }
+    outputStartIndex[i] = inputStartIndex[i];
+  }
 
   typename OutputImageType::RegionType outputLargestPossibleRegion;
   outputLargestPossibleRegion.SetSize(outputSize);
@@ -1301,89 +1300,85 @@ Segmenter< TInputImage >::UpdateOutputInformation()
   outputPtr->SetLargestPossibleRegion(outputLargestPossibleRegion);
 }
 
-template< typename TInputImage >
-void Segmenter< TInputImage >::GenerateInputRequestedRegion()
+template <typename TInputImage>
+void
+Segmenter<TInputImage>::GenerateInputRequestedRegion()
 {
   // call the superclass' implementation of this method
   Superclass::GenerateInputRequestedRegion();
 
   // get pointers to the input and output
-  typename InputImageType::Pointer inputPtr  = this->GetInputImage();
+  typename InputImageType::Pointer  inputPtr = this->GetInputImage();
   typename OutputImageType::Pointer outputPtr = this->GetOutputImage();
 
-  if ( !inputPtr || !outputPtr )
-    {
+  if (!inputPtr || !outputPtr)
+  {
     return;
-    }
+  }
 
   //
   // FOR NOW WE'LL JUST SET THE INPUT REGION TO THE OUTPUT REGION
   // AND OVERRIDE THIS LATER
   //
-  inputPtr->SetRequestedRegion( outputPtr->GetRequestedRegion() );
+  inputPtr->SetRequestedRegion(outputPtr->GetRequestedRegion());
 }
 
-template< typename TInputImage >
+template <typename TInputImage>
 void
-Segmenter< TInputImage >
-::GenerateOutputRequestedRegion(DataObject *output)
+Segmenter<TInputImage>::GenerateOutputRequestedRegion(DataObject * output)
 {
   // Only the Image output need to be propagated through.
   // No choice but to use RTTI here.
-  ImageBase< ImageDimension > *imgData;
-  ImageBase< ImageDimension > *op;
-  imgData = dynamic_cast< ImageBase< ImageDimension > * >( output );
+  ImageBase<ImageDimension> * imgData;
+  ImageBase<ImageDimension> * op;
+  imgData = dynamic_cast<ImageBase<ImageDimension> *>(output);
   typename TInputImage::RegionType c_reg;
 
-  if ( imgData )
+  if (imgData)
+  {
+    std::vector<ProcessObject::DataObjectPointer>::size_type idx;
+    for (idx = 0; idx < this->GetNumberOfIndexedOutputs(); ++idx)
     {
-    std::vector< ProcessObject::DataObjectPointer >::size_type idx;
-    for ( idx = 0; idx < this->GetNumberOfIndexedOutputs(); ++idx )
+      if (this->GetOutput(idx) && this->GetOutput(idx) != output)
       {
-      if ( this->GetOutput(idx) && this->GetOutput(idx) != output )
-        {
-        op = dynamic_cast< ImageBase< ImageDimension >
-                           * >( this->GetOutput(idx) );
+        op = dynamic_cast<ImageBase<ImageDimension> *>(this->GetOutput(idx));
 
-        if ( op ) { this->GetOutput(idx)->SetRequestedRegion(output); }
+        if (op)
+        {
+          this->GetOutput(idx)->SetRequestedRegion(output);
         }
       }
     }
+  }
 }
 
-template< typename TInputImage >
-Segmenter< TInputImage >
-::Segmenter()
+template <typename TInputImage>
+Segmenter<TInputImage>::Segmenter()
 {
   m_Threshold = 0.0;
   m_MaximumFloodLevel = 1.0;
   m_CurrentLabel = 1;
   m_DoBoundaryAnalysis = false;
   m_SortEdgeLists = true;
-  m_Connectivity.direction = ITK_NULLPTR;
-  m_Connectivity.index = ITK_NULLPTR;
-  typename OutputImageType::Pointer img =
-    static_cast< OutputImageType * >( this->MakeOutput(0).GetPointer() );
-  typename SegmentTableType::Pointer st =
-    static_cast< SegmentTableType * >( this->MakeOutput(1).GetPointer() );
-  typename BoundaryType::Pointer bd =
-    static_cast< BoundaryType * >( this->MakeOutput(2).GetPointer() );
+  m_Connectivity.direction = nullptr;
+  m_Connectivity.index = nullptr;
+  typename OutputImageType::Pointer  img = static_cast<OutputImageType *>(this->MakeOutput(0).GetPointer());
+  typename SegmentTableType::Pointer st = static_cast<SegmentTableType *>(this->MakeOutput(1).GetPointer());
+  typename BoundaryType::Pointer     bd = static_cast<BoundaryType *>(this->MakeOutput(2).GetPointer());
   this->SetNumberOfRequiredOutputs(3);
-  this->ProcessObject::SetNthOutput( 0, img.GetPointer() );
-  this->ProcessObject::SetNthOutput( 1, st.GetPointer() );
-  this->ProcessObject::SetNthOutput( 2, bd.GetPointer() );
+  this->ProcessObject::SetNthOutput(0, img.GetPointer());
+  this->ProcessObject::SetNthOutput(1, st.GetPointer());
+  this->ProcessObject::SetNthOutput(2, bd.GetPointer());
 
   // Allocate memory for connectivity
   m_Connectivity.size = 2 * ImageDimension;
   m_Connectivity.index = new unsigned int[m_Connectivity.size];
-  m_Connectivity.direction =
-    new typename InputImageType::OffsetType[m_Connectivity.size];
+  m_Connectivity.direction = new typename InputImageType::OffsetType[m_Connectivity.size];
 }
 
-template< typename TInputImage >
+template <typename TInputImage>
 void
-Segmenter< TInputImage >
-::PrintSelf(std::ostream & os, Indent indent) const
+Segmenter<TInputImage>::PrintSelf(std::ostream & os, Indent indent) const
 {
   Superclass::PrintSelf(os, indent);
   os << indent << "SortEdgeLists: " << m_SortEdgeLists << std::endl;
diff --git a/Modules/Segmentation/Watersheds/src/itkOneWayEquivalencyTable.cxx b/Modules/Segmentation/Watersheds/src/itkOneWayEquivalencyTable.cxx
index 14845b0fb7..9587de215b 100644
--- a/Modules/Segmentation/Watersheds/src/itkOneWayEquivalencyTable.cxx
+++ b/Modules/Segmentation/Watersheds/src/itkOneWayEquivalencyTable.cxx
@@ -19,19 +19,23 @@
 
 namespace itk
 {
-bool OneWayEquivalencyTable::Add(unsigned long a, unsigned long b)
+bool
+OneWayEquivalencyTable::Add(unsigned long a, unsigned long b)
 {
   //
   // Unlike EquivalencyTable, the order of the equivalence is important.
   //
-  std::pair< Iterator, bool > result;
-  if ( a == b ) { return false; }
-  result = m_HashMap.insert( ValueType(a, b) );
+  std::pair<Iterator, bool> result;
+  if (a == b)
+  {
+    return false;
+  }
+  result = m_HashMap.insert(ValueType(a, b));
 
   return result.second;
 }
 
-//void OneWayEquivalencyTable::PrintHashTable()
+// void OneWayEquivalencyTable::PrintHashTable()
 //{
 //  ConstIterator it = this->Begin();
 //  while (it != this->End() )
@@ -41,18 +45,20 @@ bool OneWayEquivalencyTable::Add(unsigned long a, unsigned long b)
 //    }
 //}
 
-void OneWayEquivalencyTable::Flatten()
+void
+OneWayEquivalencyTable::Flatten()
 {
   Iterator it = this->Begin();
 
-  while ( it != this->End() )
-    {
-    ( *it ).second = this->RecursiveLookup( ( *it ).first );
+  while (it != this->End())
+  {
+    (*it).second = this->RecursiveLookup((*it).first);
     it++;
-    }
+  }
 }
 
-unsigned long OneWayEquivalencyTable::RecursiveLookup(const unsigned long a) const
+unsigned long
+OneWayEquivalencyTable::RecursiveLookup(const unsigned long a) const
 {
   unsigned long ans = a;
   unsigned long last_ans = a;
@@ -60,22 +66,21 @@ unsigned long OneWayEquivalencyTable::RecursiveLookup(const unsigned long a) con
   ConstIterator it;
   ConstIterator hashEnd = m_HashMap.end();
 
-  while ( ( it = m_HashMap.find(ans) ) != hashEnd )
+  while ((it = m_HashMap.find(ans)) != hashEnd)
+  {
+    ans = (*it).second;
+    if (ans == a)
     {
-    ans = ( *it ).second;
-    if ( ans == a )
-      {
-      return last_ans;              // about to cycle again.
-      }
-    last_ans = ans;
+      return last_ans; // about to cycle again.
     }
+    last_ans = ans;
+  }
 
   return ans;
 }
 
 void
-OneWayEquivalencyTable
-::PrintSelf(std::ostream & os, Indent indent) const
+OneWayEquivalencyTable ::PrintSelf(std::ostream & os, Indent indent) const
 {
   Superclass::PrintSelf(os, indent);
 }
diff --git a/Modules/Segmentation/Watersheds/src/itkWatershedMiniPipelineProgressCommand.cxx b/Modules/Segmentation/Watersheds/src/itkWatershedMiniPipelineProgressCommand.cxx
index f1fe886655..5f7223867b 100644
--- a/Modules/Segmentation/Watersheds/src/itkWatershedMiniPipelineProgressCommand.cxx
+++ b/Modules/Segmentation/Watersheds/src/itkWatershedMiniPipelineProgressCommand.cxx
@@ -19,46 +19,48 @@
 
 namespace itk
 {
-void WatershedMiniPipelineProgressCommand
-::Execute(Object *caller, const EventObject & event)
+void
+WatershedMiniPipelineProgressCommand ::Execute(Object * caller, const EventObject & event)
 {
-  ProcessObject *po = dynamic_cast< ProcessObject * >( caller );
+  auto * po = dynamic_cast<ProcessObject *>(caller);
 
-  if ( !po ) { return; }
+  if (!po)
+  {
+    return;
+  }
 
-  if ( typeid( event ) == typeid( ProgressEvent ) )
+  if (typeid(event) == typeid(ProgressEvent))
+  {
+    m_Filter->UpdateProgress(static_cast<float>((m_Count + po->GetProgress()) / static_cast<float>(m_NumberOfFilters)));
+    if (po->GetProgress() == 1.0)
     {
-    m_Filter->UpdateProgress(
-      static_cast< float >( ( m_Count + po->GetProgress() ) /
-      static_cast< float >( m_NumberOfFilters ) ) );
-    if ( po->GetProgress() == 1.0 )
-      {
       m_Count += 1.0;
-      }
     }
+  }
 }
 
-void WatershedMiniPipelineProgressCommand
-::Execute(const Object *caller, const EventObject & event)
+void
+WatershedMiniPipelineProgressCommand ::Execute(const Object * caller, const EventObject & event)
 {
-  ProcessObject *po = dynamic_cast< ProcessObject * >( const_cast< Object * >( caller ) );
+  auto * po = dynamic_cast<ProcessObject *>(const_cast<Object *>(caller));
 
-  if ( !po ) { return; }
+  if (!po)
+  {
+    return;
+  }
 
-  if ( typeid( event ) == typeid( ProgressEvent ) )
+  if (typeid(event) == typeid(ProgressEvent))
+  {
+    m_Filter->UpdateProgress(static_cast<float>((m_Count + po->GetProgress()) / static_cast<float>(m_NumberOfFilters)));
+    if (po->GetProgress() == 1.0)
     {
-    m_Filter->UpdateProgress(
-      static_cast< float >( ( m_Count + po->GetProgress() ) /
-      static_cast< float >( m_NumberOfFilters ) ) );
-    if ( po->GetProgress() == 1.0 )
-      {
       m_Count += 1.0;
-      }
     }
+  }
 }
 
-void WatershedMiniPipelineProgressCommand
-::PrintSelf(std::ostream & os, Indent indent) const
+void
+WatershedMiniPipelineProgressCommand ::PrintSelf(std::ostream & os, Indent indent) const
 {
   Superclass::PrintSelf(os, indent);
   os << indent << "NumberOfFilters: " << m_NumberOfFilters << std::endl;
diff --git a/Modules/Segmentation/Watersheds/test/Baseline/PythonWatershedSegmentation1Test.png.md5 b/Modules/Segmentation/Watersheds/test/Baseline/PythonWatershedSegmentation1Test.png.md5
new file mode 100644
index 0000000000..d74ad6a965
--- /dev/null
+++ b/Modules/Segmentation/Watersheds/test/Baseline/PythonWatershedSegmentation1Test.png.md5
@@ -0,0 +1 @@
+012779e61538b8a6089518362518d7db
diff --git a/Modules/Segmentation/Watersheds/test/Baseline/PythonWatershedSegmentation1Test.png.sha512 b/Modules/Segmentation/Watersheds/test/Baseline/PythonWatershedSegmentation1Test.png.sha512
new file mode 100644
index 0000000000..383b38edc5
--- /dev/null
+++ b/Modules/Segmentation/Watersheds/test/Baseline/PythonWatershedSegmentation1Test.png.sha512
@@ -0,0 +1 @@
+0f8f0e34a409879e1942c9a56b791102690e8d09badf395938fbbcbc8437ff61296aaba633cc5ef4b524169ba8a3c5a50fdf2e81854e454a7730043dab697654
diff --git a/Modules/Segmentation/Watersheds/test/Baseline/itkIsolatedWatershedImageFilterTest.png.md5 b/Modules/Segmentation/Watersheds/test/Baseline/itkIsolatedWatershedImageFilterTest.png.md5
index 45b63072d3..3799ff02f7 100644
--- a/Modules/Segmentation/Watersheds/test/Baseline/itkIsolatedWatershedImageFilterTest.png.md5
+++ b/Modules/Segmentation/Watersheds/test/Baseline/itkIsolatedWatershedImageFilterTest.png.md5
@@ -1 +1 @@
-b19ea6df9f910060bb62fa5e983c59f1
+ffa0ca2b5f46c024bc408c6a77b6453c
diff --git a/Modules/Segmentation/Watersheds/test/Baseline/itkIsolatedWatershedImageFilterTest.png.sha512 b/Modules/Segmentation/Watersheds/test/Baseline/itkIsolatedWatershedImageFilterTest.png.sha512
index 178c84667e..78cbb4b405 100644
--- a/Modules/Segmentation/Watersheds/test/Baseline/itkIsolatedWatershedImageFilterTest.png.sha512
+++ b/Modules/Segmentation/Watersheds/test/Baseline/itkIsolatedWatershedImageFilterTest.png.sha512
@@ -1 +1 @@
-15fc65785e7054a10c6ad09f3e7c5add1a6cd54d7e2e1a8171a13efbc00c699f12edca296ffb541a77fe4d294682a1f3373733d37995fd83f06660b06eb1f8ac
+dcb1e52034ab274e83b7502337ac2d22670c032a25530be41c828ade01315c014977d8ad79f4295639ff616b4df42b36cdf4007b48882410b9072a4c9a973707
diff --git a/Modules/Segmentation/Watersheds/test/Input/VisibleWomanEyeSlice.png.md5 b/Modules/Segmentation/Watersheds/test/Input/VisibleWomanEyeSlice.png.md5
new file mode 100644
index 0000000000..63e938ba48
--- /dev/null
+++ b/Modules/Segmentation/Watersheds/test/Input/VisibleWomanEyeSlice.png.md5
@@ -0,0 +1 @@
+1aaec57175b272378b0256134b607afc
diff --git a/Modules/Segmentation/Watersheds/test/Input/VisibleWomanEyeSlice.png.sha512 b/Modules/Segmentation/Watersheds/test/Input/VisibleWomanEyeSlice.png.sha512
new file mode 100644
index 0000000000..4578ee8fb2
--- /dev/null
+++ b/Modules/Segmentation/Watersheds/test/Input/VisibleWomanEyeSlice.png.sha512
@@ -0,0 +1 @@
+a9877ac2537abd0604b8a0c6f2cd06f2aa05e3f9d2537b9a56472283fca1681d990e7be9a597bf8fd229a396cc21635f8d7638fb4012d7a852861a9a626d087b
diff --git a/Modules/Segmentation/Watersheds/test/itkIsolatedWatershedImageFilterTest.cxx b/Modules/Segmentation/Watersheds/test/itkIsolatedWatershedImageFilterTest.cxx
index 9fbbbbee8b..6b5a932ff5 100644
--- a/Modules/Segmentation/Watersheds/test/itkIsolatedWatershedImageFilterTest.cxx
+++ b/Modules/Segmentation/Watersheds/test/itkIsolatedWatershedImageFilterTest.cxx
@@ -24,118 +24,115 @@
 #include <fstream>
 
 
-int itkIsolatedWatershedImageFilterTest( int argc, char* argv[] )
+int
+itkIsolatedWatershedImageFilterTest(int argc, char * argv[])
 {
-  if( argc < 9 )
-    {
+  if (argc < 9)
+  {
     std::cerr << "Missing parameters" << std::endl;
-    std::cerr << "Usage: " << argv[0]
-      << " InputImage"
-      << " OutputImage"
-      << " seed1_x"
-      << " seed1_y"
-      << " seed2_x"
-      << " seed2_y"
-      << " threshold"
-      << " isolatedValueTolerance";
+    std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " InputImage"
+              << " OutputImage"
+              << " seed1_x"
+              << " seed1_y"
+              << " seed2_x"
+              << " seed2_y"
+              << " threshold"
+              << " isolatedValueTolerance";
     std::cerr << std::endl;
     return EXIT_FAILURE;
-    }
+  }
 
-  const unsigned int Dimension = 2;
+  constexpr unsigned int Dimension = 2;
 
-  typedef unsigned char                       PixelType;
-  typedef itk::Image< PixelType, Dimension >  ImageType;
+  using PixelType = unsigned char;
+  using ImageType = itk::Image<PixelType, Dimension>;
 
-  itk::ImageFileReader< ImageType >::Pointer reader =
-    itk::ImageFileReader< ImageType >::New();
+  itk::ImageFileReader<ImageType>::Pointer reader = itk::ImageFileReader<ImageType>::New();
 
-  reader->SetFileName( argv[1] );
+  reader->SetFileName(argv[1]);
 
-  TRY_EXPECT_NO_EXCEPTION( reader->Update() );
+  ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update());
 
 
   // Create the IsolatedWatershedImageFilter object
-  typedef itk::IsolatedWatershedImageFilter< ImageType, ImageType > FilterType;
+  using FilterType = itk::IsolatedWatershedImageFilter<ImageType, ImageType>;
 
   FilterType::Pointer filter = FilterType::New();
 
-  EXERCISE_BASIC_OBJECT_METHODS( filter, IsolatedWatershedImageFilter,
-    ImageToImageFilter );
+  ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, IsolatedWatershedImageFilter, ImageToImageFilter);
 
 
-  filter->SetInput( reader->GetOutput() );
+  filter->SetInput(reader->GetOutput());
 
 
   FilterType::IndexType seed1, seed2;
-  seed1.Fill( 0 );
-  seed2.Fill( 0 );
+  seed1.Fill(0);
+  seed2.Fill(0);
 
   // Test the seeds being outside the input image exception
   ImageType::Pointer inputImage = reader->GetOutput();
 
   ImageType::RegionType region = inputImage->GetLargestPossibleRegion();
-  ImageType::IndexType offset;
-  offset.Fill( 10 );
+  ImageType::IndexType  offset;
+  offset.Fill(10);
 
   seed1[0] = region.GetUpperIndex()[0] + offset[0];
-  filter->SetSeed1( seed1 );
+  filter->SetSeed1(seed1);
 
-  TRY_EXPECT_EXCEPTION( filter->Update() );
+  ITK_TRY_EXPECT_EXCEPTION(filter->Update());
 
-  seed1.Fill( 0 );
-  filter->SetSeed1( seed1 );
+  seed1.Fill(0);
+  filter->SetSeed1(seed1);
 
   seed2[1] = region.GetUpperIndex()[1] + offset[1];
-  filter->SetSeed2( seed2 );
+  filter->SetSeed2(seed2);
 
-  TRY_EXPECT_EXCEPTION( filter->Update() );
+  ITK_TRY_EXPECT_EXCEPTION(filter->Update());
 
 
-  seed1[0] = atoi( argv[3] );
-  seed1[1] = atoi( argv[4] );
-  filter->SetSeed1( seed1 );
-  TEST_SET_GET_VALUE( seed1, filter->GetSeed1() );
+  seed1[0] = std::stoi(argv[3]);
+  seed1[1] = std::stoi(argv[4]);
+  filter->SetSeed1(seed1);
+  ITK_TEST_SET_GET_VALUE(seed1, filter->GetSeed1());
 
-  seed2[0] = atoi( argv[5] );
-  seed2[1] = atoi( argv[6] );
-  filter->SetSeed2( seed2 );
-  TEST_SET_GET_VALUE( seed2, filter->GetSeed2() );
+  seed2[0] = std::stoi(argv[5]);
+  seed2[1] = std::stoi(argv[6]);
+  filter->SetSeed2(seed2);
+  ITK_TEST_SET_GET_VALUE(seed2, filter->GetSeed2());
 
-  double threshold = atof( argv[7] );
-  filter->SetThreshold( threshold );
-  TEST_SET_GET_VALUE( threshold, filter->GetThreshold() );
+  double threshold = std::stod(argv[7]);
+  filter->SetThreshold(threshold);
+  ITK_TEST_SET_GET_VALUE(threshold, filter->GetThreshold());
 
   PixelType replaceValue1 = 255;
-  filter->SetReplaceValue1( replaceValue1 );
-  TEST_SET_GET_VALUE( replaceValue1, filter->GetReplaceValue1() );
+  filter->SetReplaceValue1(replaceValue1);
+  ITK_TEST_SET_GET_VALUE(replaceValue1, filter->GetReplaceValue1());
 
   PixelType replaceValue2 = 127;
-  filter->SetReplaceValue2( replaceValue2 );
-  TEST_SET_GET_VALUE( replaceValue2, filter->GetReplaceValue2() );
+  filter->SetReplaceValue2(replaceValue2);
+  ITK_TEST_SET_GET_VALUE(replaceValue2, filter->GetReplaceValue2());
 
   double upperValueLimit = 1.0;
-  filter->SetUpperValueLimit( upperValueLimit );
-  TEST_SET_GET_VALUE( upperValueLimit, filter->GetUpperValueLimit() );
+  filter->SetUpperValueLimit(upperValueLimit);
+  ITK_TEST_SET_GET_VALUE(upperValueLimit, filter->GetUpperValueLimit());
 
-  double isolatedValueTolerance = atof( argv[8] );
-  filter->SetIsolatedValueTolerance( isolatedValueTolerance );
-  TEST_SET_GET_VALUE( isolatedValueTolerance,
-    filter->GetIsolatedValueTolerance() );
+  double isolatedValueTolerance = std::stod(argv[8]);
+  filter->SetIsolatedValueTolerance(isolatedValueTolerance);
+  ITK_TEST_SET_GET_VALUE(isolatedValueTolerance, filter->GetIsolatedValueTolerance());
 
-  TRY_EXPECT_NO_EXCEPTION( filter->Update() );
+  ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update());
 
 
   double isolatedValue = filter->GetIsolatedValue();
   std::cout << "IsolatedValue: " << isolatedValue << std::endl;
 
   // Write the filter output
-  typedef itk::ImageFileWriter< ImageType > WriterType;
+  using WriterType = itk::ImageFileWriter<ImageType>;
   WriterType::Pointer writer = WriterType::New();
-  writer->SetInput( filter->GetOutput() );
-  writer->SetFileName( argv[2] );
+  writer->SetInput(filter->GetOutput());
+  writer->SetFileName(argv[2]);
 
-  TRY_EXPECT_NO_EXCEPTION( writer->Update() );
+  ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update());
 
 
   std::cout << "Test finished." << std::endl;
diff --git a/Modules/Segmentation/Watersheds/test/itkMorphologicalWatershedFromMarkersImageFilterTest.cxx b/Modules/Segmentation/Watersheds/test/itkMorphologicalWatershedFromMarkersImageFilterTest.cxx
index f47a6cb2b6..b2ba410b0f 100644
--- a/Modules/Segmentation/Watersheds/test/itkMorphologicalWatershedFromMarkersImageFilterTest.cxx
+++ b/Modules/Segmentation/Watersheds/test/itkMorphologicalWatershedFromMarkersImageFilterTest.cxx
@@ -24,124 +24,119 @@
 #include "itkTestingMacros.h"
 
 
-int itkMorphologicalWatershedFromMarkersImageFilterTest( int argc, char * argv[] )
+int
+itkMorphologicalWatershedFromMarkersImageFilterTest(int argc, char * argv[])
 {
-  if( argc < 6 )
-    {
+  if (argc < 6)
+  {
     std::cerr << "Missing parameters" << std::endl;
-    std::cerr << "Usage: " << argv[0]
-      << " inputImageFile"
-      << " markerImageFile"
-      << " outputImageFile"
-      << " markWatershedLine"
-      << " fullyConnected"
-      << " [ovelayOutput [alpha]]";
+    std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inputImageFile"
+              << " markerImageFile"
+              << " outputImageFile"
+              << " markWatershedLine"
+              << " fullyConnected"
+              << " [ovelayOutput [alpha]]";
     std::cerr << std::endl;
     return EXIT_FAILURE;
-    }
+  }
 
-  const unsigned int Dimension = 2;
+  constexpr unsigned int Dimension = 2;
 
-  typedef unsigned char PixelType;
+  using PixelType = unsigned char;
 
-  typedef itk::Image< PixelType, Dimension > ImageType;
+  using ImageType = itk::Image<PixelType, Dimension>;
 
-  typedef itk::ImageFileReader< ImageType > ReaderType;
+  using ReaderType = itk::ImageFileReader<ImageType>;
   ReaderType::Pointer reader = ReaderType::New();
-  reader->SetFileName( argv[1] );
+  reader->SetFileName(argv[1]);
 
   ReaderType::Pointer reader2 = ReaderType::New();
-  reader2->SetFileName( argv[2] );
+  reader2->SetFileName(argv[2]);
 
-  typedef itk::MorphologicalWatershedFromMarkersImageFilter< ImageType, ImageType >
-    FilterType;
+  using FilterType = itk::MorphologicalWatershedFromMarkersImageFilter<ImageType, ImageType>;
   FilterType::Pointer filter = FilterType::New();
 
-  EXERCISE_BASIC_OBJECT_METHODS( filter,
-    MorphologicalWatershedFromMarkersImageFilter,
-    ImageToImageFilter );
+  ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, MorphologicalWatershedFromMarkersImageFilter, ImageToImageFilter);
 
 
-  bool markWatershedLine = atoi( argv[4] );
-  TEST_SET_GET_BOOLEAN( filter, MarkWatershedLine, markWatershedLine );
+  bool markWatershedLine = std::stoi(argv[4]);
+  ITK_TEST_SET_GET_BOOLEAN(filter, MarkWatershedLine, markWatershedLine);
 
-  bool fullyConnected = atoi( argv[5] );
-  TEST_SET_GET_BOOLEAN( filter, FullyConnected, fullyConnected );
+  bool fullyConnected = std::stoi(argv[5]);
+  ITK_TEST_SET_GET_BOOLEAN(filter, FullyConnected, fullyConnected);
 
 
-  filter->SetInput( reader->GetOutput() );
+  filter->SetInput(reader->GetOutput());
 
   // Test the marker and input image size disagreement exception
   //
   // Create a marker image larger than the input image
 
-  TRY_EXPECT_NO_EXCEPTION( reader->Update() );
+  ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update());
 
-  ImageType::RegionType region = reader->GetOutput()->GetLargestPossibleRegion();
+  ImageType::RegionType           region = reader->GetOutput()->GetLargestPossibleRegion();
   ImageType::RegionType::SizeType size = region.GetSize();
-  for( unsigned int i = 0; i < size.GetSizeDimension(); ++i )
-    {
-    size[i] = size[i]*2;
-    }
+  for (unsigned int i = 0; i < size.GetSizeDimension(); ++i)
+  {
+    size[i] = size[i] * 2;
+  }
 
   ImageType::RegionType::IndexType index;
-  index.Fill( 0 );
+  index.Fill(0);
 
-  region.SetSize( size );
-  region.SetIndex( index );
+  region.SetSize(size);
+  region.SetIndex(index);
 
   FilterType::LabelImageType::Pointer largerMarkerImage = FilterType::LabelImageType::New();
-  largerMarkerImage->SetBufferedRegion( region );
-  largerMarkerImage->SetLargestPossibleRegion( region );
+  largerMarkerImage->SetBufferedRegion(region);
+  largerMarkerImage->SetLargestPossibleRegion(region);
   largerMarkerImage->Allocate();
 
-  filter->SetInput2( largerMarkerImage );
+  filter->SetInput2(largerMarkerImage);
 
-  TRY_EXPECT_EXCEPTION( filter->Update() );
+  ITK_TRY_EXPECT_EXCEPTION(filter->Update());
 
 
   FilterType::LabelImageType::Pointer markerImage = reader2->GetOutput();
-  filter->SetInput2( markerImage );
-  TEST_SET_GET_VALUE( markerImage, filter->GetMarkerImage() );
+  filter->SetInput2(markerImage);
+  ITK_TEST_SET_GET_VALUE(markerImage, filter->GetMarkerImage());
 
-  itk::SimpleFilterWatcher watcher( filter,
-    "MorphologicalWatershedFromMarkersImageFilter" );
+  itk::SimpleFilterWatcher watcher(filter, "MorphologicalWatershedFromMarkersImageFilter");
 
-  TRY_EXPECT_NO_EXCEPTION( filter->Update() );
+  ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update());
 
 
   // Write output image
-  typedef itk::ImageFileWriter< ImageType > WriterType;
+  using WriterType = itk::ImageFileWriter<ImageType>;
   WriterType::Pointer writer = WriterType::New();
-  writer->SetInput( filter->GetOutput() );
-  writer->SetFileName( argv[3] );
+  writer->SetInput(filter->GetOutput());
+  writer->SetFileName(argv[3]);
 
-  TRY_EXPECT_NO_EXCEPTION( writer->Update() );
+  ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update());
 
-  if( argc > 6 )
-    {
-    typedef itk::RGBPixel< PixelType >            RGBPixelType;
-    typedef itk::Image< RGBPixelType, Dimension > RGBImageType;
+  if (argc > 6)
+  {
+    using RGBPixelType = itk::RGBPixel<PixelType>;
+    using RGBImageType = itk::Image<RGBPixelType, Dimension>;
 
-    typedef itk::LabelOverlayImageFilter< ImageType, ImageType, RGBImageType>
-      OverlayType;
+    using OverlayType = itk::LabelOverlayImageFilter<ImageType, ImageType, RGBImageType>;
     OverlayType::Pointer overlay = OverlayType::New();
-    overlay->SetInput( reader->GetOutput() );
-    overlay->SetLabelImage( filter->GetOutput() );
+    overlay->SetInput(reader->GetOutput());
+    overlay->SetLabelImage(filter->GetOutput());
 
-    typedef itk::ImageFileWriter< RGBImageType > RGBWriterType;
+    using RGBWriterType = itk::ImageFileWriter<RGBImageType>;
     RGBWriterType::Pointer rgbwriter = RGBWriterType::New();
-    rgbwriter->SetInput( overlay->GetOutput() );
-    rgbwriter->SetFileName( argv[6] );
-
-    if( argc > 7 )
-      {
-      overlay->SetOpacity( atof( argv[7] ) );
-      }
+    rgbwriter->SetInput(overlay->GetOutput());
+    rgbwriter->SetFileName(argv[6]);
 
-    TRY_EXPECT_NO_EXCEPTION( rgbwriter->Update() );
+    if (argc > 7)
+    {
+      overlay->SetOpacity(std::stod(argv[7]));
     }
 
+    ITK_TRY_EXPECT_NO_EXCEPTION(rgbwriter->Update());
+  }
+
   std::cerr << "Test finished" << std::endl;
   return EXIT_SUCCESS;
 }
diff --git a/Modules/Segmentation/Watersheds/test/itkMorphologicalWatershedImageFilterTest.cxx b/Modules/Segmentation/Watersheds/test/itkMorphologicalWatershedImageFilterTest.cxx
index 6cc8e20665..cbe23086b2 100644
--- a/Modules/Segmentation/Watersheds/test/itkMorphologicalWatershedImageFilterTest.cxx
+++ b/Modules/Segmentation/Watersheds/test/itkMorphologicalWatershedImageFilterTest.cxx
@@ -25,106 +25,101 @@
 #include "itkTestingMacros.h"
 
 
-int itkMorphologicalWatershedImageFilterTest( int argc, char * argv[] )
+int
+itkMorphologicalWatershedImageFilterTest(int argc, char * argv[])
 {
-  if( argc < 6 )
-    {
+  if (argc < 6)
+  {
     std::cerr << "Missing parameters" << std::endl;
-    std::cerr << "Usage: " << argv[0]
-      << " inputImageFile"
-      << " outputImageFile"
-      << " markWatershedLine"
-      << " fullyConnected"
-      << " level"
-      << " [ovelayOutput [alpha]]";
+    std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inputImageFile"
+              << " outputImageFile"
+              << " markWatershedLine"
+              << " fullyConnected"
+              << " level"
+              << " [ovelayOutput [alpha]]";
     std::cerr << std::endl;
     return EXIT_FAILURE;
-    }
+  }
 
-  const unsigned int Dimension = 2;
+  constexpr unsigned int Dimension = 2;
 
-  typedef unsigned char PixelType;
+  using PixelType = unsigned char;
 
-  typedef itk::Image< PixelType, Dimension > ImageType;
+  using ImageType = itk::Image<PixelType, Dimension>;
 
-  typedef itk::ImageFileReader< ImageType > ReaderType;
+  using ReaderType = itk::ImageFileReader<ImageType>;
   ReaderType::Pointer reader = ReaderType::New();
-  reader->SetFileName( argv[1] );
+  reader->SetFileName(argv[1]);
 
-  typedef itk::MorphologicalWatershedImageFilter< ImageType, ImageType >
-    FilterType;
+  using FilterType = itk::MorphologicalWatershedImageFilter<ImageType, ImageType>;
   FilterType::Pointer filter = FilterType::New();
 
-  EXERCISE_BASIC_OBJECT_METHODS( filter, MorphologicalWatershedImageFilter,
-    ImageToImageFilter );
+  ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, MorphologicalWatershedImageFilter, ImageToImageFilter);
 
-  bool markWatershedLine = atoi( argv[3] );
-  TEST_SET_GET_BOOLEAN( filter, MarkWatershedLine, markWatershedLine );
+  bool markWatershedLine = std::stoi(argv[3]);
+  ITK_TEST_SET_GET_BOOLEAN(filter, MarkWatershedLine, markWatershedLine);
 
-  bool fullyConnected = atoi( argv[4] );
-  TEST_SET_GET_BOOLEAN( filter, FullyConnected, fullyConnected );
+  bool fullyConnected = std::stoi(argv[4]);
+  ITK_TEST_SET_GET_BOOLEAN(filter, FullyConnected, fullyConnected);
 
-  FilterType::InputImagePixelType level =
-    static_cast< FilterType::InputImagePixelType >( atof( argv[5] ) );
-  filter->SetLevel( level );
-  TEST_SET_GET_VALUE( level, filter->GetLevel() );
+  auto level = static_cast<FilterType::InputImagePixelType>(std::stod(argv[5]));
+  filter->SetLevel(level);
+  ITK_TEST_SET_GET_VALUE(level, filter->GetLevel());
 
 
-  filter->SetInput( reader->GetOutput() );
+  filter->SetInput(reader->GetOutput());
 
-  itk::SimpleFilterWatcher watcher( filter, "MorphologicalWatershedImageFilter" );
+  itk::SimpleFilterWatcher watcher(filter, "MorphologicalWatershedImageFilter");
 
-  TRY_EXPECT_NO_EXCEPTION( filter->Update() );
+  ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update());
 
 
   // Rescale the output to have a better display
-  typedef itk::MinimumMaximumImageCalculator< ImageType > MaxCalculatorType;
+  using MaxCalculatorType = itk::MinimumMaximumImageCalculator<ImageType>;
   MaxCalculatorType::Pointer minMaxCalculator = MaxCalculatorType::New();
-  minMaxCalculator->SetImage( filter->GetOutput() );
+  minMaxCalculator->SetImage(filter->GetOutput());
   minMaxCalculator->Compute();
 
-  typedef itk::IntensityWindowingImageFilter<
-    ImageType, ImageType > RescaleType;
+  using RescaleType = itk::IntensityWindowingImageFilter<ImageType, ImageType>;
   RescaleType::Pointer rescaler = RescaleType::New();
-  rescaler->SetInput( filter->GetOutput() );
-  rescaler->SetWindowMinimum( itk::NumericTraits< PixelType >::ZeroValue() );
-  rescaler->SetWindowMaximum( minMaxCalculator->GetMaximum() );
-  rescaler->SetOutputMaximum( itk::NumericTraits< PixelType >::max() );
-  rescaler->SetOutputMinimum( itk::NumericTraits< PixelType >::ZeroValue() );
+  rescaler->SetInput(filter->GetOutput());
+  rescaler->SetWindowMinimum(itk::NumericTraits<PixelType>::ZeroValue());
+  rescaler->SetWindowMaximum(minMaxCalculator->GetMaximum());
+  rescaler->SetOutputMaximum(itk::NumericTraits<PixelType>::max());
+  rescaler->SetOutputMinimum(itk::NumericTraits<PixelType>::ZeroValue());
 
   // Write output image
-  typedef itk::ImageFileWriter< ImageType > WriterType;
+  using WriterType = itk::ImageFileWriter<ImageType>;
   WriterType::Pointer writer = WriterType::New();
-  writer->SetInput( rescaler->GetOutput() );
-  writer->SetFileName( argv[2] );
+  writer->SetInput(rescaler->GetOutput());
+  writer->SetFileName(argv[2]);
 
-  TRY_EXPECT_NO_EXCEPTION( writer->Update() );
+  ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update());
 
-  if( argc > 6 )
-    {
-    typedef itk::RGBPixel< PixelType >            RGBPixelType;
-    typedef itk::Image< RGBPixelType, Dimension > RGBImageType;
+  if (argc > 6)
+  {
+    using RGBPixelType = itk::RGBPixel<PixelType>;
+    using RGBImageType = itk::Image<RGBPixelType, Dimension>;
 
-    typedef itk::LabelOverlayImageFilter<
-      ImageType, ImageType, RGBImageType> OverlayType;
+    using OverlayType = itk::LabelOverlayImageFilter<ImageType, ImageType, RGBImageType>;
 
     OverlayType::Pointer overlay = OverlayType::New();
-    overlay->SetInput( reader->GetOutput() );
-    overlay->SetLabelImage( filter->GetOutput() );
+    overlay->SetInput(reader->GetOutput());
+    overlay->SetLabelImage(filter->GetOutput());
 
-    typedef itk::ImageFileWriter< RGBImageType > RGBWriterType;
+    using RGBWriterType = itk::ImageFileWriter<RGBImageType>;
     RGBWriterType::Pointer rgbwriter = RGBWriterType::New();
-    rgbwriter->SetInput( overlay->GetOutput() );
-    rgbwriter->SetFileName( argv[6] );
+    rgbwriter->SetInput(overlay->GetOutput());
+    rgbwriter->SetFileName(argv[6]);
 
-    if( argc > 7 )
-      {
-      overlay->SetOpacity( atof( argv[7] ) );
-      }
-
-    TRY_EXPECT_NO_EXCEPTION( rgbwriter->Update() );
+    if (argc > 7)
+    {
+      overlay->SetOpacity(std::stod(argv[7]));
     }
 
+    ITK_TRY_EXPECT_NO_EXCEPTION(rgbwriter->Update());
+  }
+
   std::cerr << "Test finished" << std::endl;
   return EXIT_SUCCESS;
 }
diff --git a/Modules/Segmentation/Watersheds/test/itkTobogganImageFilterTest.cxx b/Modules/Segmentation/Watersheds/test/itkTobogganImageFilterTest.cxx
index feafaa48c0..b12803a56e 100644
--- a/Modules/Segmentation/Watersheds/test/itkTobogganImageFilterTest.cxx
+++ b/Modules/Segmentation/Watersheds/test/itkTobogganImageFilterTest.cxx
@@ -25,75 +25,70 @@
 #include "itkTestingMacros.h"
 
 
-int itkTobogganImageFilterTest( int argc, char* argv[] )
+int
+itkTobogganImageFilterTest(int argc, char * argv[])
 {
-  if( argc < 3 )
-    {
+  if (argc < 3)
+  {
     std::cerr << "Missing parameters" << std::endl;
-    std::cerr << "Usage: " << argv[0] << " InputImage OutputImage" << std::endl;
+    std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " InputImage OutputImage" << std::endl;
     return EXIT_FAILURE;
-    }
+  }
 
-  const unsigned int Dimension = 2;
+  constexpr unsigned int Dimension = 2;
 
-  typedef unsigned char                                 PixelType;
-  typedef float                                         FloatPixelType;
-  typedef itk::Image< PixelType, Dimension >            InputImageType;
-  typedef itk::Image< FloatPixelType, Dimension >       FloatImageType;
-  typedef itk::Image< PixelType, Dimension >            OutputImageType;
-  typedef itk::Image< itk::IdentifierType, Dimension >  LongImageType;
+  using PixelType = unsigned char;
+  using FloatPixelType = float;
+  using InputImageType = itk::Image<PixelType, Dimension>;
+  using FloatImageType = itk::Image<FloatPixelType, Dimension>;
+  using OutputImageType = itk::Image<PixelType, Dimension>;
+  using LongImageType = itk::Image<itk::IdentifierType, Dimension>;
 
 
   // Create a pipeline
-  typedef itk::CastImageFilter< InputImageType, FloatImageType >
-                                           InputCastFilterType;
-  typedef itk::TobogganImageFilter< FloatImageType >
-                                           FilterType;
-  typedef itk::CastImageFilter< LongImageType, OutputImageType >
-                                           OutputCastFilterType;
-  typedef itk::GradientMagnitudeRecursiveGaussianImageFilter< FloatImageType, FloatImageType >
-                                           GMGaussianType;
+  using InputCastFilterType = itk::CastImageFilter<InputImageType, FloatImageType>;
+  using FilterType = itk::TobogganImageFilter<FloatImageType>;
+  using OutputCastFilterType = itk::CastImageFilter<LongImageType, OutputImageType>;
+  using GMGaussianType = itk::GradientMagnitudeRecursiveGaussianImageFilter<FloatImageType, FloatImageType>;
 
 
-  itk::ImageFileReader< InputImageType >::Pointer reader =
-    itk::ImageFileReader< InputImageType >::New();
+  itk::ImageFileReader<InputImageType>::Pointer reader = itk::ImageFileReader<InputImageType>::New();
 
-  reader->SetFileName( argv[1] );
+  reader->SetFileName(argv[1]);
 
-  TRY_EXPECT_NO_EXCEPTION( reader->Update() );
+  ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update());
 
 
   FilterType::Pointer toboggan = FilterType::New();
 
-  EXERCISE_BASIC_OBJECT_METHODS( toboggan, TobogganImageFilter,
-    ImageToImageFilter );
+  ITK_EXERCISE_BASIC_OBJECT_METHODS(toboggan, TobogganImageFilter, ImageToImageFilter);
 
   InputCastFilterType::Pointer inputCaster = InputCastFilterType::New();
-  GMGaussianType::Pointer gmgaussian = GMGaussianType::New();
+  GMGaussianType::Pointer      gmgaussian = GMGaussianType::New();
 
-  inputCaster->SetInput( reader->GetOutput() );
-  gmgaussian->SetInput( inputCaster->GetOutput() );
-  gmgaussian->SetSigma( 15.0 );
+  inputCaster->SetInput(reader->GetOutput());
+  gmgaussian->SetInput(inputCaster->GetOutput());
+  gmgaussian->SetSigma(15.0);
 
-  toboggan->SetInput( gmgaussian->GetOutput() );
+  toboggan->SetInput(gmgaussian->GetOutput());
 
 
-  TRY_EXPECT_NO_EXCEPTION( toboggan->Update() );
+  ITK_TRY_EXPECT_NO_EXCEPTION(toboggan->Update());
 
 
   // Cast the output of the Toboggan filter
   OutputCastFilterType::Pointer outputCaster = OutputCastFilterType::New();
-  outputCaster->SetInput( toboggan->GetOutput() );
+  outputCaster->SetInput(toboggan->GetOutput());
 
-  TRY_EXPECT_NO_EXCEPTION( outputCaster->Update() );
+  ITK_TRY_EXPECT_NO_EXCEPTION(outputCaster->Update());
 
   // Write the output
-  typedef itk::ImageFileWriter< OutputImageType > WriterType;
+  using WriterType = itk::ImageFileWriter<OutputImageType>;
   WriterType::Pointer writer = WriterType::New();
-  writer->SetInput( outputCaster->GetOutput() );
-  writer->SetFileName( argv[2] );
+  writer->SetInput(outputCaster->GetOutput());
+  writer->SetFileName(argv[2]);
 
-  TRY_EXPECT_NO_EXCEPTION( writer->Update() );
+  ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update());
 
 
   std::cout << "Test finished." << std::endl;
diff --git a/Modules/Segmentation/Watersheds/test/itkWatershedImageFilterTest.cxx b/Modules/Segmentation/Watersheds/test/itkWatershedImageFilterTest.cxx
index 61dd61f44d..ca68631741 100644
--- a/Modules/Segmentation/Watersheds/test/itkWatershedImageFilterTest.cxx
+++ b/Modules/Segmentation/Watersheds/test/itkWatershedImageFilterTest.cxx
@@ -19,51 +19,51 @@
 #include "itkWatershedImageFilter.h"
 #include "itkWatershedEquivalenceRelabeler.h"
 #include "itkWatershedBoundaryResolver.h"
-#include "itkFilterWatcher.h"
+#include "itkSimpleFilterWatcher.h"
 #include "itkTestingMacros.h"
 
 
-int itkWatershedImageFilterTest( int, char* [] )
+int
+itkWatershedImageFilterTest(int, char *[])
 {
 
-  const unsigned int Dimension = 2;
+  constexpr unsigned int Dimension = 2;
 
-  typedef float                                         PixelType;
-  typedef itk::Image< PixelType, Dimension >            ImageType2D;
-  typedef itk::Image< itk::IdentifierType, Dimension >  LongImageType2D;
+  using PixelType = float;
+  using ImageType2D = itk::Image<PixelType, Dimension>;
+  using LongImageType2D = itk::Image<itk::IdentifierType, Dimension>;
 
 
-  itk::ImageRegion< Dimension > region;
+  itk::ImageRegion<Dimension> region;
 
-  itk::Size< Dimension > size;
+  itk::Size<Dimension> size;
   size[0] = 314;
   size[1] = 314;
 
-  itk::Index< Dimension > origin;
+  itk::Index<Dimension> origin;
   origin[0] = 0;
   origin[1] = 0;
 
-  region.SetSize( size );
-  region.SetIndex( origin );
+  region.SetSize(size);
+  region.SetIndex(origin);
 
   ImageType2D::Pointer image2D = ImageType2D::New();
-  image2D->SetLargestPossibleRegion( region);
-  image2D->SetBufferedRegion( region );
-  image2D->SetRequestedRegion( region );
+  image2D->SetLargestPossibleRegion(region);
+  image2D->SetBufferedRegion(region);
+  image2D->SetRequestedRegion(region);
   image2D->Allocate();
 
   LongImageType2D::Pointer longimage2D = LongImageType2D::New();
-  longimage2D->SetRegions( region );
-  longimage2D->Allocate( true ); // initialize buffer to zero
+  longimage2D->SetRegions(region);
+  longimage2D->Allocate(true); // initialize buffer to zero
 
-  itk::ImageRegionIterator< ImageType2D > it2D( image2D,
-    image2D->GetRequestedRegion() );
+  itk::ImageRegionIterator<ImageType2D> it2D(image2D, image2D->GetRequestedRegion());
 
-  for( float q = 0.00f; !it2D.IsAtEnd(); ++it2D )
-    {
-    it2D.Value() = std::sin( q );
+  for (float q = 0.00f; !it2D.IsAtEnd(); ++it2D)
+  {
+    it2D.Value() = std::sin(q);
     q += 0.10f;
-    }
+  }
 
   // Test various objects associated to itk::WatershedImageFilter
   //
@@ -71,87 +71,79 @@ int itkWatershedImageFilterTest( int, char* [] )
   // Test EquivalenceRelabeler
   itk::EquivalencyTable::Pointer table = itk::EquivalencyTable::New();
 
-  itk::watershed::EquivalenceRelabeler<
-    LongImageType2D::PixelType, Dimension >::Pointer eq =
-    itk::watershed::EquivalenceRelabeler<
-    LongImageType2D::PixelType, Dimension >::New();
-  eq->SetInputImage( longimage2D );
+  itk::watershed::EquivalenceRelabeler<LongImageType2D::PixelType, Dimension>::Pointer eq =
+    itk::watershed::EquivalenceRelabeler<LongImageType2D::PixelType, Dimension>::New();
+  eq->SetInputImage(longimage2D);
 
-  eq->SetEquivalencyTable( table );
-  TEST_SET_GET_VALUE( table, eq->GetEquivalencyTable() );
+  eq->SetEquivalencyTable(table);
+  ITK_TEST_SET_GET_VALUE(table, eq->GetEquivalencyTable());
 
 
-  TRY_EXPECT_NO_EXCEPTION( eq->Update() );
+  ITK_TRY_EXPECT_NO_EXCEPTION(eq->Update());
 
   // Test WatershedMiniPipelineProgressCommand
   // Forcing the execution of the const Execute method which is not normally called.
-  itk::WatershedMiniPipelineProgressCommand::Pointer wmppc =
-    itk::WatershedMiniPipelineProgressCommand::New();
+  itk::WatershedMiniPipelineProgressCommand::Pointer wmppc = itk::WatershedMiniPipelineProgressCommand::New();
 
-  EXERCISE_BASIC_OBJECT_METHODS( wmppc, WatershedMiniPipelineProgressCommand,
-    Command );
+  ITK_EXERCISE_BASIC_OBJECT_METHODS(wmppc, WatershedMiniPipelineProgressCommand, Command);
 
   double count = 2.0;
-  wmppc->SetCount( count );
-  TEST_SET_GET_VALUE( count, wmppc->GetCount() );
+  wmppc->SetCount(count);
+  ITK_TEST_SET_GET_VALUE(count, wmppc->GetCount());
 
   unsigned int numberOfFilters = 2;
-  wmppc->SetNumberOfFilters( numberOfFilters );
-  TEST_SET_GET_VALUE( numberOfFilters, wmppc->GetNumberOfFilters() );
+  wmppc->SetNumberOfFilters(numberOfFilters);
+  ITK_TEST_SET_GET_VALUE(numberOfFilters, wmppc->GetNumberOfFilters());
 
-  wmppc->SetFilter( eq );
-  TEST_SET_GET_VALUE( eq, wmppc->GetFilter() );
+  wmppc->SetFilter(eq);
+  ITK_TEST_SET_GET_VALUE(eq, wmppc->GetFilter());
 
-  const itk::ProcessObject *constp = eq.GetPointer();
-  wmppc->Execute( constp, itk::ProgressEvent() );
-  wmppc->Execute( eq.GetPointer(), itk::ProgressEvent() );
+  const itk::ProcessObject * constp = eq.GetPointer();
+  wmppc->Execute(constp, itk::ProgressEvent());
+  wmppc->Execute(eq, itk::ProgressEvent());
 
   // Test watershed::BoundaryResolver
-  itk::watershed::BoundaryResolver< PixelType, Dimension >::Pointer br =
-    itk::watershed::BoundaryResolver< PixelType, Dimension >::New();
-  if( br.IsNull() )
-    {
+  itk::watershed::BoundaryResolver<PixelType, Dimension>::Pointer br =
+    itk::watershed::BoundaryResolver<PixelType, Dimension>::New();
+  if (br.IsNull())
+  {
     std::cerr << "Test failed!" << std::endl;
     std::cout << "Null itk::watershed::BoundaryResolver." << std::endl;
     return EXIT_FAILURE;
-    }
-  itk::watershed::Boundary< PixelType, 1 >::Pointer boundaryA =
-    itk::watershed::Boundary< PixelType, 1 >::New();
-  if( boundaryA.IsNull() )
-    {
+  }
+  itk::watershed::Boundary<PixelType, 1>::Pointer boundaryA = itk::watershed::Boundary<PixelType, 1>::New();
+  if (boundaryA.IsNull())
+  {
     std::cerr << "Test failed!" << std::endl;
     std::cout << "Null itk::watershed::Boundary." << std::endl;
     return EXIT_FAILURE;
-    }
-  itk::watershed::Boundary< PixelType, 1 >::Pointer boundaryB =
-    itk::watershed::Boundary< PixelType, 1 >::New();
-  if( boundaryB.IsNull() )
-    {
+  }
+  itk::watershed::Boundary<PixelType, 1>::Pointer boundaryB = itk::watershed::Boundary<PixelType, 1>::New();
+  if (boundaryB.IsNull())
+  {
     std::cerr << "Test failed!" << std::endl;
     std::cout << "Null itk::watershed::Boundary." << std::endl;
     return EXIT_FAILURE;
-    }
+  }
 
 
-  itk::WatershedImageFilter< ImageType2D >::Pointer watershedFilter =
-    itk::WatershedImageFilter< ImageType2D >::New();
+  itk::WatershedImageFilter<ImageType2D>::Pointer watershedFilter = itk::WatershedImageFilter<ImageType2D>::New();
 
-  EXERCISE_BASIC_OBJECT_METHODS( watershedFilter, WatershedImageFilter,
-    ImageToImageFilter );
+  ITK_EXERCISE_BASIC_OBJECT_METHODS(watershedFilter, WatershedImageFilter, ImageToImageFilter);
 
-  FilterWatcher watchIt( watershedFilter, "WatershedImageFilter" );
+  itk::SimpleFilterWatcher watchIt(watershedFilter, "WatershedImageFilter");
 
   double threshold = .05;
-  watershedFilter->SetThreshold( threshold );
-  TEST_SET_GET_VALUE( threshold, watershedFilter->GetThreshold() );
+  watershedFilter->SetThreshold(threshold);
+  ITK_TEST_SET_GET_VALUE(threshold, watershedFilter->GetThreshold());
 
   double level = 1.0;
-  watershedFilter->SetLevel( level );
-  TEST_SET_GET_VALUE( level, watershedFilter->GetLevel() );
+  watershedFilter->SetLevel(level);
+  ITK_TEST_SET_GET_VALUE(level, watershedFilter->GetLevel());
 
-  watershedFilter->SetInput( image2D );
+  watershedFilter->SetInput(image2D);
 
-  TRY_EXPECT_NO_EXCEPTION( watershedFilter->Update() );
+  ITK_TRY_EXPECT_NO_EXCEPTION(watershedFilter->Update());
 
 
   std::cout << "Test finished." << std::endl;
diff --git a/Modules/Segmentation/Watersheds/wrapping/test/CMakeLists.txt b/Modules/Segmentation/Watersheds/wrapping/test/CMakeLists.txt
new file mode 100644
index 0000000000..5c7b9206d4
--- /dev/null
+++ b/Modules/Segmentation/Watersheds/wrapping/test/CMakeLists.txt
@@ -0,0 +1,14 @@
+set(test_input_dir ${itk-module_SOURCE_DIR}/test/Input)
+set(test_baseline_dir ${itk-module_SOURCE_DIR}/test/Baseline)
+
+list(FIND ITK_WRAP_IMAGE_DIMS 2 wrap_2_index)
+if(ITK_WRAP_float AND wrap_2_index GREATER -1)
+  itk_python_add_test(NAME PythonWatershedSegmentation1Test
+    TEST_DRIVER_ARGS
+      --compare ${ITK_TEST_OUTPUT_DIR}/PythonWatershedSegmentation1Test.png
+                DATA{${test_baseline_dir}/PythonWatershedSegmentation1Test.png}
+    COMMAND WatershedSegmentation1Test.py
+      DATA{${test_input_dir}/VisibleWomanEyeSlice.png}
+      ${ITK_TEST_OUTPUT_DIR}/PythonWatershedSegmentation1Test.png
+    )
+endif()
diff --git a/Modules/Segmentation/Watersheds/wrapping/test/WatershedSegmentation1Test.py b/Modules/Segmentation/Watersheds/wrapping/test/WatershedSegmentation1Test.py
new file mode 100644
index 0000000000..0b3d5d0305
--- /dev/null
+++ b/Modules/Segmentation/Watersheds/wrapping/test/WatershedSegmentation1Test.py
@@ -0,0 +1,47 @@
+#==========================================================================
+#
+#   Copyright Insight Software Consortium
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#          http://www.apache.org/licenses/LICENSE-2.0.txt
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+#==========================================================================*/
+
+import itk
+import sys
+itk.auto_progress(2)
+
+PixelType = itk.ctype('float')
+Dimension = 2
+ImageType = itk.Image[PixelType, Dimension]
+reader = itk.ImageFileReader[ImageType].New()
+reader.SetFileName(sys.argv[1])
+
+diffusion = itk.GradientAnisotropicDiffusionImageFilter.New(Input=reader.GetOutput())
+diffusion.SetTimeStep(0.0625)
+diffusion.SetConductanceParameter(9.0)
+diffusion.SetNumberOfIterations(5)
+
+gradient = itk.GradientMagnitudeImageFilter.New(Input=diffusion.GetOutput())
+
+watershed = itk.WatershedImageFilter.New(Input=gradient.GetOutput())
+watershed.SetThreshold(0.01)
+watershed.SetLevel(0.2)
+
+relabel = itk.RelabelComponentImageFilter.New(Input=watershed.GetOutput())
+
+cast = itk.CastImageFilter[relabel.GetOutput().__class__,
+  itk.Image[itk.ctype('unsigned char'), Dimension]].New(Input=relabel.GetOutput())
+
+writer = itk.ImageFileWriter.New(Input=cast.GetOutput())
+writer.SetFileName(sys.argv[2])
+writer.Update()
