This file is indexed.

/usr/include/InsightToolkit/Common/itkImageRegion.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
305
306
307
308
309
310
311
/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit
  Module:    itkImageRegion.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.

  Portions of this code are covered under the VTK copyright.
  See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.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 __itkImageRegion_h
#define __itkImageRegion_h

#include "itkRegion.h"

#include "itkIndex.h"
#include "itkSize.h"
#include "itkContinuousIndex.h"
#include "vnl/vnl_math.h"

namespace itk
{
// Forward declaration of ImageBase so it can be declared a friend
// (needed for PrintSelf mechanism)
template <unsigned int VImageDimension> class ImageBase;


/** \class ImageRegion
 * \brief An image region represents a structured region of data.
 *
 * ImageRegion is an class that represents some structured portion or
 * piece of an Image. The ImageRegion is represented with an index and
 * a size in each of the n-dimensions of the image. (The index is the
 * corner of the image, the size is the lengths of the image in each of
 * the topological directions.)
 *
 * \sa Region
 * \sa Index
 * \sa Size
 * \sa MeshRegion
 *
 * \ingroup ImageObjects
 */

template <unsigned int VImageDimension>
class ITK_EXPORT ImageRegion: public Region
{
public:
  /** Standard class typedefs. */
  typedef ImageRegion             Self;
  typedef Region                  Superclass;

  /** Standard part of all itk objects. */
  itkTypeMacro(ImageRegion, Region);

  /** Dimension of the image available at compile time. */
  itkStaticConstMacro(ImageDimension, unsigned int, VImageDimension);

  /** Dimension one lower than the image unless the image is one dimensional
      in which case the SliceDimension is also one dimensional. */
  itkStaticConstMacro(SliceDimension, unsigned int,
                      (ImageDimension - (ImageDimension > 1)));

  /** Dimension of the image available at run time. */
  static unsigned int GetImageDimension()
    { return ImageDimension; }

  /** Index typedef support. An index is used to access pixel values. */
  typedef Index< itkGetStaticConstMacro( ImageDimension) >  IndexType;
  typedef typename IndexType::IndexValueType                IndexValueType;
  typedef IndexValueType                          IndexValueArrayType[ ImageDimension];
  typedef typename IndexType::OffsetType          OffsetType;
  typedef typename OffsetType::OffsetValueType    OffsetValueType;

  /** Size typedef support. A size is used to define region bounds. */
  typedef Size< itkGetStaticConstMacro( ImageDimension ) >  SizeType;
  typedef typename SizeType::SizeValueType                  SizeValueType;

  /** Slice region typedef. SliceRegion is one dimension less than Self. */
  typedef ImageRegion<itkGetStaticConstMacro(SliceDimension)> SliceRegion;

  /** Return the region type. Images are described with structured regions. */
  virtual typename Superclass::RegionType GetRegionType() const
    {return Superclass::ITK_STRUCTURED_REGION;}

  /** Constructor. ImageRegion is a lightweight object that is not reference
   * counted, so the constructor is public. */
  ImageRegion();

  /** Destructor. ImageRegion is a lightweight object that is not reference
   * counted, so the destructor is public. */
  virtual ~ImageRegion();

  /** Copy constructor. ImageRegion is a lightweight object that is not
   * reference counted, so the copy constructor is public. */
  ImageRegion(const Self& region): Region(region), m_Index( region.m_Index ), m_Size( region.m_Size ) {}

  /** Constructor that takes an index and size. ImageRegion is a lightweight
   * object that is not reference counted, so this constructor is public. */
  ImageRegion(const IndexType &index, const SizeType &size)
    { m_Index = index; m_Size = size; };

  /** Constructor that takes a size and assumes an index of zeros. ImageRegion
   * is lightweight object that is not reference counted so this constructor
   * is public. */
  ImageRegion(const SizeType &size)
    { m_Size = size; m_Index.Fill(0); }

  /** operator=. ImageRegion is a lightweight object that is not reference
   * counted, so operator= is public. */
  void operator=(const Self& region)
    { m_Index = region.m_Index;  m_Size = region.m_Size; };

  /** Set the index defining the corner of the region. */
  void SetIndex(const IndexType &index)
    { m_Index = index; };

  /** Get index defining the corner of the region. */
  const IndexType& GetIndex() const
    { return m_Index; };

  /** Set the size of the region. This plus the index determines the
   * rectangular shape, or extent, of the region. */
  void SetSize(const SizeType &size)
    { m_Size = size; };

  /** Get the size of the region. */
  const SizeType& GetSize() const
    { return m_Size; }

  /** Convenience methods to get and set the size of the particular dimension i. */
  void SetSize(unsigned long i, SizeValueType sze)
    { m_Size[i] = sze; }
  SizeValueType GetSize(unsigned long i) const
    { return m_Size[i]; }

  /** Convenience methods to get and set the index of the particular dimension i. */
  void SetIndex(unsigned long i, IndexValueType sze)
    { m_Index[i] = sze; }
  IndexValueType GetIndex(unsigned long i) const
    { return m_Index[i]; }

