18 #ifndef itkRLEImageConstIterator_h
19 #define itkRLEImageConstIterator_h
30 class MultiLabelMeshPipeline;
41 template<
typename TPixel,
unsigned int VImageDimension,
typename CounterType >
44 friend class ::MultiLabelMeshPipeline;
95 : m_RunLengthLine(nullptr),
103 m_SegmentRemainder = 0;
115 m_RunLengthLine = it.m_RunLengthLine;
117 m_Index0 = it.m_Index0;
118 this->m_BI = it.m_BI;
121 m_RealIndex = it.m_RealIndex;
122 m_SegmentRemainder = it.m_SegmentRemainder;
123 m_BeginIndex0 = it.m_BeginIndex0;
124 m_EndIndex0 = it.m_EndIndex0;
145 m_RunLengthLine = it.m_RunLengthLine;
147 m_Index0 = it.m_Index0;
151 m_RealIndex = it.m_RealIndex;
152 m_SegmentRemainder = it.m_SegmentRemainder;
153 m_BeginIndex0 = it.m_BeginIndex0;
154 m_EndIndex0 = it.m_EndIndex0;
165 if ( region.GetNumberOfPixels() > 0 )
168 itkAssertOrThrowMacro( ( bufferedRegion.IsInside( region ) ),
169 "Region " << region <<
" is outside of buffered region " << bufferedRegion );
174 m_BeginIndex0 = m_Index0 -
m_Image->GetBufferedRegion().GetIndex( 0 );
175 m_EndIndex0 = m_BeginIndex0 + region.GetSize( 0 );
176 SetIndexInternal( m_BeginIndex0 );
183 return VImageDimension;
191 return m_BI != it.m_BI || m_Index0 + m_BeginIndex0 != it.m_Index0 + it.m_BeginIndex0;
199 return m_BI == it.m_BI && m_Index0 + m_BeginIndex0 == it.m_Index0 + it.m_BeginIndex0;
207 if ( m_BI < it.m_BI )
211 else if ( m_BI > it.m_BI )
215 return m_Index0 + m_BeginIndex0 <= it.m_Index0 + it.m_BeginIndex0;
224 if ( m_BI < it.m_BI )
228 else if ( m_BI > it.m_BI )
232 return m_Index0 + m_BeginIndex0 < it.m_Index0 + it.m_BeginIndex0;
241 if ( m_BI > it.m_BI )
245 else if ( m_BI < it.m_BI )
249 return m_Index0 + m_BeginIndex0 >= it.m_Index0 + it.m_BeginIndex0;
258 if ( m_BI > it.m_BI )
262 else if ( m_BI < it.m_BI )
266 return m_Index0 + m_BeginIndex0 > it.m_Index0 + it.m_BeginIndex0;
280 indR[i] = bufInd[i - 1];
292 bufInd[i - 1] = ind[i];
295 SetIndexInternal( ind[0] -
m_Image->GetBufferedRegion().GetIndex( 0 ) );
306 r.SetIndex( 0, m_BeginIndex0 +
m_Image->GetBufferedRegion().GetIndex( 0 ) );
307 r.SetSize( 0, m_EndIndex0 - m_BeginIndex0 );
311 r.
SetIndex( i, ir.GetIndex( i - 1 ) );
312 r.SetSize( i, ir.GetSize( i - 1 ) );
339 return line[m_RealIndex].second;
348 SetIndexInternal( m_BeginIndex0 );
358 m_Index0 = m_BeginIndex0;
367 return m_Index0 == m_BeginIndex0 && m_BI.IsAtBegin();
375 return m_Index0 == m_BeginIndex0 && m_BI.IsAtEnd();
384 m_RunLengthLine = &m_BI.Value();
389 for (; x < ( *m_RunLengthLine ).size(); x++ )
391 t += ( *m_RunLengthLine )[x].first;
398 m_SegmentRemainder = t - m_Index0;
417 template<
typename TPixel,
unsigned int VImageDimension,
typename CounterType >
432 this->m_BI.GoToReverseBegin();
433 this->m_Index0 = this->m_EndIndex0 - 1;
434 SetIndexInternal( this->m_Index0 );
440 return this->m_BI.IsAtReverseEnd();
464 template<
typename TPixel,
unsigned int VImageDimension,
typename CounterType >
498 #endif // itkRLEImageConstIterator_h
typename ImageType::IndexValueType IndexValueType
virtual void SetRegion(const RegionType ®ion)
bool operator!=(const Self &it) const
bool operator==(const Self &it) const
typename ImageType::SizeType SizeType
static constexpr unsigned int ImageIteratorDimension
unsigned long SizeValueType
Self & operator=(const Self &it)
ImageType::ConstWeakPointer m_Image
typename itk::Image< RLLine, VImageDimension-1 > BufferType
ImageConstIteratorWithIndex(const ImageType *ptr, const RegionType ®ion)
const IndexType GetIndex() const
ImageConstIteratorWithOnlyIndex()
typename TImage::PixelType PixelType
typename ImageType::RegionType RegionType
IndexValueType m_EndIndex0
itkTypeMacroNoParent(ImageConstIterator)
ImageConstIteratorWithIndex()
SizeValueType m_RealIndex
Implements a weak reference to an object.
virtual void SetIndex(const IndexType &ind)
const RLLine * m_RunLengthLine
const ImageType * GetImage() const
bool operator>=(const Self &it) const
A multi-dimensional image iterator templated over image type.
Self & operator=(const Self &it)
A base class for multi-dimensional iterators templated over image type that are designed to efficient...
std::vector< RLSegment > RLLine
ImageConstIteratorWithOnlyIndex(const ImageType *ptr, const RegionType ®ion)
virtual ~ImageConstIterator()
const IndexType GetIndex() const
typename ImageType::PixelType PixelType
ImageBaseType::SizeType SizeType
const InternalPixelType * m_Buffer
A base class for multi-dimensional iterators templated over image type that are designed to provide o...
ImageBaseType::IndexType IndexType
const PixelType & Value() const
signed long IndexValueType
typename TImage::IndexType IndexType
bool IsAtBegin(void) const
TImage::ConstWeakPointer m_Image
typename ImageType::OffsetType OffsetType
BufferType::Pointer m_Buffer
static unsigned int GetImageIteratorDimension()
typename ImageType::RLLine RLLine
typename TImage::RegionType RegionType
ImageConstIteratorWithIndex(const ImageConstIteratorWithIndex &it)
bool operator>(const Self &it) const
typename TImage::RegionType RegionType
void SetIndex(const IndexValueType val[VDimension])
bool operator<(const Self &it) const
typename ImageType::BufferType BufferType
IndexValueType m_SegmentRemainder
PixelType Get(void) const
virtual void SetIndexInternal(const IndexValueType ind0)
typename Superclass::OffsetType OffsetType
const PixelType & Value(void) const
const IndexValueType * GetIndex() const
typename ImageType::IndexType IndexType
Run-Length Encoded image. It saves memory for label images at the expense of processing times...
typename TImage::RegionType RegionType
ImageConstIteratorWithOnlyIndex(const ImageConstIteratorWithOnlyIndex &it)
typename ImageType::InternalPixelType InternalPixelType
ImageBaseType::RegionType RegionType
void SetIndex(const IndexType &index)
ImageConstIterator(const Self &it)
virtual void SetRegion(const RegionType ®ion)
ImageConstIterator(const ImageType *ptr, const RegionType ®ion)
bool operator<=(const Self &it) const
const RegionType GetRegion() const
IndexValueType m_BeginIndex0
const ImageType * GetImage() const