This file is indexed.

/usr/include/InsightToolkit/Common/itkNeighborhood.h is in libinsighttoolkit3-dev 3.20.1-1.

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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
/*=========================================================================

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

  Copyright (c) Insight Software 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 __itkNeighborhood_h
#define __itkNeighborhood_h

#include <iostream>
#include "itkNeighborhoodAllocator.h"
#include "itkSize.h"
#include "itkIndent.h"
#include "itkSliceIterator.h"
#include "vnl/vnl_vector.h"
#include "itkOffset.h"
#include <vector>
#include <stdlib.h>
#include <string.h>

namespace itk {

/** \class Neighborhood
 * \brief A light-weight container object for storing an N-dimensional
 * neighborhood of values.
 *
 * This class serves as the base class for several other Itk objects such as
 * itk::NeighborhoodOperator and itk::NeighborhoodIterator.  Its purpose is to
 * store values and their relative spatial locations.
 *
 * A Neighborhood has an N-dimensional \em radius.  The radius is defined
 * separately for each dimension as the number of pixels that the neighborhood
 * extends outward from the center pixel.  For example, a 2D Neighborhood
 * object with a radius of 2x3 has sides of length 5x7.  Neighborhood objects
 * always have an unambiguous center because their side lengths are always odd.
 *
 * \sa Neighborhood
 * \sa NeighborhoodIterator
 *
 * \ingroup Operators
 * \ingroup ImageIterators
 */

template<class TPixel, unsigned int VDimension = 2,
         class TAllocator = NeighborhoodAllocator<TPixel> >
class ITK_EXPORT Neighborhood
{
public:
  /** Standard class typedefs. */
  typedef Neighborhood Self;

  /** External support for allocator type. */
  typedef TAllocator AllocatorType;

  /** External support for dimensionality. */
  itkStaticConstMacro(NeighborhoodDimension, unsigned int, VDimension);

  /** External support for pixel type. */
  typedef TPixel PixelType;

  /** Iterator typedef support. Note the naming is intentional, i.e.,
  * ::iterator and ::const_iterator, because the allocator may be a
  * vnl object or other type, which uses this form. */
  typedef typename AllocatorType::iterator       Iterator;
  typedef typename AllocatorType::const_iterator ConstIterator;

  /** Size and value typedef support. */
  typedef ::itk::Size<VDimension>          SizeType;
  typedef typename SizeType::SizeValueType SizeValueType;

  /** Radius typedef support. */
  typedef ::itk::Size<VDimension> RadiusType;

  /** Offset type used to reference neighbor locations */
  typedef Offset<VDimension> OffsetType;

  /** External slice iterator type typedef support. */
  typedef SliceIterator<TPixel, Self> SliceIteratorType;

  /** Default constructor. */
  Neighborhood()
    {
    m_Radius.Fill(0);
    m_Size.Fill(0);
    for (unsigned int i = 0; i < VDimension; i++)
      {
      m_StrideTable[i] = 0;
      }
    }

  /** Default destructor. */
  virtual ~Neighborhood() {}

  /** Copy constructor. */
  Neighborhood(const Self& other);

  /** Assignment operator. */
  Self &operator=(const Self& other);

  /** Comparison operator. */
  bool
  operator==(const Self& other) const
    {
    return (m_Radius == other.m_Radius &&
            m_Size   == other.m_Size &&
            m_DataBuffer == other.m_DataBuffer);
    }

  /** Not Equal operator. */
  bool operator!=(const Self& other) const
    {
    return (m_Radius != other.m_Radius ||
            m_Size   != other.m_Size ||
            m_DataBuffer != other.m_DataBuffer);
    }

  /** Returns the radius of the neighborhood. */
  const SizeType GetRadius() const
    { return m_Radius; }

  /** Returns the radius of the neighborhood along a specified
   * dimension. */
  unsigned long GetRadius(const unsigned long n) const
    { return m_Radius[n]; }

  /** Returns the size (total length) of the neighborhood along
   * a specified dimension. */
  unsigned long GetSize(const unsigned long n) const
    { return m_Size[n]; }

  /** Returns the size (total length of sides) of the neighborhood. */
  SizeType GetSize() const
    { return m_Size; }

  /** Returns the stride length for the specified dimension. Stride
   * length is the number of pixels between adjacent pixels along the
   * given dimension. */
  unsigned GetStride(const unsigned axis) const
  {     return m_StrideTable[axis];  }

  /** STL-style iterator support. */
  Iterator End()
    { return m_DataBuffer.end(); }
  Iterator Begin()
    { return m_DataBuffer.begin(); }
  ConstIterator End() const
    { return m_DataBuffer.end(); }
  ConstIterator Begin() const
    { return m_DataBuffer.begin(); }

  /** More STL-style support. */
  unsigned int Size() const
    { return m_DataBuffer.size(); }

