/**============================================================================
 *
 * \file   distance_correction_filter.hpp
 * \brief  Declarations for the DistanceCorrectionFilter class.
 * In case of streeaming into pieces an image, the euclidean distance
 * transform computed by the maurerDistanceMapFilter is not
 * accurate (especially at the edges of each piece).
 *
 * This filter compute the correct distance transform
 * based on the previous inaccurate distance transform
 * by computing it on a larger but (hopefully) still smaller
 * region than the hole image.
 *
 *
 * \author Leblanc Christophe.
 * \date   07/02/2013
 * \email cleblancad@gmail.com
 *
 * Code inspired from:
 * 'Getting Started with ITK + VTK'
 * L. Ibanez, W. Schroeder, Insight Software Consortium.
 *
 * and (indirectly) from:
 *
 * "Parallel Banding Algorithm to compute Exact Distance Transform
 * with the GPU". Thanh-Tung Cao et al.
 * School of Computing, National University of Singapore.
 *
 *
 *===========================================================================*/

#ifndef TOMOPROCESS_FILTER_DISTANCE_CORRECTION_FILTER_HPP
#define TOMOPROCESS_FILTER_DISTANCE_CORRECTION_FILTER_HPP

#include "filter.hpp"
#include "detail/maurer_streaming_correction.hpp"

TOMOPROCESS_OPEN_GLOBAL_NAMESPACE
TOMOPROCESS_OPEN_FILTER_NAMESPACE

/** \class DistanceCorrectionFilter
 *  \brief Class to correct the Maurer distance map algorithm 
 *   in case of image streaming.
 *
 *  In case of streeaming into pieces an image, the euclidean distance
 *  transform computed by the maurerDistanceMapFilter is not
 *  accurate (especially at the edges of each piece).
 *
 *  This filter compute the correct distance transform
 *  based on the previous inaccurate distance transform
 *  by computing it on a larger but (hopefully) still smaller
 *  region than the hole image.
 */
template<class ImageT>
class DistanceCorrectionFilter
  : public Filter<
      itk::MaurerStreamingCorrection<
        typename ImageT::InputImageType,
	typename ImageT::OutputImageType>,
      ImageT>
{
public:
  /// \brief This type.
  typedef DistanceCorrectionFilter	Self;
  
  /// \brief Parent class.
  typedef Filter<
    itk::MaurerStreamingCorrection<
      typename ImageT::InputImageType,
      typename ImageT::OutputImageType>,
    ImageT> SuperClass;
  
  /// \brief Image type.
  typedef ImageT 			ImageType;
  
  /// \brief Set the parameter.
  /// \param[in] useImageSpacing flag for using the image spacing or not.
  virtual void SetParameters(const bool useImageSpacing)
  {
    this->m_Filter->SetUseImageSpacing(useImageSpacing);
  }
};

TOMOPROCESS_CLOSE_FILTER_NAMESPACE
TOMOPROCESS_CLOSE_GLOBAL_NAMESPACE

#endif // TOMOPROCESS_FILTER_DISTANCE_CORRECTION_FILTER_HPP