<commit_before>/*=========================================================================

  Program:   ORFEO Toolbox
  Language:  C++
  Date:      $Date$
  Version:   $Revision$


  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
  See OTBCopyright.txt for details.


     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#ifndef __otbConvolutionImageFilter_h
#define __otbConvolutionImageFilter_h

#include "itkImageToImageFilter.h"
#include "itkImage.h"
#include "itkNumericTraits.h"
#include "itkArray.h"
#include "itkZeroFluxNeumannBoundaryCondition.h"

namespace otb
{
/** \class ConvolutionImageFilter
 * \brief Applies a convolution filter to a mono channel image
 *
 * Computes an image which is the convolution of the input image
 * with a filter.
 *
 * The radius of the input filter is provided by the \code SetInput() \endcode
 * method and the filters coefficients are given by an itk::Array passed to the
 * \code SetFilter() \endcode method.
 *
 * By default, the input filter is not normalized but it can be using the
 * NormalizeFilterOn() method.
 *
 * This filter allows the user to choose the boundary condtions in the template parameters.
 Default boundary conditions are zero flux Neumann boundary conditions.
 *
 * An optimized version of this filter using FFTW is available in the Orfeo ToolBox and
 * will significantly improves performances especially for large kernels
 * (see OverlapSaveConvolutionImageFilter).
 *
 * \sa Image
 * \sa Neighborhood
 * \sa NeighborhoodOperator
 * \sa NeighborhoodIterator
 * \sa ImageBoundaryCondition
 * \sa ZeroFluxNeumannBoundaryCondition
 * \sa OverlapSaveConvolutionImageFilter
 *
 * \ingroup IntensityImageFilters
 * \ingroup Streamed
 * \ingroup MultiThreaded
 */