  /** Compare two regions. */
  bool
  operator==(const Self &region) const
    {
    bool same = 1;
    same = (m_Index == region.m_Index);
    same = same && (m_Size == region.m_Size);
    return same;
    }

  /** Compare two regions. */
  bool
  operator!=(const Self &region) const
    {
    bool same = 1;
    same = (m_Index == region.m_Index);
    same = same && (m_Size == region.m_Size);
    return !same;
    }


  /** Test if an index is inside */
  bool
  IsInside(const IndexType &index) const
    {
    for(unsigned int i=0; i<ImageDimension; i++)
      {
      if( index[i] < m_Index[i] )
        {
        return false;
        }
      if( index[i] >= (m_Index[i] + static_cast<IndexValueType>(m_Size[i])) )
        {
        return false;
        }
      }
    return true;
    }

  /** Test if a continuous index is inside the region.
   * If ITK_USE_CENTERED_PIXEL_COORDINATES_CONSISTENTLY is on,
   * we take into account the fact that each voxel has its
   * center at the integer coordinate and extends half way
   * to the next integer coordinate. */
  template <typename TCoordRepType>
  bool
  IsInside(const ContinuousIndex<TCoordRepType,VImageDimension> &index) const
    {
    for(unsigned int i=0; i<ImageDimension; i++)
      {
#ifdef ITK_USE_CENTERED_PIXEL_COORDINATES_CONSISTENTLY
      if( Math::RoundHalfIntegerUp<IndexValueType>(index[i]) < static_cast<IndexValueType>( m_Index[i] ) )
#else
      if( index[i] < static_cast<TCoordRepType>( m_Index[i] ) )
#endif
        {
        return false;
        }
      // bound is the last valid pixel location
#ifdef ITK_USE_CENTERED_PIXEL_COORDINATES_CONSISTENTLY
      const TCoordRepType bound = static_cast<TCoordRepType>(
         m_Index[i] + m_Size[i] - 0.5);
#else
      const TCoordRepType bound = static_cast<TCoordRepType>(
         m_Index[i] + static_cast<IndexValueType>(m_Size[i]) - 1);
#endif

      if( index[i] > bound )
        {
        return false;
        }
      }
    return true;
    }

  /** Test if a region (the argument) is completely inside of this region. If
   * the region that is passed as argument to this method, has a size of value
   * zero, then it will not be considered to be inside of the current region,
   * even its starting index is inside. */
  bool
  IsInside(const Self &region) const
    {
    IndexType beginCorner = region.GetIndex();
    if( ! this->IsInside( beginCorner ) )
      {
      return false;
      }
    IndexType endCorner;
    SizeType  size = region.GetSize();
    for(unsigned int i=0; i<ImageDimension; i++)
      {
      endCorner[i] = beginCorner[i] + size[i] - 1;
      }
    if( ! this->IsInside( endCorner ) )
      {
      return false;
      }
    return true;
    }

  /** Get the number of pixels contained in this region. This just
   * multiplies the size components. */
  SizeValueType GetNumberOfPixels() const;

  /** Pad an image region by the specified radius. Region can be padded
   * uniformly in all dimensions or can be padded by different amounts
   * in each dimension. */
  void PadByRadius(IndexValueType radius);
  void PadByRadius(const IndexValueArrayType radius);
  void PadByRadius(const SizeType &radius);

  /** Crop a region by another region. If this region is outside of the
   * crop, this method returns false and does not modify the
   * region. Otherwise, this method returns true and the region is
   * modified to reflect the crop. */
  bool Crop(const Self& region);

  /** Slice a region, producing a region that is one dimension lower
   * than the current region. Parameter "dim" specifies which dimension
   * to remove. */
  SliceRegion Slice(const unsigned long dim) const;

protected:
  /** Methods invoked by Print() to print information about the object
   * including superclasses. Typically not called by the user (use Print()
   * instead) but used in the hierarchical print process to combine the
   * output of several classes.  */
  virtual void PrintSelf(std::ostream& os, Indent indent) const;

private:
  IndexType           m_Index;
  SizeType            m_Size;

  /** Friends of ImageRegion */
  friend class ImageBase<VImageDimension>;
};


template<unsigned int VImageDimension>
std::ostream & operator<<(std::ostream &os, const ImageRegion<VImageDimension> &region);

} // end namespace itk

// Define instantiation macro for this template.
#define ITK_TEMPLATE_ImageRegion(_, EXPORT, x, y) namespace itk { \
  _(1(class EXPORT ImageRegion< ITK_TEMPLATE_1 x >)) \
  _(1(EXPORT std::ostream& operator<<(std::ostream&, \
                                      const ImageRegion< ITK_TEMPLATE_1 x >&))) \
  namespace Templates { typedef ImageRegion< ITK_TEMPLATE_1 x > ImageRegion##y; } \
  }

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

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

#endif