This file is indexed.

/usr/include/ITK-4.5/itkCurvatureFlowFunction.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
/*=========================================================================
 *
 *  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 __itkCurvatureFlowFunction_hxx
#define __itkCurvatureFlowFunction_hxx
#include "itkCurvatureFlowFunction.h"

#include "vnl/vnl_math.h"

namespace itk
{
/**
 * Constructor
 */
template< typename TImage >
CurvatureFlowFunction< TImage >
::CurvatureFlowFunction()
{
  RadiusType   r;
  unsigned int j;

  for ( j = 0; j < ImageDimension; j++ )
    {
    r[j] = 1;
    }

  this->SetRadius(r);

  m_TimeStep  = 0.05f;
}

/**
 * Compute the global time step
 */
template< typename TImage >
typename CurvatureFlowFunction< TImage >::TimeStepType
CurvatureFlowFunction< TImage >
::ComputeGlobalTimeStep( void *itkNotUsed(gd) ) const
{
  return this->GetTimeStep();
}

/**
 * Update the solution at pixels which lies on the data boundary.
 */
template< typename TImage >
typename CurvatureFlowFunction< TImage >::PixelType
CurvatureFlowFunction< TImage >
::ComputeUpdate( const NeighborhoodType & it, void *itkNotUsed(gd),
                 const FloatOffsetType & itkNotUsed(offset) )
{
  PixelRealType firstderiv[ImageDimension];
  PixelRealType secderiv[ImageDimension];
  PixelRealType crossderiv[ImageDimension][ImageDimension];
  IdentifierType center;
  IdentifierType stride[ImageDimension];
  unsigned int  i, j;

  const NeighborhoodScalesType neighborhoodScales = this->ComputeNeighborhoodScales();

  // get the center pixel position
  center = it.Size() / 2;

  // cache the stride for each dimension
  for ( i = 0; i < ImageDimension; i++ )
    {
    stride[i] = it.GetStride( (IdentifierType)i );
    }

  PixelRealType magnitudeSqr = 0.0;
  for ( i = 0; i < ImageDimension; i++ )
    {
    // compute first order derivatives
    firstderiv[i] = 0.5 * ( it.GetPixel(center + stride[i])
                            - it.GetPixel(center - stride[i]) ) * neighborhoodScales[i];

    // compute second order derivatives
    secderiv[i] = ( it.GetPixel(center + stride[i])
                    - 2 * it.GetPixel(center) + it.GetPixel(center - stride[i]) ) * vnl_math_sqr(neighborhoodScales[i]);

    // compute cross derivatives
    for ( j = i + 1; j < ImageDimension; j++ )
      {
      crossderiv[i][j] = 0.25 * (
        it.GetPixel(center - stride[i] - stride[j])
        - it.GetPixel(center - stride[i] + stride[j])
        - it.GetPixel(center + stride[i] - stride[j])
        + it.GetPixel(center + stride[i] + stride[j]) )
                         * neighborhoodScales[i] * neighborhoodScales[j];
      }

    // accumlate the gradient magnitude squared
    magnitudeSqr += vnl_math_sqr( (double)firstderiv[i] );
    }

  if ( magnitudeSqr < 1e-9 )
    {
    return NumericTraits< PixelType >::Zero;
    }

  // compute the update value = mean curvature * magnitude
  PixelRealType update = 0.0;
  PixelRealType temp;

  // accumulate dx^2 * (dyy + dzz) terms
  for ( i = 0; i < ImageDimension; i++ )
    {
    temp = 0.0;
    for ( j = 0; j < ImageDimension; j++ )
      {
      if ( j == i ) { continue; }
      temp += secderiv[j];
      }

    update += temp * vnl_math_sqr( (double)firstderiv[i] );
    }

  // accumlate -2 * dx * dy * dxy terms
  for ( i = 0; i < ImageDimension; i++ )
    {
    for ( j = i + 1; j < ImageDimension; j++ )
      {
      update -= 2 * firstderiv[i] * firstderiv[j]
                * crossderiv[i][j];
      }
    }

  update /= magnitudeSqr;
  return static_cast< PixelType >( update );
}
} // end namespace itk

#endif