This file is indexed.

/usr/include/ITK-4.5/itkManifoldParzenWindowsPointSetFunction.hxx is in libinsighttoolkit4-dev 4.5.0-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
/*=========================================================================
 *
 *  Copyright Insight Software Consortium
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0.txt
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 *=========================================================================*/
#ifndef __itkManifoldParzenWindowsPointSetFunction_hxx
#define __itkManifoldParzenWindowsPointSetFunction_hxx

#include "itkManifoldParzenWindowsPointSetFunction.h"

#include "vnl/vnl_math.h"

namespace itk
{

template <typename TPointSet, typename TOutput, typename TCoordRep>
ManifoldParzenWindowsPointSetFunction<TPointSet, TOutput, TCoordRep>
::ManifoldParzenWindowsPointSetFunction() :
  m_PointsLocator( NULL ),
  m_CovarianceKNeighborhood( 5 ),
  m_EvaluationKNeighborhood( 50 ),
  m_RegularizationSigma( 1.0 ),
  m_KernelSigma( 1.0 ),
  m_Normalize( true ),
  m_UseAnisotropicCovariances( true )
{
}

template <typename TPointSet, typename TOutput, typename TCoordRep>
ManifoldParzenWindowsPointSetFunction<TPointSet, TOutput, TCoordRep>
::~ManifoldParzenWindowsPointSetFunction()
{
}

template <typename TPointSet, typename TOutput, typename TCoordRep>
void
ManifoldParzenWindowsPointSetFunction<TPointSet, TOutput, TCoordRep>
::SetInputPointSet( const InputPointSetType * ptr )
{
  this->m_PointSet = ptr;

  /**
   * Generate KdTree and create set of gaussians from input point set
   */
  std::vector<typename GaussianType::Pointer> inputGaussians;
  inputGaussians.resize( this->GetInputPointSet()->GetNumberOfPoints() );
  this->m_Gaussians.resize( this->GetInputPointSet()->GetNumberOfPoints() );

  const PointsContainer * points = this->GetInputPointSet()->GetPoints();

  IdentifierType count = NumericTraits< IdentifierType >::Zero;

  typename PointSetType::PointsContainerConstIterator It = points->Begin();

  while( It != points->End() )
    {
    CovarianceMatrixType covariance( PointDimension, PointDimension );

    covariance.SetIdentity();
    covariance *= this->m_KernelSigma;

    inputGaussians[count] = GaussianType::New();
    inputGaussians[count]->SetMeasurementVectorSize( PointDimension );
    inputGaussians[count]->SetMean( It.Value() );
    inputGaussians[count]->SetCovariance( covariance );

    count++;
    ++It;
    }

  this->m_PointsLocator = PointsLocatorType::New();
  this->m_PointsLocator->SetPoints( const_cast<PointsContainer *>( points ) );
  this->m_PointsLocator->Initialize();

  /**
   * Calculate covariance matrices
   */

  It = points->Begin();
  while( It != points->End() )
    {
    PointType point = It.Value();
    unsigned long index = It.Index();

    this->m_Gaussians[index] = GaussianType::New();
    this->m_Gaussians[index]->SetMeasurementVectorSize( PointDimension );
    this->m_Gaussians[index]->SetMean( inputGaussians[index]->GetMean() );

    if( this->m_CovarianceKNeighborhood > 0
      && this->m_UseAnisotropicCovariances )
      {
      CovarianceMatrixType Cout( PointDimension, PointDimension );
      Cout.Fill( 0 );

      typename PointsLocatorType::NeighborsIdentifierType neighbors;
      this->m_PointsLocator->Search( point, this->m_CovarianceKNeighborhood, neighbors );

      RealType denominator = 0.0;
      for( unsigned int j = 0; j < this->m_CovarianceKNeighborhood; j++ )
        {
        if( neighbors[j] != index
          && neighbors[j] < this->GetInputPointSet()->GetNumberOfPoints() )
          {
          PointType neighbor =
            this->GetInputPointSet()->GetPoint( neighbors[j] );

          RealType kernelValue = inputGaussians[index]->Evaluate( neighbor );

          denominator += kernelValue;
          if( kernelValue > 0.0 )
            {
            for( unsigned int m = 0; m < PointDimension; m++ )
              {
              for( unsigned int n = m; n < PointDimension; n++ )
                {
                RealType covariance = kernelValue * ( neighbor[m] - point[m] ) *
                  ( neighbor[n] - point[n] );
                Cout(m, n) += covariance;
                Cout(n, m) += covariance;
                }
              }
            }
          }
        }

      if( this->m_Normalize && denominator > 0.0 )
        {
        Cout /= denominator;
        }
      else
        {
        Cout /= static_cast<RealType>( this->m_CovarianceKNeighborhood );
        }
      for( unsigned int m = 0; m < PointDimension; m++ )
        {
        Cout(m, m) += vnl_math_sqr( this->m_RegularizationSigma );
        }

      this->m_Gaussians[index]->SetCovariance( Cout );
      }
    else
      {
      typename GaussianType::CovarianceMatrixType covariance
        ( PointDimension, PointDimension );
      covariance.SetIdentity();
      covariance *= vnl_math_sqr( this->m_RegularizationSigma );
      this->m_Gaussians[index]->SetCovariance( covariance );
      }
    ++It;
    }
}

template <typename TPointSet, typename TOutput, typename TCoordRep>
TOutput
ManifoldParzenWindowsPointSetFunction<TPointSet, TOutput, TCoordRep>
::Evaluate( const InputPointType &point ) const
{
  if( this->GetInputPointSet() == NULL )
    {
    itkExceptionMacro( "The input point set has not been specified." );
    }

  unsigned int numberOfNeighbors = vnl_math_min(
    this->m_EvaluationKNeighborhood,
    static_cast<unsigned int>( this->m_Gaussians.size() ) );

  OutputType sum = NumericTraits< OutputType>::Zero;

  if( numberOfNeighbors == this->m_Gaussians.size() )
    {
    for( unsigned int j = 0; j < this->m_Gaussians.size(); j++ )
      {
      sum += static_cast<OutputType>(
        this->m_Gaussians[j]->Evaluate( point ) );
      }
    }
  else
    {
    typename PointsLocatorType::NeighborsIdentifierType neighbors;
    this->m_PointsLocator->Search( point, numberOfNeighbors, neighbors );

    for( unsigned int j = 0; j < numberOfNeighbors; j++ )
      {
      sum += static_cast<OutputType>(
        this->m_Gaussians[neighbors[j]]->Evaluate( point ) );
      }
    }
  return static_cast<OutputType>(
    sum / static_cast<OutputType>( this->m_Gaussians.size() ) );
}

template <typename TPointSet, typename TOutput, typename TCoordRep>
typename ManifoldParzenWindowsPointSetFunction<TPointSet, TOutput, TCoordRep>::GaussianConstPointer
ManifoldParzenWindowsPointSetFunction<TPointSet, TOutput, TCoordRep>
::GetGaussian( PointIdentifier i ) const
{
  if( i < this->m_Gaussians.size() )
    {
    return this->m_Gaussians[i].GetPointer();
    }
  else
    {
    return NULL;
    }
}

/**
 * Standard "PrintSelf" method
 */
template <typename TPointSet, typename TOutput, typename TCoordRep>
void
ManifoldParzenWindowsPointSetFunction<TPointSet, TOutput, TCoordRep>
::PrintSelf(
  std::ostream& os,
  Indent indent) const
{
  os << indent << "Covariance neighborhood: "
               << this->m_CovarianceKNeighborhood << std::endl;
  os << indent << "Evaluation neighborhood: "
               << this->m_EvaluationKNeighborhood << std::endl;
  os << indent << "Regularization sigma: "
               << this->m_RegularizationSigma << std::endl;
  os << indent << "Kernel sigma: "
               << this->m_KernelSigma << std::endl;
  os << indent << "Normalize: "
               << this->m_Normalize << std::endl;
  os << indent << "Use anisotropic covariances: "
               << this->m_UseAnisotropicCovariances << std::endl;
}

}  //end namespace itk

#endif