/**============================================================================
 *
 * \file   auto_binary_threshold_filter.hpp
 * \brief  Declarations for the AutoBinaryThresholdFilter class.
 *
 * \author Leblanc Christophe.
 * \date   22/01/2016
 * \email cleblancad@gmail.com
 *
 * Code inspired from:
 * 'Getting Started with ITK + VTK'
 * L. Ibanez, W. Schroeder, Insight Software Consortium.
 *
 *
 *===========================================================================*/

#ifndef TOMOPROCESS_FILTER_AUTO_BINARY_THRESHOLD_FILTER_HPP
#define TOMOPROCESS_FILTER_AUTO_BINARY_THRESHOLD_FILTER_HPP

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

TOMOPROCESS_OPEN_GLOBAL_NAMESPACE
TOMOPROCESS_OPEN_FILTER_NAMESPACE

/** \class AutoBinaryThresholdFilter
 * \brief Applies an automatic binary threhsold on a grayscale image.
 */
template<class ImageT>
class AutoBinaryThresholdFilter
  : public Filter<
      itk::AutoBinaryThresholdImageFilter<
        typename ImageT::InputImageType,
	typename ImageT::OutputImageType>,
      ImageT>
{
public:
  /// \brief This type.
  typedef AutoBinaryThresholdFilter Self;
  
  /// \brief Parent class.
  typedef Filter<
    itk::AutoBinaryThresholdImageFilter<
      typename ImageT::InputImageType,
      typename ImageT::OutputImageType>,
    ImageT> SuperClass;
  
  /// \brief Image type.
  typedef ImageT 	ImageType;
  
  /// \brief Input pixel type.
  typedef typename ImageType::InputImageType::PixelType  InputPixelType;
  
  /// \brief Output pixel type.
  typedef typename ImageType::OutputImageType::PixelType OutputPixelType;
  
  /// \brief Index pixel type.
  typedef typename SuperClass::ITKFilterType::VectorIndexType VectorIndexType;
  
  /// \brief Sets the parameters.
  /// \param[in] insideValue value for the foreground.
  /// \param[in] outsideValue value for the background.
  /// \param[in] numberOfHistogramBins number of histogram bins.
  /// \param[in] histogramBinMinimum minimum histogram bin value.
  /// \param[in] histogramBinMaximum maximum histogram bin value.
  virtual void SetParameters(OutputPixelType insideValue, OutputPixelType outsideValue,
			     unsigned int numberOfHistogramBins = 256,
			     InputPixelType histogramBinMinimum = 0,
			     InputPixelType histogramBinMaximum = 255)
  {
    this->m_Filter->SetInsideValue(insideValue);
    this->m_Filter->SetOutsideValue(outsideValue);
    this->m_Filter->SetNumberOfHistogramBins(numberOfHistogramBins);
    this->m_Filter->SetHistogramBinMinimum(histogramBinMinimum);
    this->m_Filter->SetHistogramBinMaximum(histogramBinMaximum);
  }
};

TOMOPROCESS_CLOSE_FILTER_NAMESPACE
TOMOPROCESS_CLOSE_GLOBAL_NAMESPACE

#endif // TOMOPROCESS_FILTER_AUTO_BINARY_THRESHOLD_FILTER_HPP