18#ifndef itkSliceSeriesSpecialCoordinatesImage_h
19#define itkSliceSeriesSpecialCoordinatesImage_h
52template <
typename TSliceImage,
54 typename TPixel =
typename TSliceImage::PixelType,
55 unsigned int VDimension = TSliceImage::ImageDimension + 1>
185 template <
typename TCoordRep,
typename TIndexRep>
193 IndexValueType upperIndex = lowerIndex + region.GetSize(sliceDimensionIndex) - 1;
197 if (transform ==
nullptr)
199 itkExceptionMacro(
"Inverse slice transform not available for index: " << lowerIndex);
201 lowerPoint = transform->TransformPoint(point);
202 int lowerSign =
Math::sgn(lowerPoint[sliceDimensionIndex]);
205 if (transform ==
nullptr)
207 itkExceptionMacro(
"Inverse slice transform not available for index: " << upperIndex);
209 upperPoint = transform->TransformPoint(point);
210 int upperSign =
Math::sgn(upperPoint[sliceDimensionIndex]);
216 nextPoint = lowerPoint;
218 else if (upperSign == 0)
221 nextPoint = upperPoint;
225 if (lowerSign == upperSign)
232 while (upperIndex - lowerIndex > 1)
234 nextIndex = lowerIndex + (upperIndex - lowerIndex) / 2;
236 nextPoint = transform->TransformPoint(point);
237 nextSign =
Math::sgn(nextPoint[sliceDimensionIndex]);
242 else if (nextSign == lowerSign)
244 lowerIndex = nextIndex;
245 lowerPoint = nextPoint;
249 upperIndex = nextIndex;
250 upperPoint = nextPoint;
257 const TCoordRep fraction =
258 -lowerPoint[sliceDimensionIndex] / (upperPoint[sliceDimensionIndex] - lowerPoint[sliceDimensionIndex]);
259 nextPoint[sliceDimensionIndex] = lowerIndex + fraction * (upperIndex - lowerIndex);
260 for (
unsigned int ii = 0; ii < SliceImageType::ImageDimension; ++ii)
262 nextPoint[ii] = lowerPoint[ii] + fraction * (upperPoint[ii] - lowerPoint[ii]);
267 nextPoint[sliceDimensionIndex] = nextIndex;
270 typename SliceImageType::PointType slicePoint;
271 for (
unsigned int ii = 0; ii < SliceImageType::ImageDimension; ++ii)
273 slicePoint[ii] = nextPoint[ii];
277 for (
unsigned int ii = 0; ii < SliceImageType::ImageDimension; ++ii)
279 index[ii] = sliceIndex[ii];
281 index[sliceDimensionIndex] = nextPoint[sliceDimensionIndex];
283 const bool isInside = region.IsInside(index);
302 template <
typename TIndexRep,
typename TCoordRep>
315 template <
typename TCoordRep>
322 IndexValueType upperIndex = lowerIndex + region.GetSize(sliceDimensionIndex) - 1;
326 if (transform ==
nullptr)
328 itkExceptionMacro(
"Inverse slice transform not available for index: " << lowerIndex);
330 lowerPoint = transform->TransformPoint(point);
331 int lowerSign =
Math::sgn(lowerPoint[sliceDimensionIndex]);
334 if (transform ==
nullptr)
336 itkExceptionMacro(
"Inverse slice transform not available for index: " << upperIndex);
338 upperPoint = transform->TransformPoint(point);
339 int upperSign =
Math::sgn(upperPoint[sliceDimensionIndex]);
345 nextPoint = lowerPoint;
347 else if (upperSign == 0)
350 nextPoint = upperPoint;
354 if (lowerSign == upperSign)
361 while (upperIndex - lowerIndex > 1)
363 nextIndex = lowerIndex + (upperIndex - lowerIndex) / 2;
365 nextPoint = transform->TransformPoint(point);
366 nextSign =
Math::sgn(nextPoint[sliceDimensionIndex]);
371 else if (nextSign == lowerSign)
373 lowerIndex = nextIndex;
374 lowerPoint = nextPoint;
378 upperIndex = nextIndex;
379 upperPoint = nextPoint;
386 const TCoordRep fraction =
387 -lowerPoint[sliceDimensionIndex] / (upperPoint[sliceDimensionIndex] - lowerPoint[sliceDimensionIndex]);
388 nextPoint[sliceDimensionIndex] = lowerIndex + fraction * (upperIndex - lowerIndex);
389 for (
unsigned int ii = 0; ii < SliceImageType::ImageDimension; ++ii)
391 nextPoint[ii] = lowerPoint[ii] + fraction * (upperPoint[ii] - lowerPoint[ii]);
396 nextPoint[sliceDimensionIndex] = nextIndex;
399 typename SliceImageType::PointType slicePoint;
400 for (
unsigned int ii = 0; ii < SliceImageType::ImageDimension; ++ii)
402 slicePoint[ii] = nextPoint[ii];
404 typename SliceImageType::IndexType sliceIndex = this->
m_SliceImage->TransformPhysicalPointToIndex(slicePoint);
405 for (
unsigned int ii = 0; ii < SliceImageType::ImageDimension; ++ii)
407 index[ii] = sliceIndex[ii];
411 const bool isInside = region.IsInside(index);
431 template <
typename TCoordRep>
444 template <
typename TCoordRep,
typename TIndexRep>
451 for (
unsigned int ii = 0; ii < SliceImageType::ImageDimension; ++ii)
453 sliceIndex[ii] = index[ii];
456 this->
m_SliceImage->TransformContinuousIndexToPhysicalPoint(sliceIndex, slicePoint);
457 for (
unsigned int ii = 0; ii < SliceImageType::ImageDimension; ++ii)
459 point[ii] += slicePoint[ii];
462 CoordRepPointType lowerPoint;
466 if (transform !=
nullptr)
468 lowerPoint = transform->TransformPoint(point);
473 const IndexType & largestIndex = largestRegion.GetIndex();
480 const SizeType & largestSize = largestRegion.GetSize();
490 CoordRepPointType upperPoint;
491 if (transform !=
nullptr)
493 upperPoint = transform->TransformPoint(point);
498 const IndexType & largestIndex = largestRegion.GetIndex();
505 const SizeType & largestSize = largestRegion.GetSize();
517 point[ii] = lowerPoint[ii] + fraction * (upperPoint[ii] - lowerPoint[ii]);
525 template <
typename TCoordRep,
typename TIndexRep>
539 template <
typename TCoordRep>
544 typename SliceImageType::IndexType sliceIndex;
545 for (
unsigned int ii = 0; ii < SliceImageType::ImageDimension; ++ii)
547 sliceIndex[ii] = index[ii];
550 this->
m_SliceImage->TransformIndexToPhysicalPoint(sliceIndex, slicePoint);
551 for (
unsigned int ii = 0; ii < SliceImageType::ImageDimension; ++ii)
553 point[ii] += slicePoint[ii];
556 if (transform !=
nullptr)
558 point = transform->TransformPoint(point);
562 const IndexType & largestIndex = largestRegion.GetIndex();
567 point = transform->TransformPoint(point);
571 const SizeType & largestSize = largestRegion.GetSize();
578 point = transform->TransformPoint(point);
587 template <
typename TCoordRep>
596 template <
typename TCoordRep>
601 template <
typename TCoordRep>
622 NeighborhoodAccessorFunctorType
629 const NeighborhoodAccessorFunctorType
662#ifndef ITK_MANUAL_INSTANTIATION
663# include "itkSliceSeriesSpecialCoordinatesImage.hxx"
A templated class holding a point in n-Dimensional image space.
Base class for all data objects in ITK.
virtual void Graft(const DataObject *)
Provides a common API for pixel accessors for Image and VectorImage.
Give access to partial aspects a type.
Simulate a standard C array with copy semantics.
void Fill(const ValueType &)
Base class for templated image classes.
typename IndexType::IndexValueType IndexValueType
virtual const RegionType & GetLargestPossibleRegion() const
typename SizeType::SizeValueType SizeValueType
Defines an itk::Image front-end to a standard C-array.
SmartPointer< Self > Pointer
SmartPointer< const Self > ConstPointer
Control indentation during Print() invocation.
Provides accessor interfaces to Get pixels and is meant to be used on pointers contained within Neigh...
A templated class holding a geometric point in n-Dimensional space.
SliceImageType::Pointer m_SliceImage
typename Superclass::SpacingType SpacingType
DefaultPixelAccessorFunctor< Self > AccessorFunctorType
typename Superclass::OffsetType OffsetType
void SetSliceTransform(IndexValueType sliceIndex, TransformType *transform)
void TransformIndexToPhysicalPoint(const IndexType &index, Point< TCoordRep, VDimension > &point) const
typename Superclass::IndexValueType IndexValueType
NeighborhoodAccessorFunctorType GetNeighborhoodAccessor()
void TransformPhysicalVectorToLocalVector(const FixedArray< TCoordRep, VDimension > &, FixedArray< TCoordRep, VDimension > &) const
const TransformType * GetSliceInverseTransform(IndexValueType sliceIndex) const
bool TransformPhysicalPointToIndex(const Point< TCoordRep, VDimension > &point, IndexType &index) const
typename Superclass::IOPixelType IOPixelType
SmartPointer< const Self > ConstPointer
SliceTransformsType::Pointer m_SliceTransforms
ImportImageContainer< SizeValueType, PixelType > PixelContainer
SpecialCoordinatesImage< TPixel, VDimension > Superclass
typename PixelContainer::ConstPointer PixelContainerConstPointer
typename Superclass::IndexType IndexType
AccessorType GetPixelAccessor(void)
SliceSeriesSpecialCoordinatesImage()
typename Superclass::RegionType RegionType
SliceTransformsType::Pointer m_SliceInverseTransforms
TSliceImage SliceImageType
typename Superclass::SizeValueType SizeValueType
const AccessorType GetPixelAccessor(void) const
virtual void SetLargestPossibleRegion(const RegionType ®ion) override
SliceSeriesSpecialCoordinatesImage Self
void Graft(const ImageBase< VDimension > *image) override
~SliceSeriesSpecialCoordinatesImage() override=default
NeighborhoodAccessorFunctor< Self > NeighborhoodAccessorFunctorType
void TransformLocalVectorToPhysicalVector(FixedArray< TCoordRep, VDimension > &) const
virtual void PrintSelf(std::ostream &os, Indent indent) const override
SliceSeriesSpecialCoordinatesImage(const Self &)
SmartPointer< Self > Pointer
WeakPointer< const Self > ConstWeakPointer
void operator=(const Self &)
typename Superclass::PointType PointType
Point< TCoordRep, VDimension > TransformIndexToPhysicalPoint(const IndexType &index) const
static constexpr unsigned int ImageDimension
IndexType TransformPhysicalPointToIndex(const Point< TCoordRep, VDimension > &point) const
typename PixelContainer::Pointer PixelContainerPointer
bool TransformPhysicalPointToContinuousIndex(const Point< TCoordRep, VDimension > &point, ContinuousIndex< TIndexRep, VDimension > &index) const
Get the continuous index from a physical point.
const TransformType * GetSliceTransform(IndexValueType sliceIndex) const
Point< TCoordRep, VDimension > TransformContinuousIndexToPhysicalPoint(const ContinuousIndex< TIndexRep, VDimension > &index) const
const NeighborhoodAccessorFunctorType GetNeighborhoodAccessor() const
virtual void CopyInformation(const DataObject *data) override
void TransformContinuousIndexToPhysicalPoint(const ContinuousIndex< TIndexRep, VDimension > &index, Point< TCoordRep, VDimension > &point) const
typename Superclass::SizeType SizeType
VectorContainer< IdentifierType, typename TransformType::Pointer > SliceTransformsType
ContinuousIndex< TIndexRep, VDimension > TransformPhysicalPointToContinuousIndex(const Point< TCoordRep, VDimension > &point) const
Returns the continuous index from a physical point.
DefaultPixelAccessor< PixelType > AccessorType
Implements transparent reference counting.
Size< VImageDimension > SizeType
Point< PointValueType, VImageDimension > PointType
ImageRegion< VImageDimension > RegionType
SpecialCoordinatesImage()=default
Offset< VImageDimension > OffsetType
Vector< SpacingValueType, VImageDimension > SpacingType
Index< VImageDimension > IndexType
Implements a weak reference to an object.
SmartPointer< Self > Pointer
TInput Ceil(TInput x) template< typename TReturn
TInput RoundHalfIntegerUp(TInput x) template< typename TReturn
Round towards nearest integer (This is a synonym for RoundHalfIntegerUp)
constexpr int sgn(T x)
Sign of a value: -1, 0, or +1.
Floor(TInput x) template< TReturn
Round towards minus infinity.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
detail::VectorContainer< std::conditional_t< std::is_void_v< T2 >, SizeValueType, T1 >, std::conditional_t< std::is_void_v< T2 >, T1, T2 > > VectorContainer