template <class TInputImage, class TOutputImage, class TBoundaryCondition = itk::ZeroFluxNeumannBoundaryCondition<TInputImage> >
class ITK_EXPORT ConvolutionImageFilter :
      public itk::ImageToImageFilter< TInputImage, TOutputImage >
{
public:
  /** Extract dimension from input and output image. */
  itkStaticConstMacro(InputImageDimension, unsigned int,
                      TInputImage::ImageDimension);
  itkStaticConstMacro(OutputImageDimension, unsigned int,
                      TOutputImage::ImageDimension);

  /** Convenient typedefs for simplifying declarations. */
  typedef TInputImage InputImageType;
  typedef TOutputImage OutputImageType;

  /** Standard class typedefs. */
  typedef ConvolutionImageFilter Self;
  typedef itk::ImageToImageFilter< InputImageType, OutputImageType> Superclass;
  typedef itk::SmartPointer<Self> Pointer;
  typedef itk::SmartPointer<const Self>  ConstPointer;

  /** Method for creation through the object factory. */
  itkNewMacro(Self);

  /** Run-time type information (and related methods). */
  itkTypeMacro(ConvolutionImageFilter, ImageToImageFilter);

  /** Image typedef support. */
  typedef typename InputImageType::PixelType InputPixelType;
  typedef typename OutputImageType::PixelType OutputPixelType;
  typedef typename itk::NumericTraits<InputPixelType>::RealType InputRealType;
  typedef typename InputImageType::RegionType InputImageRegionType;
  typedef typename OutputImageType::RegionType OutputImageRegionType;
  typedef typename InputImageType::SizeType InputSizeType;
  typedef typename itk::Array<InputRealType> ArrayType;
  typedef TBoundaryCondition BoundaryConditionType;

  /** Set the radius of the neighborhood of the filter */
  virtual void SetRadius (const InputSizeType rad)
  {
    itkDebugMacro("setting radius to " << rad);
    if (this->m_Radius != rad)
    {
      this->m_Radius = rad;
      unsigned int arraySize=1;
      for (unsigned int i=0; i<m_Radius.GetSizeDimension(); ++i)
      {
        arraySize *= 2*this->m_Radius[i]+1;
      }
      this->m_Filter.SetSize(arraySize);
      this->m_Filter.Fill(1);
      this->Modified();
    }
  }

  /** Get the radius of the neighborhood of the filter*/
  itkGetConstReferenceMacro(Radius, InputSizeType);

  /** Set the input filter */
  void SetFilter( ArrayType filter )
  {
    if (filter.Size()!= m_Filter.Size())
    {
      itkExceptionMacro("Error in SetFilter, invalid filter size:"<< filter.Size()<<" instead of 2*(m_Radius[0]+1)*(2*m_Radius[1]+1): "<<m_Filter.Size());
    }
    else
    {
      m_Filter = filter;
    }
    this->Modified();
  }
  itkGetConstReferenceMacro(Filter, ArrayType);


  /**
   * Set/Get methods for the normalization of the filter
  */<commit_msg>STYLE : correct error msg<commit_after>/*=========================================================================

  Program:   ORFEO Toolbox
  Language:  C++
  Date:      $Date$
  Version:   $Revision$


  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
  See OTBCopyright.txt for details.


     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#ifndef __otbConvolutionImageFilter_h
#define __otbConvolutionImageFilter_h

#include "itkImageToImageFilter.h"
#include "itkImage.h"
#include "itkNumericTraits.h"
#include "itkArray.h"
#include "itkZeroFluxNeumannBoundaryCondition.h"

namespace otb
{
/** \class ConvolutionImageFilter
 * \brief Applies a convolution filter to a mono channel image
 *
 * Computes an image which is the convolution of the input image
 * with a filter.
 *
 * The radius of the input filter is provided by the \code SetInput() \endcode
 * method and the filters coefficients are given by an itk::Array passed to the
 * \code SetFilter() \endcode method.
 *
 * By default, the input filter is not normalized but it can be using the
 * NormalizeFilterOn() method.
 *
 * This filter allows the user to choose the boundary condtions in the template parameters.
 Default boundary conditions are zero flux Neumann boundary conditions.
 *
 * An optimized version of this filter using FFTW is available in the Orfeo ToolBox and
 * will significantly improves performances especially for large kernels
 * (see OverlapSaveConvolutionImageFilter).
 *
 * \sa Image
 * \sa Neighborhood
 * \sa NeighborhoodOperator
 * \sa NeighborhoodIterator
 * \sa ImageBoundaryCondition
 * \sa ZeroFluxNeumannBoundaryCondition
 * \sa OverlapSaveConvolutionImageFilter
 *
 * \ingroup IntensityImageFilters
 * \ingroup Streamed
 * \ingroup MultiThreaded
 */
template <class TInputImage, class TOutputImage, class TBoundaryCondition = itk::ZeroFluxNeumannBoundaryCondition<TInputImage> >
class ITK_EXPORT ConvolutionImageFilter :
      public itk::ImageToImageFilter< TInputImage, TOutputImage >
{
public:
  /** Extract dimension from input and output image. */
  itkStaticConstMacro(InputImageDimension, unsigned int,
                      TInputImage::ImageDimension);
  itkStaticConstMacro(OutputImageDimension, unsigned int,
                      TOutputImage::ImageDimension);

  /** Convenient typedefs for simplifying declarations. */
  typedef TInputImage InputImageType;
  typedef TOutputImage OutputImageType;

  /** Standard class typedefs. */
  typedef ConvolutionImageFilter Self;
  typedef itk::ImageToImageFilter< InputImageType, OutputImageType> Superclass;
  typedef itk::SmartPointer<Self> Pointer;
  typedef itk::SmartPointer<const Self>  ConstPointer;

  /** Method for creation through the object factory. */
  itkNewMacro(Self);

  /** Run-time type information (and related methods). */
  itkTypeMacro(ConvolutionImageFilter, ImageToImageFilter);

  /** Image typedef support. */
  typedef typename InputImageType::PixelType InputPixelType;
  typedef typename OutputImageType::PixelType OutputPixelType;
  typedef typename itk::NumericTraits<InputPixelType>::RealType InputRealType;
  typedef typename InputImageType::RegionType InputImageRegionType;
  typedef typename OutputImageType::RegionType OutputImageRegionType;
  typedef typename InputImageType::SizeType InputSizeType;
  typedef typename itk::Array<InputRealType> ArrayType;
  typedef TBoundaryCondition BoundaryConditionType;

  /** Set the radius of the neighborhood of the filter */
  virtual void SetRadius (const InputSizeType rad)
  {
    itkDebugMacro("setting radius to " << rad);
    if (this->m_Radius != rad)
    {
      this->m_Radius = rad;
      unsigned int arraySize=1;
      for (unsigned int i=0; i<m_Radius.GetSizeDimension(); ++i)
      {
        arraySize *= 2*this->m_Radius[i]+1;
      }
      this->m_Filter.SetSize(arraySize);
      this->m_Filter.Fill(1);
      this->Modified();
    }
  }

  /** Get the radius of the neighborhood of the filter*/
  itkGetConstReferenceMacro(Radius, InputSizeType);

  /** Set the input filter */
  void SetFilter( ArrayType filter )
  {
    if (filter.Size()!= m_Filter.Size())
    {
      itkExceptionMacro("Error in SetFilter, invalid filter size:"<< filter.Size()<<" instead of (2*m_Radius[0]+1)*(2*m_Radius[1]+1): "<<m_Filter.Size());
    }
    else
    {
      m_Filter = filter;
    }
    this->Modified();
  }
  itkGetConstReferenceMacro(Filter, ArrayType);


  /**
   * Set/Get methods for the normalization of the filter
  */
{'fraction_non_alphanumeric': 0.11453045685279188, 'fraction_numerical': 0.002326565143824027, 'mean_word_length': 4.333897349125776, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1360248', 'n_tokens_mistral': 2665, 'n_tokens_neox': 2558, 'n_words': 807}