ITK  6.0.0
Insight Toolkit
itkPhasedArray3DSpecialCoordinatesImage.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * https://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkPhasedArray3DSpecialCoordinatesImage_h
19 #define itkPhasedArray3DSpecialCoordinatesImage_h
20 
22 #include "itkPoint.h"
23 #include "itkMath.h"
26 
27 namespace itk
28 {
94 template <typename TPixel>
95 class ITK_TEMPLATE_EXPORT PhasedArray3DSpecialCoordinatesImage : public SpecialCoordinatesImage<TPixel, 3>
96 {
97 public:
98  ITK_DISALLOW_COPY_AND_MOVE(PhasedArray3DSpecialCoordinatesImage);
99 
106 
108  itkNewMacro(Self);
109 
111  itkOverrideGetNameOfClassMacro(PhasedArray3DSpecialCoordinatesImage);
112 
115  using PixelType = TPixel;
116 
118  using ValueType = TPixel;
119 
124  using InternalPixelType = TPixel;
125 
126  using typename Superclass::IOPixelType;
127 
131 
136 
140 
145  static constexpr unsigned int ImageDimension = 3;
146 
148  using typename Superclass::IndexType;
149  using typename Superclass::IndexValueType;
150 
152  using typename Superclass::OffsetType;
153 
155  using typename Superclass::SizeType;
156  using typename Superclass::SizeValueType;
157 
160 
164  using typename Superclass::RegionType;
165 
172  using typename Superclass::SpacingType;
173 
178  using typename Superclass::PointType;
179 
183 
185  template <typename TIndexRep, typename TCoordinate>
186  [[nodiscard]] ContinuousIndex<TIndexRep, 3>
188  {
189  const RegionType region = this->GetLargestPossibleRegion();
190  const double maxAzimuth = region.GetSize(0) - 1;
191  const double maxElevation = region.GetSize(1) - 1;
194  // Convert Cartesian coordinates into angular coordinates
195  TCoordinate azimuth = Math::pi_over_2;
196  TCoordinate elevation = Math::pi_over_2;
197  if (point[2] != 0.0)
198  {
199  azimuth = std::atan(point[0] / point[2]);
200  elevation = std::atan(point[1] / point[2]);
201  }
202  const TCoordinate radius = std::sqrt(point[0] * point[0] + point[1] * point[1] + point[2] * point[2]);
203 
204  // Convert the "proper" angular coordinates into index format
206  index[0] = static_cast<TCoordinate>((azimuth / m_AzimuthAngularSeparation) + (maxAzimuth / 2.0));
207  index[1] = static_cast<TCoordinate>((elevation / m_ElevationAngularSeparation) + (maxElevation / 2.0));
208  index[2] = static_cast<TCoordinate>(((radius - m_FirstSampleDistance) / m_RadiusSampleSize));
209  return index;
210  }
211 
220  template <typename TCoordinate, typename TIndexRep>
221  ITK_NODISCARD("Call the overload which has the point as the only parameter and returns the index")
222  bool TransformPhysicalPointToContinuousIndex(const Point<TCoordinate, 3> & point,
223  ContinuousIndex<TIndexRep, 3> & index) const
224  {
225  index = this->TransformPhysicalPointToContinuousIndex<TIndexRep>(point);
226 
227  // Now, check to see if the index is within allowed bounds
228  const bool isInside = this->GetLargestPossibleRegion().IsInside(index);
229 
230  return isInside;
231  }
232 
236  template <typename TCoordinate>
237  [[nodiscard]] IndexType
239  {
240  const RegionType region = this->GetLargestPossibleRegion();
241  const double maxAzimuth = region.GetSize(0) - 1;
242  const double maxElevation = region.GetSize(1) - 1;
245  // Convert Cartesian coordinates into angular coordinates
246  TCoordinate azimuth = Math::pi_over_2;
247  TCoordinate elevation = Math::pi_over_2;
248  if (point[2] != 0.0)
249  {
250  azimuth = std::atan(point[0] / point[2]);
251  elevation = std::atan(point[1] / point[2]);
252  }
253  const TCoordinate radius = std::sqrt(point[0] * point[0] + point[1] * point[1] + point[2] * point[2]);
254 
255  // Convert the "proper" angular coordinates into index format
256  IndexType index;
257  index[0] = static_cast<IndexValueType>((azimuth / m_AzimuthAngularSeparation) + (maxAzimuth / 2.0));
258  index[1] = static_cast<IndexValueType>((elevation / m_ElevationAngularSeparation) + (maxElevation / 2.0));
259  index[2] = static_cast<IndexValueType>(((radius - m_FirstSampleDistance) / m_RadiusSampleSize));
260  return index;
261  }
262 
271  template <typename TCoordinate>
272  ITK_NODISCARD("Call the overload which has the point as the only parameter and returns the index")
273  bool TransformPhysicalPointToIndex(const Point<TCoordinate, 3> & point, IndexType & index) const
274  {
275  index = this->TransformPhysicalPointToIndex(point);
276 
277  // Now, check to see if the index is within allowed bounds
278  const bool isInside = this->GetLargestPossibleRegion().IsInside(index);
279 
280  return isInside;
281  }
282 
287  template <typename TCoordinate, typename TIndexRep>
288  void
291  {
292  const RegionType region = this->GetLargestPossibleRegion();
293  const double maxAzimuth = region.GetSize(0) - 1;
294  const double maxElevation = region.GetSize(1) - 1;
297  // Convert the index into proper angular coordinates
298  const TCoordinate azimuth = (index[0] - (maxAzimuth / 2.0)) * m_AzimuthAngularSeparation;
299  const TCoordinate elevation = (index[1] - (maxElevation / 2.0)) * m_ElevationAngularSeparation;
300  const TCoordinate radius = (index[2] * m_RadiusSampleSize) + m_FirstSampleDistance;
301 
302  // Convert the angular coordinates into Cartesian coordinates
303  const TCoordinate tanOfAzimuth = std::tan(azimuth);
304  const TCoordinate tanOfElevation = std::tan(elevation);
305 
306  point[2] =
307  static_cast<TCoordinate>(radius / std::sqrt(1 + tanOfAzimuth * tanOfAzimuth + tanOfElevation * tanOfElevation));
308  point[1] = static_cast<TCoordinate>(point[2] * tanOfElevation);
309  point[0] = static_cast<TCoordinate>(point[2] * tanOfAzimuth);
310  }
311 
313  template <typename TCoordinate, typename TIndexRep>
314  [[nodiscard]] Point<TCoordinate, 3>
316  {
318  this->TransformContinuousIndexToPhysicalPoint(index, point);
319  return point;
320  }
328  template <typename TCoordinate>
329  void
331  {
332  const RegionType region = this->GetLargestPossibleRegion();
333  const double maxAzimuth = region.GetSize(0) - 1;
334  const double maxElevation = region.GetSize(1) - 1;
337  // Convert the index into proper angular coordinates
338  const TCoordinate azimuth = (static_cast<double>(index[0]) - (maxAzimuth / 2.0)) * m_AzimuthAngularSeparation;
339  const TCoordinate elevation = (static_cast<double>(index[1]) - (maxElevation / 2.0)) * m_ElevationAngularSeparation;
340  const TCoordinate radius = (static_cast<double>(index[2]) * m_RadiusSampleSize) + m_FirstSampleDistance;
341 
342  // Convert the angular coordinates into Cartesian coordinates
343  const TCoordinate tanOfAzimuth = std::tan(azimuth);
344  const TCoordinate tanOfElevation = std::tan(elevation);
345 
346  point[2] =
347  static_cast<TCoordinate>(radius / std::sqrt(1.0 + tanOfAzimuth * tanOfAzimuth + tanOfElevation * tanOfElevation));
348  point[1] = static_cast<TCoordinate>(point[2] * tanOfElevation);
349  point[0] = static_cast<TCoordinate>(point[2] * tanOfAzimuth);
350  }
351 
353  template <typename TCoordinate>
354  [[nodiscard]] Point<TCoordinate, 3>
356  {
358  this->TransformIndexToPhysicalPoint(index, point);
359  return point;
360  }
364  itkSetMacro(AzimuthAngularSeparation, double);
365 
367  itkSetMacro(ElevationAngularSeparation, double);
368 
370  itkSetMacro(RadiusSampleSize, double);
371 
373  itkSetMacro(FirstSampleDistance, double);
374 
375  template <typename TCoordinate>
376  void
378  {}
379 
380  template <typename TCoordinate>
381  void
383  {}
384 
386  AccessorType
388  {
389  return AccessorType();
390  }
391 
393  const AccessorType
395  {
396  return AccessorType();
397  }
398 
400  NeighborhoodAccessorFunctorType
402  {
404  }
405 
407  const NeighborhoodAccessorFunctorType
409  {
411  }
412 
413 protected:
415  {
416  m_RadiusSampleSize = 1;
417  m_AzimuthAngularSeparation = 1 * (2.0 * itk::Math::pi / 360.0); // 1
418  // degree
419  m_ElevationAngularSeparation = 1 * (2.0 * itk::Math::pi / 360.0); // 1
420  // degree
421  m_FirstSampleDistance = 0;
422  }
423 
424  ~PhasedArray3DSpecialCoordinatesImage() override = default;
425  void
426  PrintSelf(std::ostream & os, Indent indent) const override;
427 
428 private:
429  double m_AzimuthAngularSeparation{}; // in radians
430  double m_ElevationAngularSeparation{}; // in radians
431  double m_RadiusSampleSize{};
432  double m_FirstSampleDistance{};
433 };
434 } // end namespace itk
435 
436 #ifndef ITK_MANUAL_INSTANTIATION
437 # include "itkPhasedArray3DSpecialCoordinatesImage.hxx"
438 #endif
439 
440 #endif
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itkSpecialCoordinatesImage.h
itk::PhasedArray3DSpecialCoordinatesImage::GetPixelAccessor
const AccessorType GetPixelAccessor() const
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:394
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:94
itk::Index< VImageDimension >
itk::PhasedArray3DSpecialCoordinatesImage::TransformIndexToPhysicalPoint
Point< TCoordinate, 3 > TransformIndexToPhysicalPoint(const IndexType &index) const
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:355
itk::PhasedArray3DSpecialCoordinatesImage::PixelContainerConstPointer
typename PixelContainer::ConstPointer PixelContainerConstPointer
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:182
itk::PhasedArray3DSpecialCoordinatesImage::TransformContinuousIndexToPhysicalPoint
Point< TCoordinate, 3 > TransformContinuousIndexToPhysicalPoint(const ContinuousIndex< TIndexRep, 3 > &index) const
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:315
itkPoint.h
itk::PhasedArray3DSpecialCoordinatesImage::TransformPhysicalVectorToLocalVector
void TransformPhysicalVectorToLocalVector(const FixedArray< TCoordinate, 3 > &, FixedArray< TCoordinate, 3 > &) const
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:382
itk::ImageRegion
An image region represents a structured region of data.
Definition: itkImageRegion.h:80
itk::PhasedArray3DSpecialCoordinatesImage::GetNeighborhoodAccessor
NeighborhoodAccessorFunctorType GetNeighborhoodAccessor()
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:401
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itkNeighborhoodAccessorFunctor.h
itk::ImageRegion::GetSize
const SizeType & GetSize() const
Definition: itkImageRegion.h:209
itk::SmartPointer< Self >
itk::DefaultPixelAccessor
Give access to partial aspects a type.
Definition: itkDefaultPixelAccessor.h:54
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::SpecialCoordinatesImage
Templated n-dimensional nonrectilinear-coordinate image base class.
Definition: itkSpecialCoordinatesImage.h:95
itk::NeighborhoodAccessorFunctor
Provides accessor interfaces to Get pixels and is meant to be used on pointers contained within Neigh...
Definition: itkNeighborhoodAccessorFunctor.h:41
itk::IndexValueType
long IndexValueType
Definition: itkIntTypes.h:93
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itkDefaultPixelAccessor.h
itk::DefaultPixelAccessorFunctor
Provides a common API for pixel accessors for Image and VectorImage.
Definition: itkDefaultPixelAccessorFunctor.h:47
itk::point
*par Constraints *The filter requires an image with at least two dimensions and a vector *length of at least The theory supports extension to scalar but *the implementation of the itk vector classes do not **The template parameter TRealType must be floating point(float or double) or *a user-defined "real" numerical type with arithmetic operations defined *sufficient to compute derivatives. **\par Performance *This filter will automatically multithread if run with *SetUsePrincipleComponents
itk::PhasedArray3DSpecialCoordinatesImage::TransformContinuousIndexToPhysicalPoint
void TransformContinuousIndexToPhysicalPoint(const ContinuousIndex< TIndexRep, 3 > &index, Point< TCoordinate, 3 > &point) const
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:289
itk::PhasedArray3DSpecialCoordinatesImage::InternalPixelType
TPixel InternalPixelType
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:124
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::PhasedArray3DSpecialCoordinatesImage::PhasedArray3DSpecialCoordinatesImage
PhasedArray3DSpecialCoordinatesImage()
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:414
itk::PhasedArray3DSpecialCoordinatesImage::GetPixelAccessor
AccessorType GetPixelAccessor()
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:387
itk::Math::pi_over_2
static constexpr double pi_over_2
Definition: itkMath.h:70
itk::PhasedArray3DSpecialCoordinatesImage::GetNeighborhoodAccessor
const NeighborhoodAccessorFunctorType GetNeighborhoodAccessor() const
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:408
itk::ImportImageContainer
Defines an itk::Image front-end to a standard C-array.
Definition: itkImportImageContainer.h:45
itk::PhasedArray3DSpecialCoordinatesImage::TransformPhysicalPointToContinuousIndex
ContinuousIndex< TIndexRep, 3 > TransformPhysicalPointToContinuousIndex(const Point< TCoordinate, 3 > &point) const
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:187
itk::FixedArray
Simulate a standard C array with copy semantics.
Definition: itkFixedArray.h:53
itk::PhasedArray3DSpecialCoordinatesImage::TransformIndexToPhysicalPoint
void TransformIndexToPhysicalPoint(const IndexType &index, Point< TCoordinate, 3 > &point) const
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:330
itk::PhasedArray3DSpecialCoordinatesImage::TransformPhysicalPointToIndex
IndexType TransformPhysicalPointToIndex(const Point< TCoordinate, 3 > &point) const
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:238
itk::WeakPointer
Implements a weak reference to an object.
Definition: itkWeakPointer.h:44
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::ContinuousIndex
A templated class holding a point in n-Dimensional image space.
Definition: itkContinuousIndex.h:46
itk::PhasedArray3DSpecialCoordinatesImage::PixelContainerPointer
typename PixelContainer::Pointer PixelContainerPointer
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:181
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61
itk::PhasedArray3DSpecialCoordinatesImage::TransformLocalVectorToPhysicalVector
void TransformLocalVectorToPhysicalVector(FixedArray< TCoordinate, 3 > &) const
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:377
itk::Point
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:53
itk::PhasedArray3DSpecialCoordinatesImage::ValueType
TPixel ValueType
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:118
itk::PhasedArray3DSpecialCoordinatesImage
Templated 3D nonrectilinear-coordinate image class for phased-array "range" images.
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:95
itk::Math::pi
static constexpr double pi
Definition: itkMath.h:66
itkMath.h
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86
itk::PhasedArray3DSpecialCoordinatesImage::PixelType
TPixel PixelType
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:115
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293