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);
473 template <
typename TCoordRep>
474 ITK_NODISCARD(
"Call the overload which has the point as the only parameter and returns the index")
475 bool TransformPhysicalPointToIndex(const
Point<TCoordRep, VImageDimension> &
point,
IndexType & index)
const
477 index = TransformPhysicalPointToIndex(
point);
480 const bool isInside = this->GetLargestPossibleRegion().IsInside(index);
499 template <
typename TIndexRep,
typename TCoordRep>
506 for (
unsigned int k = 0; k < VImageDimension; ++k)
508 cvector[k] =
point[k] - this->m_Origin[k];
510 cvector = m_PhysicalPointToIndex * cvector;
511 for (
unsigned int i = 0; i < VImageDimension; ++i)
513 index[i] = static_cast<TIndexRep>(cvector[i]);
526 template <
typename TCoordRep,
typename TIndexRep>
527 ITK_NODISCARD(
"Call the overload which has the point as the only parameter and returns the index")
528 bool TransformPhysicalPointToContinuousIndex(const
Point<TCoordRep, VImageDimension> &
point,
531 index = TransformPhysicalPointToContinuousIndex<TIndexRep>(
point);
534 const bool isInside = this->GetLargestPossibleRegion().IsInside(index);
542 template <
typename TCoordRep,
typename TIndexRep>
547 for (
unsigned int r = 0; r < VImageDimension; ++r)
550 for (
unsigned int c = 0; c < VImageDimension; ++c)
552 sum += this->m_IndexToPhysicalPoint(r, c) * index[c];
554 point[r] = sum + this->m_Origin[r];
563 template <
typename TCoordRep,
typename TIndexRep>
568 TransformContinuousIndexToPhysicalPoint(index,
point);
578 template <
typename TCoordRep>
582 for (
unsigned int i = 0; i < VImageDimension; ++i)
584 point[i] = this->m_Origin[i];
585 for (
unsigned int j = 0; j < VImageDimension; ++j)
587 point[i] += m_IndexToPhysicalPoint[i][j] * index[j];
598 template <
typename TCoordRep>
603 TransformIndexToPhysicalPoint(index,
point);
622 template <
typename TCoordRep>
631 for (
unsigned int i = 0; i < VImageDimension; ++i)
635 for (
unsigned int j = 0; j < VImageDimension; ++j)
637 sum += direction[i][j] * inputGradient[j];
639 outputGradient[i] = static_cast<TCoordRep>(sum);
649 template <
typename TVector>
650 [[nodiscard]] TVector
653 TVector outputGradient;
654 TransformLocalVectorToPhysicalVector(inputGradient, outputGradient);
655 return outputGradient;
672 template <
typename TCoordRep>
677 const DirectionType & inverseDirection = this->GetInverseDirection();
681 for (
unsigned int i = 0; i < VImageDimension; ++i)
685 for (
unsigned int j = 0; j < VImageDimension; ++j)
687 sum += inverseDirection[i][j] * inputGradient[j];
689 outputGradient[i] = static_cast<TCoordRep>(sum);
699 template <
typename TVector>
700 [[nodiscard]] TVector
703 TVector outputGradient;
704 TransformPhysicalVectorToLocalVector(inputGradient, outputGradient);
705 return outputGradient;
719 CopyInformation(
const DataObject * data)
override;
732 Graft(
const Self * image);
742 UpdateOutputInformation()
override;
752 UpdateOutputData()
override;
758 SetRequestedRegionToLargestPossibleRegion()
override;
770 RequestedRegionIsOutsideOfTheBufferedRegion()
override;
781 VerifyRequestedRegion()
override;
802 GetNumberOfComponentsPerPixel()
const;
804 SetNumberOfComponentsPerPixel(
unsigned int);
811 PrintSelf(std::ostream & os,
Indent indent)
const override;
818 ComputeOffsetTable();
826 ComputeIndexToPhysicalPointMatrices();
849 InitializeBufferedRegion();
866 Self::GetBufferedRegion().GetIndex(), ind, m_OffsetTable, offset);
904 #ifndef ITK_MANUAL_INSTANTIATION
905 # include "itkImageBase.hxx"