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->Self::SetRegions(region);
346 return m_OffsetTable;
362 this->GetBufferedRegion().GetIndex(), ind, m_OffsetTable, offset);
424 SetSpacing(
const SpacingType & spacing);
426 SetSpacing(
const double spacing[VImageDimension]);
428 SetSpacing(
const float spacing[VImageDimension]);
446 template <
typename TCoordRep>
453 for (
unsigned int i = 0; i < VImageDimension; ++i)
456 for (
unsigned int j = 0; j < VImageDimension; ++j)
458 sum += this->m_PhysicalPointToIndex[i][j] * (
point[j] - this->m_Origin[j]);
460 index[i] = Math::RoundHalfIntegerUp<IndexValueType>(sum);
469 template <
typename TCoordRep>
473 index = TransformPhysicalPointToIndex(
point);
476 const bool isInside = this->GetLargestPossibleRegion().IsInside(index);
495 template <
typename TIndexRep,
typename TCoordRep>
502 for (
unsigned int k = 0; k < VImageDimension; ++k)
504 cvector[k] =
point[k] - this->m_Origin[k];
506 cvector = m_PhysicalPointToIndex * cvector;
507 for (
unsigned int i = 0; i < VImageDimension; ++i)
509 index[i] = static_cast<TIndexRep>(cvector[i]);
518 template <
typename TCoordRep,
typename TIndexRep>
523 index = TransformPhysicalPointToContinuousIndex<TIndexRep>(
point);
526 const bool isInside = this->GetLargestPossibleRegion().IsInside(index);
534 template <
typename TCoordRep,
typename TIndexRep>
539 for (
unsigned int r = 0; r < VImageDimension; ++r)
542 for (
unsigned int c = 0; c < VImageDimension; ++c)
544 sum += this->m_IndexToPhysicalPoint(r, c) * index[c];
546 point[r] = sum + this->m_Origin[r];
555 template <
typename TCoordRep,
typename TIndexRep>
560 TransformContinuousIndexToPhysicalPoint(index,
point);
570 template <
typename TCoordRep>
574 for (
unsigned int i = 0; i < VImageDimension; ++i)
576 point[i] = this->m_Origin[i];
577 for (
unsigned int j = 0; j < VImageDimension; ++j)
579 point[i] += m_IndexToPhysicalPoint[i][j] * index[j];
590 template <
typename TCoordRep>
595 TransformIndexToPhysicalPoint(index,
point);
614 template <
typename TCoordRep>
623 for (
unsigned int i = 0; i < VImageDimension; ++i)
627 for (
unsigned int j = 0; j < VImageDimension; ++j)
629 sum += direction[i][j] * inputGradient[j];
631 outputGradient[i] = static_cast<TCoordRep>(sum);
641 template <
typename TVector>
645 TVector outputGradient;
646 TransformLocalVectorToPhysicalVector(inputGradient, outputGradient);
647 return outputGradient;
664 template <
typename TCoordRep>
669 const DirectionType & inverseDirection = this->GetInverseDirection();
673 for (
unsigned int i = 0; i < VImageDimension; ++i)
677 for (
unsigned int j = 0; j < VImageDimension; ++j)
679 sum += inverseDirection[i][j] * inputGradient[j];
681 outputGradient[i] = static_cast<TCoordRep>(sum);
691 template <
typename TVector>
695 TVector outputGradient;
696 TransformPhysicalVectorToLocalVector(inputGradient, outputGradient);
697 return outputGradient;
711 CopyInformation(
const DataObject * data)
override;
724 Graft(
const Self * image);
734 UpdateOutputInformation()
override;
744 UpdateOutputData()
override;
750 SetRequestedRegionToLargestPossibleRegion()
override;
762 RequestedRegionIsOutsideOfTheBufferedRegion()
override;
773 VerifyRequestedRegion()
override;
794 GetNumberOfComponentsPerPixel()
const;
796 SetNumberOfComponentsPerPixel(
unsigned int);
803 PrintSelf(std::ostream & os,
Indent indent)
const override;
810 ComputeOffsetTable();
818 ComputeIndexToPhysicalPointMatrices();
841 InitializeBufferedRegion();
858 Self::GetBufferedRegion().GetIndex(), ind, m_OffsetTable, offset);
896 #ifndef ITK_MANUAL_INSTANTIATION
897 # include "itkImageBase.hxx"