11 #ifndef itkVectorImageRegionIterator_h 12 #define itkVectorImageRegionIterator_h 14 #include "itkImageRegionConstIterator.h" 15 #include "itkImageRegionIterator.h" 17 #include "itkVectorImage.h" 18 #include "itkVariableLengthVector.h" 33 template<
typename TImage >
45 TImage::ImageDimension);
53 typedef typename Superclass::SizeType
SizeType;
65 #ifdef ITK_USE_CONCEPT_CHECKING 66 itkConceptMacro( SameTypeCheck,
67 ( itk::Concept::SameType< ImageType, VectorImage<InternalPixelType, ImageIteratorDimension> > ) );
68 itkConceptMacro( SameTypeCheck2,
69 ( itk::Concept::SameType< PixelType, PixelVectorType> ) );
111 typename RegionType::SizeType regionSize = this->m_Region.GetSize();
112 typename RegionType::IndexType regionIndex = this->m_Region.GetIndex();
115 SizeType size = ptr->GetLargestPossibleRegion().GetSize();
116 const typename ImageType::OffsetValueType* offsetTable = ptr->GetOffsetTable();
127 Superclass::operator=(it);
137 Superclass::SetRegion(regionInput);
140 typename RegionType::SizeType sizeInput = regionInput.GetSize();
141 typename RegionType::IndexType indexInput = regionInput.GetIndex();
145 this->m_Region.SetIndex(indexInput);
146 this->m_Region.SetSize(sizeInput);
148 if ( region.GetNumberOfPixels() > 0 )
150 const RegionType & bufferedRegion = this->m_Image->GetBufferedRegion();
151 itkAssertOrThrowMacro( ( bufferedRegion.IsInside(this->m_Region) ),
152 "Region " << this->m_Region <<
" is outside of buffered region " << bufferedRegion );
156 this->m_Offset = this->m_Image->ComputeOffset( this->m_Region.GetIndex() );
157 this->m_BeginOffset = this->m_Offset;
163 if ( this->m_Region.GetNumberOfPixels() == 0 )
166 this->m_EndOffset = this->m_BeginOffset;
170 IndexType ind( this->m_Region.GetIndex() );
171 SizeType size( this->m_Region.GetSize() );
175 ind[i] += (
static_cast< IndexValueType
>( size[i] ) - 1 );
179 this->m_EndOffset = this->m_Image->ComputeOffset(ind);
186 void SetVector(
const PixelVectorType & value,
const int offIndex=0)
const 190 this->m_PixelAccessorFunctor.Set(*( const_cast< InternalPixelType * >(
191 this->m_Buffer + this->m_Offset ) ), value);
195 int numberOfComponens = this->m_Image->GetNumberOfComponentsPerPixel();
196 InternalPixelType* p =
const_cast<InternalPixelType*
>(this->m_Buffer + numberOfComponens*this->m_Offset);
207 void GetVector(PixelVectorType& vec,
const int offIndex=0)
const 211 vec = this->m_PixelAccessorFunctor.Get( *( this->m_Buffer + this->m_Offset ) );
216 int numberOfComponens = this->m_Image->GetNumberOfComponentsPerPixel();
217 InternalPixelType* p =
const_cast<InternalPixelType*
>(this->m_Buffer + numberOfComponens*this->m_Offset);
234 Self &
operator=(
const ImageRegionIterator< TImage > & it);
244 template <
typename TPixel,
unsigned int VImageDimension>
260 typedef ImageRegionIterator< Image<TPixel, VImageDimension> >
Superclass;
276 #ifdef ITK_USE_CONCEPT_CHECKING 277 itkConceptMacro( SameTypeCheck,
278 ( itk::Concept::SameType< ImageType, Image<InternalPixelType, VImageDimension> > ) );
298 m_VolumeSize = it.m_VolumeSize;
308 m_VectorAxis = (vectorAxis==-1) ? Superclass::ImageDimension-1 : vectorAxis;
312 typename RegionType::SizeType regionSize = this->m_Region.GetSize();
313 typename RegionType::IndexType regionIndex = this->m_Region.GetIndex();
316 SizeType size = ptr->GetLargestPossibleRegion().GetSize();
317 const typename ImageType::OffsetValueType* offsetTable = ptr->GetOffsetTable();
327 Superclass::operator=(it);
328 m_VolumeSize = it.m_VolumeSize;
337 typename RegionType::SizeType sizeInput = regionInput.GetSize();
338 typename RegionType::IndexType indexInput = regionInput.GetIndex();
340 for (
int i = 0; i < VImageDimension-1; ++i )
341 m_VolumeSize *= sizeInput[i];
347 this->m_Region.SetIndex(indexInput);
348 this->m_Region.SetSize(sizeInput);
350 if ( this->m_Region.GetNumberOfPixels() > 0 )
352 const RegionType & bufferedRegion = this->m_Image->GetBufferedRegion();
353 itkAssertOrThrowMacro( ( bufferedRegion.IsInside(this->m_Region) ),
354 "Region " << this->m_Region <<
" is outside of buffered region " << bufferedRegion );
358 this->m_Offset = this->m_Image->ComputeOffset( this->m_Region.GetIndex() );
359 this->m_BeginOffset = this->m_Offset;
365 if ( this->m_Region.GetNumberOfPixels() == 0 )
368 this->m_EndOffset = this->m_BeginOffset;
372 IndexType ind( this->m_Region.GetIndex() );
373 SizeType size( this->m_Region.GetSize() );
374 for (
unsigned int i = 0; i < VImageDimension; ++i )
377 ind[i] += (
static_cast< IndexValueType
>( size[i] ) - 1 );
381 this->m_EndOffset = this->m_Image->ComputeOffset(ind);
388 void SetVector(
const PixelVectorType & value,
const int offIndex=0)
390 int off=offIndex*m_VolumeSize;
393 this->m_PixelAccessorFunctor.Set(
394 *( const_cast< InternalPixelType * >( this->m_Buffer ) + this->m_Offset + off), value[i]);
400 void GetVector(PixelVectorType& vec,
const int offIndex=0)
const 403 int off=offIndex*m_VolumeSize;
406 vec[i] = this->m_PixelAccessorFunctor.Get( *( this->m_Buffer + this->m_Offset + off ) );
417 Self &
operator=(
const ImageRegionIterator< ImageType > & it);
Superclass::InternalPixelType InternalPixelType
Superclass::PixelContainerPointer PixelContainerPointer
Superclass::PixelContainerPointer PixelContainerPointer
Superclass::RegionType RegionType
void SetVector(const PixelVectorType &value, const int offIndex=0) const
Superclass::SizeType SizeType
ImageRegionIterator< Image< TPixel, VImageDimension > > Superclass
Superclass::ImageType ImageType
~VectorImageRegionIterator()
A multi-dimensional iterator templated over image type.
VariableLengthVector< InternalPixelType > PixelVectorType
VectorImageRegionIterator(ImageType *ptr, const RegionType ®ion, int vectorAxis=-1)
VectorImageRegionIterator(TImage *ptr, const RegionType ®ion, int vectorAxis=-1)
VectorImageRegionIterator Self
void SetRegion(const RegionType ®ionInput)
VectorImageRegionIterator()
Superclass::PixelContainer PixelContainer
Superclass::SizeType SizeType
Self & operator=(const Self &it)
Superclass::AccessorType AccessorType
VariableLengthVector< InternalPixelType > PixelVectorType
void SetVector(const PixelVectorType &value, const int offIndex=0)
Superclass::IndexType IndexType
Superclass::RegionType RegionType
void GetVector(PixelVectorType &vec, const int offIndex=0) const
Superclass::IndexType IndexType
~VectorImageRegionIterator()
void GetVector(PixelVectorType &vec, const int offIndex=0) const
OffsetValueType m_VectorStride
Superclass::ImageType ImageType
void SetRegion(const RegionType ®ionInput)
OffsetValueType m_VolumeSize
Superclass::InternalPixelType InternalPixelType
Superclass::PixelType PixelType
VectorImageRegionIterator(const Self &it)
static const unsigned int ImageIteratorDimension
Superclass::PixelType PixelType
Superclass::PixelContainer PixelContainer
VectorImageRegionIterator(const Self &it)
ImageRegionIterator< TImage > Superclass
Superclass::OffsetType OffsetType
VectorImageRegionIterator Self
OffsetValueType m_VectorStride
Superclass::AccessorType AccessorType
Superclass::OffsetType OffsetType
VectorImageRegionIterator()
Self & operator=(const Self &it)