28 #ifndef itkImageRegion_h
29 #define itkImageRegion_h
41 template<
unsigned int VImageDimension >
68 template<
unsigned int VImageDimension >
80 static constexpr
unsigned int ImageDimension = VImageDimension;
84 static constexpr
unsigned int SliceDimension = ImageDimension - ( ImageDimension > 1 );
88 {
return ImageDimension; }
107 {
return Superclass::ITK_STRUCTURED_REGION; }
145 Self& operator=(
const Self & ) ITK_NOEXCEPT = default;
171 {
return m_Size[i]; }
177 { m_Index[i] = sze; }
179 {
return m_Index[i]; }
186 void SetUpperIndex(
const IndexType & idx );
189 void ComputeOffsetTable(OffsetTableType offsetTable)
const;
195 return (m_Index == region.m_Index) && (m_Size == region.m_Size);
202 return !(*
this == region);
209 for (
unsigned int i = 0; i < ImageDimension; i++ )
211 if ( index[i] < m_Index[i] )
215 if ( index[i] >= ( m_Index[i] + static_cast< IndexValueType >( m_Size[i] ) ) )
228 template<
typename TCoordRepType >
232 for (
unsigned int i = 0; i < ImageDimension; i++ )
234 if ( Math::RoundHalfIntegerUp< IndexValueType >(index[i]) < static_cast< IndexValueType >( m_Index[i] ) )
239 const auto bound =
static_cast< TCoordRepType
>(
240 m_Index[i] + m_Size[i] - 0.5 );
249 if ( ! (index[i] <= bound) )
264 IndexType beginCorner = region.GetIndex();
266 if ( !this->IsInside(beginCorner) )
271 const SizeType & size = region.GetSize();
272 for (
unsigned int i = 0; i < ImageDimension; i++ )
274 endCorner[i] = beginCorner[i] +
static_cast< OffsetValueType >( size[i] ) - 1;
276 if ( !this->IsInside(endCorner) )
292 void PadByRadius(
const IndexValueArrayType radius);
294 void PadByRadius(
const SizeType & radius);
302 bool ShrinkByRadius(
const IndexValueArrayType radius);
304 bool ShrinkByRadius(
const SizeType & radius);
310 bool Crop(
const Self & region);
315 SliceRegion Slice(
const unsigned int dim)
const;
322 void PrintSelf(std::ostream & os,
Indent indent)
const override;
332 template<
unsigned int VImageDimension >
333 std::ostream & operator<<(std::ostream & os, const ImageRegion< VImageDimension > & region);
336 #ifndef ITK_MANUAL_INSTANTIATION
337 #include "itkImageRegion.hxx"
void SetSize(const SizeType &size)
typename IndexType::OffsetType OffsetType
bool operator==(const Self ®ion) const noexcept
IndexValueType GetIndex(unsigned int i) const
const IndexType & GetIndex() const
unsigned long SizeValueType
bool IsInside(const IndexType &index) const
An image region represents a structured region of data.
typename IndexType::IndexValueType IndexValueType
static unsigned int GetImageDimension()
Superclass::RegionType GetRegionType() const override
SizeValueType GetSize(unsigned int i) const
ImageRegion(const SizeType &size) noexcept
ImageBaseType::SizeType SizeType
IndexType & GetModifiableIndex()
ImageBaseType::IndexType IndexType
SizeType & GetModifiableSize()
signed long IndexValueType
Represent a n-dimensional offset between two n-dimensional indexes of n-dimensional image...
void SetSize(unsigned int i, SizeValueType sze)
const SizeType & GetSize() const
A region represents some portion or piece of data.
typename OffsetType::OffsetValueType OffsetValueType
class ITK_TEMPLATE_EXPORT ImageBase
bool IsInside(const Self ®ion) const
Base class for templated image classes.
A templated class holding a point in n-Dimensional image space.
Control indentation during Print() invocation.
bool operator!=(const Self ®ion) const noexcept
void SetIndex(unsigned int i, IndexValueType sze)
typename SizeType::SizeValueType SizeValueType
signed long OffsetValueType
bool IsInside(const ContinuousIndex< TCoordRepType, VImageDimension > &index) const