28 #ifndef itkImageBase_h
29 #define itkImageBase_h
41 #include <vxl_version.h>
42 #include "vnl/vnl_matrix_fixed.hxx"
104 template<
unsigned int VImageDimension = 2 >
123 using ImageDimensionType =
unsigned int;
129 static constexpr ImageDimensionType ImageDimension = VImageDimension;
165 void Initialize()
override;
169 {
return VImageDimension; }
176 virtual void SetOrigin(
const double origin[VImageDimension]);
177 virtual void SetOrigin(
const float origin[VImageDimension]);
221 itkGetConstReferenceMacro(Spacing, SpacingType);
227 itkGetConstReferenceMacro(Origin,
PointType);
236 virtual void Allocate(
bool initialize=
false);
244 virtual void SetLargestPossibleRegion(
const RegionType & region);
253 {
return m_LargestPossibleRegion; }
258 virtual void SetBufferedRegion(
const RegionType & region);
264 {
return m_BufferedRegion; }
273 virtual void SetRequestedRegion(
const RegionType & region);
282 void SetRequestedRegion(
const DataObject *data )
override;
289 {
return m_RequestedRegion; }
296 this->SetLargestPossibleRegion(region);
297 this->SetBufferedRegion(region);
298 this->SetRequestedRegion(region);
306 this->SetLargestPossibleRegion(region);
307 this->SetBufferedRegion(region);
308 this->SetRequestedRegion(region);
401 virtual void SetSpacing(
const SpacingType & spacing);
402 virtual void SetSpacing(
const double spacing[VImageDimension]);
403 virtual void SetSpacing(
const float spacing[VImageDimension]);
410 template<
typename TCoordRep >
415 for (
unsigned int i = 0; i < VImageDimension; i++ )
418 for (
unsigned int j = 0; j < VImageDimension; j++ )
420 sum += this->m_PhysicalPointToIndex[i][j] * ( point[j] - this->m_Origin[j] );
422 index[i] = Math::RoundHalfIntegerUp< IndexValueType >(sum);
425 const bool isInside = this->GetLargestPossibleRegion().IsInside(index);
434 template<
typename TCoordRep,
typename TIndexRep >
441 for (
unsigned int k = 0; k < VImageDimension; ++k )
443 cvector[k] = point[k] - this->m_Origin[k];
445 cvector = m_PhysicalPointToIndex * cvector;
446 for (
unsigned int i = 0; i < VImageDimension; ++i )
448 index[i] =
static_cast< TIndexRep
>( cvector[i] );
452 const bool isInside = this->GetLargestPossibleRegion().IsInside(index);
461 template<
typename TCoordRep,
typename TIndexRep >
466 for (
unsigned int r = 0; r < VImageDimension; ++r )
469 for (
unsigned int c = 0; c < VImageDimension; ++c )
471 sum += this->m_IndexToPhysicalPoint(r, c) * index[c];
473 point[r] = sum + this->m_Origin[r];
483 template<
typename TCoordRep >
488 for (
unsigned int i = 0; i < VImageDimension; ++i )
490 point[i] = this->m_Origin[i];
491 for (
unsigned int j = 0; j < VImageDimension; ++j )
493 point[i] += m_IndexToPhysicalPoint[i][j] * index[j];
513 template<
typename TCoordRep >
522 for (
unsigned int i = 0; i < VImageDimension; ++i )
526 for (
unsigned int j = 0; j < VImageDimension; ++j )
528 sum += direction[i][j] * inputGradient[j];
530 outputGradient[i] =
static_cast< TCoordRep
>( sum );
546 template<
typename TCoordRep >
551 const DirectionType & inverseDirection = this->GetInverseDirection();
555 for (
unsigned int i = 0; i < VImageDimension; ++i )
559 for (
unsigned int j = 0; j < VImageDimension; ++j )
561 sum += inverseDirection[i][j] * inputGradient[j];
563 outputGradient[i] =
static_cast< TCoordRep
>( sum );
576 void CopyInformation(
const DataObject *data)
override;
588 virtual void Graft(
const Self *data);
597 void UpdateOutputInformation()
override;
606 void UpdateOutputData()
override;
611 void SetRequestedRegionToLargestPossibleRegion()
override;
622 bool RequestedRegionIsOutsideOfTheBufferedRegion()
override;
632 bool VerifyRequestedRegion()
override;
652 virtual unsigned int GetNumberOfComponentsPerPixel()
const;
653 virtual void SetNumberOfComponentsPerPixel(
unsigned int);
659 void PrintSelf(std::ostream & os,
Indent indent)
const override;
665 void ComputeOffsetTable();
672 virtual void ComputeIndexToPhysicalPointMatrices();
692 virtual void InitializeBufferedRegion();
747 template <
typename TSpacingValue>
764 #ifndef ITK_MANUAL_INSTANTIATION
765 #include "itkImageBase.hxx"
void SetSize(const SizeType &size)
virtual void SetRegions(const RegionType ®ion)
double SpacePrecisionType
const OffsetValueType * GetOffsetTable() const
static void ComputeOffset(const IndexType &bufferedRegionIndex, const IndexType &index, const OffsetValueType offsetTable[], OffsetValueType &offset)
SpacePrecisionType SpacingValueType
Define numeric traits for std::vector.
RegionType m_BufferedRegion
unsigned long SizeValueType
virtual const RegionType & GetLargestPossibleRegion() const
IndexType FastComputeIndex(OffsetValueType offset) const
An image region represents a structured region of data.
RegionType m_RequestedRegion
void TransformIndexToPhysicalPoint(const IndexType &index, Point< TCoordRep, VImageDimension > &point) const
class ITK_FORWARD_EXPORT DataObject
DirectionType m_IndexToPhysicalPoint
static void ComputeIndex(const IndexType &bufferedRegionIndex, OffsetValueType offset, const OffsetValueType offsetTable[], IndexType &index)
DirectionType m_InverseDirection
Simulate a standard C array with copy semnatics.
virtual void SetRegions(const SizeType &size)
IndexType ComputeIndex(OffsetValueType offset) const
DirectionType m_Direction
bool TransformPhysicalPointToContinuousIndex(const Point< TCoordRep, VImageDimension > &point, ContinuousIndex< TIndexRep, VImageDimension > &index) const
Get the continuous index from a physical point.
virtual const RegionType & GetBufferedRegion() const
ImageBaseType::DirectionType DirectionType
signed long IndexValueType
void TransformLocalVectorToPhysicalVector(const FixedArray< TCoordRep, VImageDimension > &inputGradient, FixedArray< TCoordRep, VImageDimension > &outputGradient) const
Represent a n-dimensional size (bounds) of a n-dimensional image.
Represent a n-dimensional offset between two n-dimensional indexes of n-dimensional image...
OffsetValueType FastComputeOffset(const IndexType &ind) const
void CastFrom(const Vector< TCoordRepB, NVectorDimension > &pa)
typename SizeType::SizeValueType SizeValueType
void TransformPhysicalVectorToLocalVector(const FixedArray< TCoordRep, VImageDimension > &inputGradient, FixedArray< TCoordRep, VImageDimension > &outputGradient) const
static unsigned int GetImageDimension()
typename OffsetType::OffsetValueType OffsetValueType
class ITK_TEMPLATE_EXPORT ImageBase
void InternalSetSpacing(const TSpacingValue spacing[VImageDimension])
Base class for templated image classes.
A templated class holding a point in n-Dimensional image space.
void TransformContinuousIndexToPhysicalPoint(const ContinuousIndex< TIndexRep, VImageDimension > &index, Point< TCoordRep, VImageDimension > &point) const
DirectionType m_PhysicalPointToIndex
virtual const RegionType & GetRequestedRegion() const
SpacePrecisionType PointValueType
Control indentation during Print() invocation.
ImageBaseType::PointType PointType
void InternalSetSpacing(const SpacingValueType spacing[VImageDimension])
OffsetValueType ComputeOffset(const IndexType &ind) const
const IndexValueType * GetIndex() const
ValueType * GetDataPointer()
Base class for most ITK classes.
ImageBaseType::RegionType RegionType
typename IndexType::IndexValueType IndexValueType
signed long OffsetValueType
Base class for all data objects in ITK.
RegionType m_LargestPossibleRegion
bool TransformPhysicalPointToIndex(const Point< TCoordRep, VImageDimension > &point, IndexType &index) const