20 #ifndef __itkImageRegion_h
21 #define __itkImageRegion_h
28 #include "vnl/vnl_math.h"
34 template <
unsigned int VImageDimension>
class ImageBase;
54 template <
unsigned int VImageDimension>
66 itkStaticConstMacro(ImageDimension,
unsigned int, VImageDimension);
70 itkStaticConstMacro(SliceDimension,
unsigned int,
71 (ImageDimension - (ImageDimension > 1)));
75 {
return ImageDimension; }
93 {
return Superclass::ITK_STRUCTURED_REGION;}
110 { m_Index = index; m_Size = size; };
116 { m_Size = size; m_Index.
Fill(0); }
120 void operator=(
const Self& region)
121 { m_Index = region.m_Index; m_Size = region.m_Size; };
125 { m_Index = index; };
144 {
return m_Size[i]; }
148 { m_Index[i] = sze; }
150 {
return m_Index[i]; }
157 same = (m_Index == region.m_Index);
158 same = same && (m_Size == region.m_Size);
167 same = (m_Index == region.m_Index);
168 same = same && (m_Size == region.m_Size);
177 for(
unsigned int i=0; i<ImageDimension; i++)
179 if( index[i] < m_Index[i] )
183 if( index[i] >= (m_Index[i] + static_cast<IndexValueType>(m_Size[i])) )
196 template <
typename TCoordRepType>
200 for(
unsigned int i=0; i<ImageDimension; i++)
202 #ifdef ITK_USE_CENTERED_PIXEL_COORDINATES_CONSISTENTLY
203 if( Math::RoundHalfIntegerUp<IndexValueType>(index[i]) < static_cast<IndexValueType>( m_Index[i] ) )
205 if( index[i] < static_cast<TCoordRepType>( m_Index[i] ) )
211 #ifdef ITK_USE_CENTERED_PIXEL_COORDINATES_CONSISTENTLY
212 const TCoordRepType bound =
static_cast<TCoordRepType
>(
213 m_Index[i] + m_Size[i] - 0.5);
215 const TCoordRepType bound =
static_cast<TCoordRepType
>(
219 if( index[i] > bound )
232 IsInside(
const Self ®ion)
const
234 IndexType beginCorner = region.GetIndex();
235 if( ! this->IsInside( beginCorner ) )
241 for(
unsigned int i=0; i<ImageDimension; i++)
243 endCorner[i] = beginCorner[i] + size[i] - 1;
245 if( ! this->IsInside( endCorner ) )
254 SizeValueType GetNumberOfPixels()
const;
259 void PadByRadius(IndexValueType radius);
260 void PadByRadius(
const IndexValueArrayType radius);
261 void PadByRadius(
const SizeType &radius);
267 bool Crop(
const Self& region);
272 SliceRegion Slice(
const unsigned long dim)
const;
279 virtual void PrintSelf(std::ostream& os,
Indent indent)
const;
290 template<
unsigned int VImageDimension>
291 std::ostream & operator<<(std::ostream &os, const ImageRegion<VImageDimension> ®ion);
296 #define ITK_TEMPLATE_ImageRegion(_, EXPORT, x, y) namespace itk { \
297 _(1(class EXPORT ImageRegion< ITK_TEMPLATE_1 x >)) \
298 _(1(EXPORT std::ostream& operator<<(std::ostream&, \
299 const ImageRegion< ITK_TEMPLATE_1 x >&))) \
300 namespace Templates { typedef ImageRegion< ITK_TEMPLATE_1 x > ImageRegion##y; } \
303 #if ITK_TEMPLATE_EXPLICIT
304 # include "Templates/itkImageRegion+-.h"