/**============================================================================
 *
 * \file   invert_filter.hpp
 * \brief  Declarations for the InvertFilter class.
 * to a maximum value. The maximum value can be set with 
 * SetMaximum and defaults the maximum of input pixel type. 
 * This filter can be used to invert, for example, a binary image, 
 * a distance map, etc.
 *
 *
 * \author Leblanc Christophe.
 * \date   19/12/2012
 * \email cleblancad@gmail.com
 *
 * Code inspired from:
 * 'Getting Started with ITK + VTK'
 * L. Ibanez, W. Schroeder, Insight Software Consortium.
 *
 *
 *===========================================================================*/

#ifndef TOMOPROCESS_FILTER_INVERSE_FILTER_HPP
#define TOMOPROCESS_FILTER_INVERSE_FILTER_HPP

#include "filter.hpp"
#include "itkInvertIntensityImageFilter.h"
#include "itkNumericTraits.h"

TOMOPROCESS_OPEN_GLOBAL_NAMESPACE
TOMOPROCESS_OPEN_FILTER_NAMESPACE

/** \class InvertFilter
  * \brief Applies an image inversion on the pixels' values.
  */
template<class ImageT>
class InvertFilter
  : public Filter<
      itk::InvertIntensityImageFilter<
        typename ImageT::InputImageType,
	typename ImageT::OutputImageType>,
      ImageT>
{
public:
  /// \brief This type.
  typedef InvertFilter Self;
  
  /// \brief Parent class.
  typedef Filter<
    itk::InvertIntensityImageFilter<
      typename ImageT::InputImageType,
      typename ImageT::OutputImageType>,
    ImageT> SuperClass;
  
  /// \brief Image type.
  typedef ImageT 	ImageType;
  
  /// \brief Pixel type.
  typedef typename ImageType::InputImageType::PixelType PixelType;
  
  /// \brief Sets the parameters.
  /// \param[in] maximum maximum value to substract pixels with.
  virtual void SetParameters(PixelType maximum = itk::NumericTraits<PixelType>::max())
  {
    this->m_Filter->SetMaximum(maximum);
    
    // sets the filter to be run in place.
    this->m_Filter->InPlaceOn();
  }
};

TOMOPROCESS_CLOSE_FILTER_NAMESPACE
TOMOPROCESS_CLOSE_GLOBAL_NAMESPACE

#endif // TOMOPROCESS_FILTER_INVERSE_FILTER_HPP