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

  Program:   Insight Segmentation & Registration Toolkit
  Module:    itkBloxBoundaryPointImageToBloxBoundaryProfileImageFilter.h
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) 2002 Insight Consortium. All rights reserved.
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm 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 __itkBloxBoundaryPointImageToBloxBoundaryProfileImageFilter_h
#define __itkBloxBoundaryPointImageToBloxBoundaryProfileImageFilter_h

#include "itkBloxBoundaryPointImage.h"
#include "itkBloxBoundaryProfileImage.h"
#include "itkImageToImageFilter.h"
#include "itkSize.h"

namespace itk
{

/** \class BloxBoundaryPointImageToBloxBoundaryProfileImageFilter
 * \brief Converts a BloxImage of BloxBoundaryPoints to a BloxImage of BloxBoundaryProfiles
 *
 * Samples the boundary point image to produce
 * a BloxBoundaryProfileImage
 * 
 * References:
 * <NAME>, <NAME>: Gradient-Oriented Profiles 
 * for Boundary Parameterization and Their Application to Core Atoms 
 * Towards Shape Analysis. International Journal of Image and 
 * Graphics 1(4): 659-680 (2001) 
 *
 * <NAME> and <NAME>,M.D.,Ph.D.: Gradient-Oriented 
 * Profiles for Unsupervised Boundary Classification. Proceedings of 
 * the 29th Applied Imagery Pattern Recognition Workshop. October 2000: 
 * Washington, D.C.
 *
 * \ingroup ImageEnhancement
 */
template< typename TSourceImage >
class ITK_EXPORT BloxBoundaryPointImageToBloxBoundaryProfileImageFilter :
public ImageToImageFilter<TSourceImage,BloxBoundaryProfileImage<TSourceImage::ImageDimension> >
{
public:
  /** Standard class typedefs */
  typedef BloxBoundaryPointImageToBloxBoundaryProfileImageFilter  Self;
  typedef ImageToImageFilter<TSourceImage,BloxBoundaryProfileImage<TSourceImage::ImageDimension> >  Superclass;
  typedef SmartPointer<Self>   Pointer;
  typedef SmartPointer<const Self>  ConstPointer;

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

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

  /** Number of dimensions */
  enum {NDimensions = TSourceImage::ImageDimension};

  /** Typedef for boundary point image */
  typedef BloxBoundaryPointImage<NDimensions> BoundaryPointImageType;
  typedef typename BoundaryPointImageType::Pointer BoundaryPointImagePointer;
  typedef typename BoundaryPointImageType::RegionType BoundaryPointImageRegionType; 
  typedef typename BoundaryPointImageType::PixelType BoundaryPointImagePixelType; 
  typedef typename BoundaryPointImageType::ConstPointer BoundaryPointImageConstPointer;

  /** Typedef for blurred source image */
  typedef TSourceImage SourceImageType;
  typedef typename SourceImageType::Pointer SourceImagePointer;
  typedef typename SourceImageType::RegionType SourceImageRegionType; 
  typedef typename SourceImageType::PixelType SourceImagePixelType; 
  typedef typename SourceImageType::ConstPointer SourceImageConstPointer;

  /** Typedef for profile image */
  typedef BloxBoundaryProfileImage<NDimensions> OutputImageType;
  typedef typename OutputImageType::Pointer OutputImagePointer;
  typedef typename OutputImageType::RegionType OutputImageRegionType;
  typedef typename OutputImageType::PixelType OutputImagePixelType;

  /** Image index typedef */
  typedef typename BloxBoundaryProfileImage<NDimensions>::IndexType IndexType;

  /** Image pixel value typedef */
  typedef typename BloxBoundaryProfileImage<NDimensions>::PixelType PixelType;

  /** The type of vector used to convert between physical and blox space */
  typedef Point<double, NDimensions> TPositionType;

  /** Vector typedef */
  typedef typename TPositionType::VectorType TVectorType;

  /** Set the blurred original image */
  void SetInput1( const SourceImageType * image1 );

  /** Set the boundary point image */
  void SetInput2( const BoundaryPointImageType * image2 );

  /** Find maximum in accumulator */
  double FindAccumulatorMaximum();
  
  /** Find minimum in accumulator */
  double FindAccumulatorMinimum();

  /** Find boundary profiles from input images and store them */
  void FindBoundaryProfiles();

  /** Find boundary profiles given a specific boundary point */
  void FindBoundaryProfilesAtBoundaryPoint(BloxBoundaryPointItem<NDimensions>* pItem);
  
  /** Add weighted pixel value to appropriate bin number in splat accumulator and normalizer */
  bool AddSplatToAccumulatorAndNormalizer(int binNumber, double weight, double sourcePixelValue);

  /** Normalize the splat accumulator by the normalizer */
  void NormalizeSplatAccumulator();

  /** Fit the boundary profile to a cumulative Gaussian */
  int FitProfile();
  
  /** Parameters required to find boundary profiles */
  void Initialize(double setUniqueAxis, double setSymmetricAxes, unsigned int numberOfBins,
                  unsigned int splatMethod, unsigned int spaceDimension)
    {
    m_UniqueAxis = setUniqueAxis;
    m_SymmetricAxes = setSymmetricAxes;
    m_NumberOfBins = numberOfBins;
    m_SplatMethod = splatMethod;
    m_SpaceDimension = spaceDimension;

    m_Accumulator = new double[m_NumberOfBins];
    m_Normalizer = new double[m_NumberOfBins];
    }

protected:
  BloxBoundaryPointImageToBloxBoundaryProfileImageFilter();
  virtual ~BloxBoundaryPointImageToBloxBoundaryProfileImageFilter() {};
  void PrintSelf(std::ostream& os, Indent indent) const;

  /** Method for forming the BloxBoundaryProfileImage */
  void GenerateData();

private:
  BloxBoundaryProfileImageFilter(const Self&); //purposely not implemented
  void operator=(const Self&); //purposely not implemented

  typename BoundaryPointImagePointer m_BoundaryPointImage;
  const double* m_BPImageOrigin;
  const double* m_BPImageSpacing;
    
  typename TSourceImage::Pointer m_OriginalImage;
  const double* m_OriginalImageOrigin;
  const double* m_OriginalImageSpacing;
   
  /** Length of major axis of ellipsoid */
  double m_UniqueAxis;

  /** Lengths of minor axes of ellipsoid */
  double m_SymmetricAxes;

  /** Number of bins in splat accumulator and normalizer */
  unsigned int m_NumberOfBins;

  /** Type of method to splat. 0: Gaussian 1: Triangle  */
  unsigned int m_SplatMethod;

  /** Count of number of boundary profiles found */<commit_msg>ERR: fixed incorrect constructor statement<commit_after>/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit
  Module:    itkBloxBoundaryPointImageToBloxBoundaryProfileImageFilter.h
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) 2002 Insight Consortium. All rights reserved.
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm 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 __itkBloxBoundaryPointImageToBloxBoundaryProfileImageFilter_h
#define __itkBloxBoundaryPointImageToBloxBoundaryProfileImageFilter_h

#include "itkBloxBoundaryPointImage.h"
#include "itkBloxBoundaryProfileImage.h"
#include "itkImageToImageFilter.h"
#include "itkSize.h"

namespace itk
{

/** \class BloxBoundaryPointImageToBloxBoundaryProfileImageFilter
 * \brief Converts a BloxImage of BloxBoundaryPoints to a BloxImage of BloxBoundaryProfiles
 *
 * Samples the boundary point image to produce
 * a BloxBoundaryProfileImage
 * 
 * References:
 * <NAME>, <NAME>: Gradient-Oriented Profiles 
 * for Boundary Parameterization and Their Application to Core Atoms 
 * Towards Shape Analysis. International Journal of Image and 
 * Graphics 1(4): 659-680 (2001) 
 *
 * <NAME> and <NAME>,M.D.,Ph.D.: Gradient-Oriented 
 * Profiles for Unsupervised Boundary Classification. Proceedings of 
 * the 29th Applied Imagery Pattern Recognition Workshop. October 2000: 
 * Washington, D.C.
 *
 * \ingroup ImageEnhancement
 */
template< typename TSourceImage >
class ITK_EXPORT BloxBoundaryPointImageToBloxBoundaryProfileImageFilter :
public ImageToImageFilter<TSourceImage,BloxBoundaryProfileImage<TSourceImage::ImageDimension> >
{
public:
  /** Standard class typedefs */
  typedef BloxBoundaryPointImageToBloxBoundaryProfileImageFilter  Self;
  typedef ImageToImageFilter<TSourceImage,BloxBoundaryProfileImage<TSourceImage::ImageDimension> >  Superclass;
  typedef SmartPointer<Self>   Pointer;
  typedef SmartPointer<const Self>  ConstPointer;

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

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

  /** Number of dimensions */
  enum {NDimensions = TSourceImage::ImageDimension};

  /** Typedef for boundary point image */
  typedef BloxBoundaryPointImage<NDimensions> BoundaryPointImageType;
  typedef typename BoundaryPointImageType::Pointer BoundaryPointImagePointer;
  typedef typename BoundaryPointImageType::RegionType BoundaryPointImageRegionType; 
  typedef typename BoundaryPointImageType::PixelType BoundaryPointImagePixelType; 
  typedef typename BoundaryPointImageType::ConstPointer BoundaryPointImageConstPointer;

  /** Typedef for blurred source image */
  typedef TSourceImage SourceImageType;
  typedef typename SourceImageType::Pointer SourceImagePointer;
  typedef typename SourceImageType::RegionType SourceImageRegionType; 
  typedef typename SourceImageType::PixelType SourceImagePixelType; 
  typedef typename SourceImageType::ConstPointer SourceImageConstPointer;

  /** Typedef for profile image */
  typedef BloxBoundaryProfileImage<NDimensions> OutputImageType;
  typedef typename OutputImageType::Pointer OutputImagePointer;
  typedef typename OutputImageType::RegionType OutputImageRegionType;
  typedef typename OutputImageType::PixelType OutputImagePixelType;

  /** Image index typedef */
  typedef typename BloxBoundaryProfileImage<NDimensions>::IndexType IndexType;

  /** Image pixel value typedef */
  typedef typename BloxBoundaryProfileImage<NDimensions>::PixelType PixelType;

  /** The type of vector used to convert between physical and blox space */
  typedef Point<double, NDimensions> TPositionType;

  /** Vector typedef */
  typedef typename TPositionType::VectorType TVectorType;

  /** Set the blurred original image */
  void SetInput1( const SourceImageType * image1 );

  /** Set the boundary point image */
  void SetInput2( const BoundaryPointImageType * image2 );

  /** Find maximum in accumulator */
  double FindAccumulatorMaximum();
  
  /** Find minimum in accumulator */
  double FindAccumulatorMinimum();

  /** Find boundary profiles from input images and store them */
  void FindBoundaryProfiles();

  /** Find boundary profiles given a specific boundary point */
  void FindBoundaryProfilesAtBoundaryPoint(BloxBoundaryPointItem<NDimensions>* pItem);
  
  /** Add weighted pixel value to appropriate bin number in splat accumulator and normalizer */
  bool AddSplatToAccumulatorAndNormalizer(int binNumber, double weight, double sourcePixelValue);

  /** Normalize the splat accumulator by the normalizer */
  void NormalizeSplatAccumulator();

  /** Fit the boundary profile to a cumulative Gaussian */
  int FitProfile();
  
  /** Parameters required to find boundary profiles */
  void Initialize(double setUniqueAxis, double setSymmetricAxes, unsigned int numberOfBins,
                  unsigned int splatMethod, unsigned int spaceDimension)
    {
    m_UniqueAxis = setUniqueAxis;
    m_SymmetricAxes = setSymmetricAxes;
    m_NumberOfBins = numberOfBins;
    m_SplatMethod = splatMethod;
    m_SpaceDimension = spaceDimension;

    m_Accumulator = new double[m_NumberOfBins];
    m_Normalizer = new double[m_NumberOfBins];
    }

protected:
  BloxBoundaryPointImageToBloxBoundaryProfileImageFilter();
  virtual ~BloxBoundaryPointImageToBloxBoundaryProfileImageFilter() {};
  void PrintSelf(std::ostream& os, Indent indent) const;

  /** Method for forming the BloxBoundaryProfileImage */
  void GenerateData();

private:
  BloxBoundaryPointImageToBloxBoundaryProfileImageFilter(const Self&); //purposely not implemented
  void operator=(const Self&); //purposely not implemented

  typename BoundaryPointImagePointer m_BoundaryPointImage;
  const double* m_BPImageOrigin;
  const double* m_BPImageSpacing;
    
  typename TSourceImage::Pointer m_OriginalImage;
  const double* m_OriginalImageOrigin;
  const double* m_OriginalImageSpacing;
   
  /** Length of major axis of ellipsoid */
  double m_UniqueAxis;

  /** Lengths of minor axes of ellipsoid */
  double m_SymmetricAxes;

  /** Number of bins in splat accumulator and normalizer */
  unsigned int m_NumberOfBins;

  /** Type of method to splat. 0: Gaussian 1: Triangle  */
  unsigned int m_SplatMethod;

  /** Count of number of boundary profiles found */
{'fraction_non_alphanumeric': 0.09094985427098125, 'fraction_numerical': 0.004185038487407518, 'mean_word_length': 5.363290537327627, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4826366', 'n_tokens_mistral': 3803, 'n_tokens_neox': 3532, 'n_words': 1034}