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 ) ) );
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; }
160 {
return m_Size[i]; }
166 { m_Index[i] = sze; }
168 {
return m_Index[i]; }
172 IndexType GetUpperIndex()
const;
175 void SetUpperIndex(
const IndexType & idx );
178 void ComputeOffsetTable(OffsetTableType offsetTable)
const;
182 operator==(
const Self & region)
const
186 same = ( m_Index == region.m_Index );
187 same = same && ( m_Size == region.m_Size );
197 same = ( m_Index == region.m_Index );
198 same = same && ( m_Size == region.m_Size );
206 for (
unsigned int i = 0; i < ImageDimension; i++ )
208 if ( index[i] < m_Index[i] )
212 if ( index[i] >= ( m_Index[i] + static_cast< IndexValueType >( m_Size[i] ) ) )
225 template<
typename TCoordRepType >
229 for (
unsigned int i = 0; i < ImageDimension; i++ )
231 if ( Math::RoundHalfIntegerUp< IndexValueType >(index[i]) < static_cast< IndexValueType >( m_Index[i] ) )
236 const TCoordRepType bound =
static_cast< TCoordRepType
>(
237 m_Index[i] + m_Size[i] - 0.5 );
246 if ( ! (index[i] <= bound) )
259 IsInside(
const Self & region)
const
261 IndexType beginCorner = region.GetIndex();
263 if ( !this->IsInside(beginCorner) )
269 for (
unsigned int i = 0; i < ImageDimension; i++ )
271 endCorner[i] = beginCorner[i] +
static_cast< OffsetValueType >( size[i] ) - 1;
273 if ( !this->IsInside(endCorner) )
289 void PadByRadius(
const IndexValueArrayType radius);
291 void PadByRadius(
const SizeType & radius);
299 bool ShrinkByRadius(
const IndexValueArrayType radius);
301 bool ShrinkByRadius(
const SizeType & radius);
307 bool Crop(
const Self & region);
312 SliceRegion Slice(
const unsigned long dim)
const;
319 virtual void PrintSelf(std::ostream & os,
Indent indent)
const;
329 template<
unsigned int VImageDimension >
330 std::ostream & operator<<(std::ostream & os, const ImageRegion< VImageDimension > & region);
334 #define ITK_TEMPLATE_ImageRegion(_, EXPORT, TypeX, TypeY) \
337 _( 1 ( class EXPORT ImageRegion< ITK_TEMPLATE_1 TypeX > ) ) \
338 _( 1 ( EXPORT std::ostream & operator<<(std::ostream &, \
339 const ImageRegion< ITK_TEMPLATE_1 TypeX > &) ) ) \
340 namespace Templates \
342 typedef ImageRegion< ITK_TEMPLATE_1 TypeX > ImageRegion##TypeY; \
346 #if ITK_TEMPLATE_EXPLICIT
351 #include "Templates/itkImageRegion+-.h"
355 #include "itkImageRegion.hxx"