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;
166 Initialize()
override;
172 return VImageDimension;
181 SetOrigin(
const double origin[VImageDimension]);
183 SetOrigin(
const float origin[VImageDimension]);
228 itkGetConstReferenceMacro(Spacing, SpacingType);
234 itkGetConstReferenceMacro(Origin,
PointType);
244 Allocate(
bool initialize =
false);
253 SetLargestPossibleRegion(
const RegionType & region);
264 return m_LargestPossibleRegion;
279 return m_BufferedRegion;
290 SetRequestedRegion(
const RegionType & region);
300 SetRequestedRegion(
const DataObject * data)
override;
309 return m_RequestedRegion;
318 this->SetLargestPossibleRegion(region);
319 this->SetBufferedRegion(region);
320 this->SetRequestedRegion(region);
330 this->SetLargestPossibleRegion(region);
331 this->SetBufferedRegion(region);
332 this->SetRequestedRegion(region);
348 return m_OffsetTable;
364 this->GetBufferedRegion().GetIndex(), ind, m_OffsetTable, offset);
426 SetSpacing(
const SpacingType & spacing);
428 SetSpacing(
const double spacing[VImageDimension]);
430 SetSpacing(
const float spacing[VImageDimension]);
448 template <
typename TCoordRep>
455 for (
unsigned int i = 0; i < VImageDimension; i++)
458 for (
unsigned int j = 0; j < VImageDimension; j++)
460 sum += this->m_PhysicalPointToIndex[i][j] * (point[j] - this->m_Origin[j]);
462 index[i] = Math::RoundHalfIntegerUp<IndexValueType>(sum);
471 template <
typename TCoordRep>
475 index = TransformPhysicalPointToIndex(point);
478 const bool isInside = this->GetLargestPossibleRegion().IsInside(index);
497 template <
typename TIndexRep,
typename TCoordRep>
504 for (
unsigned int k = 0; k < VImageDimension; ++k)
506 cvector[k] = point[k] - this->m_Origin[k];
508 cvector = m_PhysicalPointToIndex * cvector;
509 for (
unsigned int i = 0; i < VImageDimension; ++i)
511 index[i] = static_cast<TIndexRep>(cvector[i]);
520 template <
typename TCoordRep,
typename TIndexRep>
525 index = TransformPhysicalPointToContinuousIndex<TIndexRep>(point);
528 const bool isInside = this->GetLargestPossibleRegion().IsInside(index);
536 template <
typename TCoordRep,
typename TIndexRep>
541 for (
unsigned int r = 0; r < VImageDimension; ++r)
544 for (
unsigned int c = 0; c < VImageDimension; ++c)
546 sum += this->m_IndexToPhysicalPoint(r, c) * index[c];
548 point[r] = sum + this->m_Origin[r];
557 template <
typename TCoordRep,
typename TIndexRep>
562 TransformContinuousIndexToPhysicalPoint(index, point);
572 template <
typename TCoordRep>
576 for (
unsigned int i = 0; i < VImageDimension; ++i)
578 point[i] = this->m_Origin[i];
579 for (
unsigned int j = 0; j < VImageDimension; ++j)
581 point[i] += m_IndexToPhysicalPoint[i][j] * index[j];
592 template <
typename TCoordRep>
597 TransformIndexToPhysicalPoint(index, point);
616 template <
typename TCoordRep>
625 for (
unsigned int i = 0; i < VImageDimension; ++i)
629 for (
unsigned int j = 0; j < VImageDimension; ++j)
631 sum += direction[i][j] * inputGradient[j];
633 outputGradient[i] = static_cast<TCoordRep>(sum);
643 template <
typename TVector>
647 TVector outputGradient;
648 TransformLocalVectorToPhysicalVector(inputGradient, outputGradient);
649 return outputGradient;
666 template <
typename TCoordRep>
671 const DirectionType & inverseDirection = this->GetInverseDirection();
675 for (
unsigned int i = 0; i < VImageDimension; ++i)
679 for (
unsigned int j = 0; j < VImageDimension; ++j)
681 sum += inverseDirection[i][j] * inputGradient[j];
683 outputGradient[i] = static_cast<TCoordRep>(sum);
693 template <
typename TVector>
697 TVector outputGradient;
698 TransformPhysicalVectorToLocalVector(inputGradient, outputGradient);
699 return outputGradient;
713 CopyInformation(
const DataObject * data)
override;
726 Graft(
const Self * image);
736 UpdateOutputInformation()
override;
746 UpdateOutputData()
override;
752 SetRequestedRegionToLargestPossibleRegion()
override;
764 RequestedRegionIsOutsideOfTheBufferedRegion()
override;
775 VerifyRequestedRegion()
override;
796 GetNumberOfComponentsPerPixel()
const;
798 SetNumberOfComponentsPerPixel(
unsigned int);
805 PrintSelf(std::ostream & os,
Indent indent)
const override;
812 ComputeOffsetTable();
820 ComputeIndexToPhysicalPointMatrices();
841 InitializeBufferedRegion();
858 Self::GetBufferedRegion().GetIndex(), ind, m_OffsetTable, offset);
896 #ifndef ITK_MANUAL_INSTANTIATION
897 # include "itkImageBase.hxx"