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

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

     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 __itkVectorConnectedComponentImageFilter_h
#define __itkVectorConnectedComponentImageFilter_h

#include "vnl/vnl_math.h"
#include "itkNumericTraits.h"
#include "itkConnectedComponentFunctorImageFilter.h"

namespace itk
{
  
/** \class SimilarVectorsFunctor
 *
 *  \brief A connected components filter that labels the
 *         objects in a vector image.  Two vectors are pointing
 *         similar directions if one minus their dot product is less than a
 *         threshold.  Vectors that are 180 degrees out of phase
 *         are similar.  Assumes that vectors are normalized.
 */

namespace Functor {  
  
template<class TInput>
class SimilarVectorsFunctor
{
public:
  SimilarVectorsFunctor()
    {threshold = itk::NumericTraits<typename TInput::ValueType>::Zero;};

  ~SimilarVectorsFunctor() {};

  void SetDistanceThreshold(const typename TInput::ValueType &thresh)
    {threshold = thresh;};
  typename TInput::ValueType GetDistanceThreshold() {return (threshold);};
  
  bool operator()(const TInput &a, const TInput &b)
    {
    typename TInput::ValueType dotProduct = vnl_math_abs(a * b);
    return (1.0 - dotProduct <= threshold);
    };

protected:
  typename TInput::ValueType threshold;
                            
};

} // end namespace Functor 

template <class TInputImage, class TOutputImage, class TMaskImage=TInputImage>
class ITK_EXPORT VectorConnectedComponentImageFilter :
    public ConnectedComponentFunctorImageFilter<TInputImage,TOutputImage,
             Functor::SimilarVectorsFunctor<typename TInputImage::ValueType>,
                                           TMaskImage> 
{
public:
  /** Standard class typedefs. */
  typedef VectorConnectedComponentImageFilter Self;<commit_msg>COMP: typename issues with VS6.<commit_after>/*=========================================================================

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

     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 __itkVectorConnectedComponentImageFilter_h
#define __itkVectorConnectedComponentImageFilter_h

#include "vnl/vnl_math.h"
#include "itkNumericTraits.h"
#include "itkConnectedComponentFunctorImageFilter.h"

namespace itk
{
  
/** \class SimilarVectorsFunctor
 *
 *  \brief A connected components filter that labels the
 *         objects in a vector image.  Two vectors are pointing
 *         similar directions if one minus their dot product is less than a
 *         threshold.  Vectors that are 180 degrees out of phase
 *         are similar.  Assumes that vectors are normalized.
 */

namespace Functor {  
  
template<class TInput>
class SimilarVectorsFunctor
{
public:
  SimilarVectorsFunctor()
    {threshold = itk::NumericTraits<ITK_TYPENAME TInput::ValueType>::Zero;};

  ~SimilarVectorsFunctor() {};

  void SetDistanceThreshold(const typename TInput::ValueType &thresh)
    {threshold = thresh;};
  typename TInput::ValueType GetDistanceThreshold() {return (threshold);};
  
  bool operator()(const TInput &a, const TInput &b)
    {
    typename TInput::ValueType dotProduct = vnl_math_abs(a * b);
    return (1.0 - dotProduct <= threshold);
    };

protected:
  typename TInput::ValueType threshold;
                            
};

} // end namespace Functor 

template <class TInputImage, class TOutputImage, class TMaskImage=TInputImage>
class ITK_EXPORT VectorConnectedComponentImageFilter :
    public ConnectedComponentFunctorImageFilter<TInputImage,TOutputImage,
             Functor::SimilarVectorsFunctor<typename TInputImage::ValueType>,
                                           TMaskImage> 
{
public:
  /** Standard class typedefs. */
  typedef VectorConnectedComponentImageFilter Self;
{'fraction_non_alphanumeric': 0.1343218491059747, 'fraction_numerical': 0.002398604448320977, 'mean_word_length': 3.9642857142857144, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7657437', 'n_tokens_mistral': 1237, 'n_tokens_neox': 1177, 'n_words': 343}