28 #ifndef __itkImageRegion_h
29 #define __itkImageRegion_h
35 #include "vnl/vnl_math.h"
41 template<
unsigned int VImageDimension >
68 template<
unsigned int VImageDimension >
80 itkStaticConstMacro(ImageDimension,
unsigned int, VImageDimension);
84 itkStaticConstMacro( SliceDimension,
unsigned int,
85 ( ImageDimension - ( ImageDimension > 1 ) ) );
88 static unsigned int GetImageDimension()
89 {
return ImageDimension; }
108 {
return Superclass::ITK_STRUCTURED_REGION; }
125 { m_Index = index; m_Size = size; }
131 { m_Size = size; m_Index.
Fill(0); }
135 void operator=(
const Self & region)
136 { m_Index = region.m_Index;m_Size = region.m_Size; }
162 {
return m_Size[i]; }
168 { m_Index[i] = sze; }
170 {
return m_Index[i]; }
174 IndexType GetUpperIndex()
const;
177 void SetUpperIndex(
const IndexType & idx );
180 void ComputeOffsetTable(OffsetTableType offsetTable)
const;
184 operator==(
const Self & region)
const
188 same = ( m_Index == region.m_Index );
189 same = same && ( m_Size == region.m_Size );
199 same = ( m_Index == region.m_Index );
200 same = same && ( m_Size == region.m_Size );
208 for (
unsigned int i = 0; i < ImageDimension; i++ )
210 if ( index[i] < m_Index[i] )
214 if ( index[i] >= ( m_Index[i] + static_cast< IndexValueType >( m_Size[i] ) ) )
227 template<
typename TCoordRepType >
231 for (
unsigned int i = 0; i < ImageDimension; i++ )
233 if ( Math::RoundHalfIntegerUp< IndexValueType >(index[i]) < static_cast< IndexValueType >( m_Index[i] ) )
238 const TCoordRepType bound =
static_cast< TCoordRepType
>(
239 m_Index[i] + m_Size[i] - 0.5 );
248 if ( ! (index[i] <= bound) )
261 IsInside(
const Self & region)
const
263 IndexType beginCorner = region.GetIndex();
265 if ( !this->IsInside(beginCorner) )
271 for (
unsigned int i = 0; i < ImageDimension; i++ )
273 endCorner[i] = beginCorner[i] +
static_cast< OffsetValueType >( size[i] ) - 1;
275 if ( !this->IsInside(endCorner) )
291 void PadByRadius(
const IndexValueArrayType radius);
293 void PadByRadius(
const SizeType & radius);
301 bool ShrinkByRadius(
const IndexValueArrayType radius);
303 bool ShrinkByRadius(
const SizeType & radius);
309 bool Crop(
const Self & region);
314 SliceRegion Slice(
const unsigned int dim)
const;
321 virtual void PrintSelf(std::ostream & os,
Indent indent)
const;
331 template<
unsigned int VImageDimension >
332 std::ostream & operator<<(std::ostream & os, const ImageRegion< VImageDimension > & region);
335 #ifndef ITK_MANUAL_INSTANTIATION
336 #include "itkImageRegion.hxx"