  /** Pass-through data access methods to the buffer. */
  TPixel &operator[](unsigned int i)
    { return m_DataBuffer[i]; }
  const TPixel &operator[](unsigned int i) const
    { return m_DataBuffer[i]; }
  TPixel &GetElement(unsigned int i)
    { return m_DataBuffer[i]; }

  /** Returns the element at the center of the neighborhood. */
  TPixel GetCenterValue() const
    { return (this->operator[]((this->Size())>>1)); }

  /** Sets the radius for the neighborhood, calculates size from the
   * radius, and allocates storage. */
  void SetRadius(const SizeType &);

  /** Sets the radius for the neighborhood. Overloaded to support an unsigned
   * long array. */
  void SetRadius(const unsigned long *rad)
    {
    SizeType s;
    memcpy(s.m_Size, rad, sizeof(unsigned long) * VDimension);
    this->SetRadius(s);
    }

  /** Overloads SetRadius to allow a single long integer argument
   * that is used as the radius of all the dimensions of the
   * Neighborhood (resulting in a "square" neighborhood). */
  void SetRadius(const unsigned long);

  /** Standard itk object method. */
  void Print(std::ostream& os) const
    { this->PrintSelf(os, Indent(0));  }

  /** Returns a reference to the data buffer structure. */
  AllocatorType &GetBufferReference()
    { return m_DataBuffer; }
  const AllocatorType &GetBufferReference() const
    { return m_DataBuffer; }

  /** Get pixel value by offset */
  TPixel &operator[](const OffsetType &o)
    { return this->operator[](this->GetNeighborhoodIndex(o)); }
  const TPixel &operator[](const OffsetType &o) const
    { return this->operator[](this->GetNeighborhoodIndex(o)); }

  /** Returns the itk::Offset from the center of the Neighborhood to
      the requested neighbor index. */
  OffsetType GetOffset(unsigned int i) const
    { return m_OffsetTable[i]; }

  virtual unsigned int GetNeighborhoodIndex(const OffsetType &) const;

  unsigned int GetCenterNeighborhoodIndex() const
    {
    return  static_cast<unsigned int>(this->Size()/2);
    }

  std::slice GetSlice(unsigned int) const;

protected:
  /** Sets the length along each dimension. */
  void SetSize()
    {
    for (unsigned int i=0; i<VDimension; ++i)
      {
      m_Size[i] = m_Radius[i]*2+1;
      }
    }

  /** Allocates the neighborhood's memory buffer. */
  virtual void Allocate(unsigned int i)
    { m_DataBuffer.set_size(i); }

  /** Standard itk object method. */
  virtual void PrintSelf(std::ostream&, Indent) const;

  /** Computes the entries for the stride table */
  virtual void ComputeNeighborhoodStrideTable();

  /** Fills entries into the offset lookup table. Called once on
      initialization. */
  virtual void ComputeNeighborhoodOffsetTable();

private:
  /** Number of neighbors to include (symmetrically) along each axis.
   * A neighborhood will always have odd-length axes (m_Radius[n]*2+1). */
  SizeType m_Radius;

  /** Actual length of each dimension, calculated from m_Radius.
   * A neighborhood will always have odd-length axes (m_Radius[n]*2+1). */
  SizeType m_Size;

  /** The buffer in which data is stored. */
  AllocatorType m_DataBuffer;

  /** A lookup table for keeping track of stride lengths in a neighborhood
      i.e. the memory offsets between pixels along each dimensional axis */
  unsigned int m_StrideTable[VDimension];

  /** */
  std::vector<OffsetType> m_OffsetTable;

};

template <class TPixel, unsigned int VDimension, class TContainer>
std::ostream & operator<<(std::ostream &os, const Neighborhood<TPixel,VDimension,TContainer> &neighborhood)
{
  os << "Neighborhood:" << std::endl;
  os << "    Radius:" << neighborhood.GetRadius() << std::endl;
  os << "    Size:" << neighborhood.GetSize() << std::endl;
  os << "    DataBuffer:" << neighborhood.GetBufferReference() << std::endl;

  return os;
}

} // namespace itk

// Define instantiation macro for this template.
#define ITK_TEMPLATE_Neighborhood(_, EXPORT, x, y) namespace itk { \
  _(2(class EXPORT Neighborhood< ITK_TEMPLATE_2 x >)) \
  namespace Templates { typedef Neighborhood< ITK_TEMPLATE_2 x > \
                                                  Neighborhood##y; } \
  }

#if ITK_TEMPLATE_EXPLICIT
# include "Templates/itkNeighborhood+-.h"
#endif

#if ITK_TEMPLATE_TXX
# include "itkNeighborhood.txx"
#endif

/*
#ifndef ITK_MANUAL_INSTANTIATION
#include "itkNeighborhood.txx"
#endif
*/

#endif