ITK  5.3.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  * http://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 
112 
115  using PixelType = TPixel;
116 
118  using ValueType = TPixel;
119 
124  using InternalPixelType = TPixel;
125 
126  using IOPixelType = typename Superclass::IOPixelType;
127 
131 
136 
140 
145  static constexpr unsigned int ImageDimension = 3;
146 
150 
152  using OffsetType = typename Superclass::OffsetType;
153 
155  using SizeType = typename Superclass::SizeType;
157 
160 
165 
172  using SpacingType = typename Superclass::SpacingType;
173 
179 
183 
185  template <typename TIndexRep, typename TCoordRep>
188  {
189  const RegionType region = this->GetLargestPossibleRegion();
190  const double maxAzimuth = region.GetSize(0) - 1;
191  const double maxElevation = region.GetSize(1) - 1;
193 
194  // Convert Cartesian coordinates into angular coordinates
195  TCoordRep azimuth = Math::pi_over_2;
196  TCoordRep 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 TCoordRep 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<TCoordRep>((azimuth / m_AzimuthAngularSeparation) + (maxAzimuth / 2.0));
207  index[1] = static_cast<TCoordRep>((elevation / m_ElevationAngularSeparation) + (maxElevation / 2.0));
208  index[2] = static_cast<TCoordRep>(((radius - m_FirstSampleDistance) / m_RadiusSampleSize));
209  return index;
210  }
211 
216  template <typename TCoordRep, typename TIndexRep>
217  bool
219  ContinuousIndex<TIndexRep, 3> & index) const
220  {
221  index = this->TransformPhysicalPointToContinuousIndex<TIndexRep>(point);
222 
223  // Now, check to see if the index is within allowed bounds
224  const bool isInside = this->GetLargestPossibleRegion().IsInside(index);
225 
226  return isInside;
227  }
228 
232  template <typename TCoordRep>
233  IndexType
235  {
236  const RegionType region = this->GetLargestPossibleRegion();
237  const double maxAzimuth = region.GetSize(0) - 1;
238  const double maxElevation = region.GetSize(1) - 1;
240 
241  // Convert Cartesian coordinates into angular coordinates
242  TCoordRep azimuth = Math::pi_over_2;
243  TCoordRep elevation = Math::pi_over_2;
244  if (point[2] != 0.0)
245  {
246  azimuth = std::atan(point[0] / point[2]);
247  elevation = std::atan(point[1] / point[2]);
248  }
249  const TCoordRep radius = std::sqrt(point[0] * point[0] + point[1] * point[1] + point[2] * point[2]);
250 
251  // Convert the "proper" angular coordinates into index format
252  IndexType index;
253  index[0] = static_cast<IndexValueType>((azimuth / m_AzimuthAngularSeparation) + (maxAzimuth / 2.0));
254  index[1] = static_cast<IndexValueType>((elevation / m_ElevationAngularSeparation) + (maxElevation / 2.0));
255  index[2] = static_cast<IndexValueType>(((radius - m_FirstSampleDistance) / m_RadiusSampleSize));
256  return index;
257  }
258 
263  template <typename TCoordRep>
264  bool
266  {
267  index = this->TransformPhysicalPointToIndex(point);
268 
269  // Now, check to see if the index is within allowed bounds
270  const bool isInside = this->GetLargestPossibleRegion().IsInside(index);
271 
272  return isInside;
273  }
274 
279  template <typename TCoordRep, typename TIndexRep>
280  void
282  Point<TCoordRep, 3> & point) const
283  {
284  const RegionType region = this->GetLargestPossibleRegion();
285  const double maxAzimuth = region.GetSize(0) - 1;
286  const double maxElevation = region.GetSize(1) - 1;
288 
289  // Convert the index into proper angular coordinates
290  const TCoordRep azimuth = (index[0] - (maxAzimuth / 2.0)) * m_AzimuthAngularSeparation;
291  const TCoordRep elevation = (index[1] - (maxElevation / 2.0)) * m_ElevationAngularSeparation;
292  const TCoordRep radius = (index[2] * m_RadiusSampleSize) + m_FirstSampleDistance;
293 
294  // Convert the angular coordinates into Cartesian coordinates
295  const TCoordRep tanOfAzimuth = std::tan(azimuth);
296  const TCoordRep tanOfElevation = std::tan(elevation);
297 
298  point[2] =
299  static_cast<TCoordRep>(radius / std::sqrt(1 + tanOfAzimuth * tanOfAzimuth + tanOfElevation * tanOfElevation));
300  point[1] = static_cast<TCoordRep>(point[2] * tanOfElevation);
301  point[0] = static_cast<TCoordRep>(point[2] * tanOfAzimuth);
302  }
303 
305  template <typename TCoordRep, typename TIndexRep>
308  {
309  Point<TCoordRep, 3> point;
310  this->TransformContinuousIndexToPhysicalPoint(index, point);
311  return point;
312  }
314 
320  template <typename TCoordRep>
321  void
323  {
324  const RegionType region = this->GetLargestPossibleRegion();
325  const double maxAzimuth = region.GetSize(0) - 1;
326  const double maxElevation = region.GetSize(1) - 1;
328 
329  // Convert the index into proper angular coordinates
330  const TCoordRep azimuth = (static_cast<double>(index[0]) - (maxAzimuth / 2.0)) * m_AzimuthAngularSeparation;
331  const TCoordRep elevation = (static_cast<double>(index[1]) - (maxElevation / 2.0)) * m_ElevationAngularSeparation;
332  const TCoordRep radius = (static_cast<double>(index[2]) * m_RadiusSampleSize) + m_FirstSampleDistance;
333 
334  // Convert the angular coordinates into Cartesian coordinates
335  const TCoordRep tanOfAzimuth = std::tan(azimuth);
336  const TCoordRep tanOfElevation = std::tan(elevation);
337 
338  point[2] =
339  static_cast<TCoordRep>(radius / std::sqrt(1.0 + tanOfAzimuth * tanOfAzimuth + tanOfElevation * tanOfElevation));
340  point[1] = static_cast<TCoordRep>(point[2] * tanOfElevation);
341  point[0] = static_cast<TCoordRep>(point[2] * tanOfAzimuth);
342  }
343 
345  template <typename TCoordRep>
348  {
349  Point<TCoordRep, 3> point;
350  this->TransformIndexToPhysicalPoint(index, point);
351  return point;
352  }
354 
356  itkSetMacro(AzimuthAngularSeparation, double);
357 
359  itkSetMacro(ElevationAngularSeparation, double);
360 
362  itkSetMacro(RadiusSampleSize, double);
363 
365  itkSetMacro(FirstSampleDistance, double);
366 
367  template <typename TCoordRep>
369  {}
370 
371  template <typename TCoordRep>
372  void
374  {}
375 
377  AccessorType
379  {
380  return AccessorType();
381  }
382 
384  const AccessorType
386  {
387  return AccessorType();
388  }
389 
391  NeighborhoodAccessorFunctorType
393  {
395  }
396 
398  const NeighborhoodAccessorFunctorType
400  {
402  }
403 
404 protected:
406  {
407  m_RadiusSampleSize = 1;
408  m_AzimuthAngularSeparation = 1 * (2.0 * itk::Math::pi / 360.0); // 1
409  // degree
410  m_ElevationAngularSeparation = 1 * (2.0 * itk::Math::pi / 360.0); // 1
411  // degree
412  m_FirstSampleDistance = 0;
413  }
414 
415  ~PhasedArray3DSpecialCoordinatesImage() override = default;
416  void
417  PrintSelf(std::ostream & os, Indent indent) const override;
418 
419 private:
420  double m_AzimuthAngularSeparation; // in radians
421  double m_ElevationAngularSeparation; // in radians
424 };
425 } // end namespace itk
426 
427 #ifndef ITK_MANUAL_INSTANTIATION
428 # include "itkPhasedArray3DSpecialCoordinatesImage.hxx"
429 #endif
430 
431 #endif
itk::PhasedArray3DSpecialCoordinatesImage::TransformPhysicalPointToIndex
IndexType TransformPhysicalPointToIndex(const Point< TCoordRep, 3 > &point) const
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:234
itkSpecialCoordinatesImage.h
itk::PhasedArray3DSpecialCoordinatesImage::GetPixelAccessor
const AccessorType GetPixelAccessor() const
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:385
itk::Index< VImageDimension >
itk::PhasedArray3DSpecialCoordinatesImage::PixelContainerConstPointer
typename PixelContainer::ConstPointer PixelContainerConstPointer
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:182
itk::PhasedArray3DSpecialCoordinatesImage::TransformIndexToPhysicalPoint
void TransformIndexToPhysicalPoint(const IndexType &index, Point< TCoordRep, 3 > &point) const
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:322
itk::PhasedArray3DSpecialCoordinatesImage::TransformContinuousIndexToPhysicalPoint
Point< TCoordRep, 3 > TransformContinuousIndexToPhysicalPoint(const ContinuousIndex< TIndexRep, 3 > &index) const
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:307
itk::Size
Represent a n-dimensional size (bounds) of a n-dimensional image.
Definition: itkSize.h:69
itk::PhasedArray3DSpecialCoordinatesImage::m_FirstSampleDistance
double m_FirstSampleDistance
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:423
itkPoint.h
itk::ImageRegion
An image region represents a structured region of data.
Definition: itkImageRegion.h:69
itk::ImageBase::SizeValueType
typename SizeType::SizeValueType SizeValueType
Definition: itkImageBase.h:142
itk::PhasedArray3DSpecialCoordinatesImage::GetNeighborhoodAccessor
NeighborhoodAccessorFunctorType GetNeighborhoodAccessor()
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:392
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::Vector< SpacingValueType, VImageDimension >
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itkNeighborhoodAccessorFunctor.h
itk::PhasedArray3DSpecialCoordinatesImage::TransformPhysicalVectorToLocalVector
void TransformPhysicalVectorToLocalVector(const FixedArray< TCoordRep, 3 > &, FixedArray< TCoordRep, 3 > &) const
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:373
itk::ImageRegion::GetSize
const SizeType & GetSize() const
Definition: itkImageRegion.h:181
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::ImageBase::IndexValueType
typename IndexType::IndexValueType IndexValueType
Definition: itkImageBase.h:133
itk::NeighborhoodAccessorFunctor
Provides accessor interfaces to Get pixels and is meant to be used on pointers contained within Neigh...
Definition: itkNeighborhoodAccessorFunctor.h:41
itk::PhasedArray3DSpecialCoordinatesImage::TransformPhysicalPointToIndex
bool TransformPhysicalPointToIndex(const Point< TCoordRep, 3 > &point, IndexType &index) const
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:265
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::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:405
itk::PhasedArray3DSpecialCoordinatesImage::GetPixelAccessor
AccessorType GetPixelAccessor()
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:378
itk::PhasedArray3DSpecialCoordinatesImage::m_AzimuthAngularSeparation
double m_AzimuthAngularSeparation
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:420
itk::Math::pi_over_2
static constexpr double pi_over_2
Definition: itkMath.h:68
itk::PhasedArray3DSpecialCoordinatesImage::GetNeighborhoodAccessor
const NeighborhoodAccessorFunctorType GetNeighborhoodAccessor() const
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:399
itk::PhasedArray3DSpecialCoordinatesImage::IOPixelType
typename Superclass::IOPixelType IOPixelType
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:126
itk::PhasedArray3DSpecialCoordinatesImage::TransformContinuousIndexToPhysicalPoint
void TransformContinuousIndexToPhysicalPoint(const ContinuousIndex< TIndexRep, 3 > &index, Point< TCoordRep, 3 > &point) const
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:281
itk::PhasedArray3DSpecialCoordinatesImage::m_RadiusSampleSize
double m_RadiusSampleSize
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:422
itk::PhasedArray3DSpecialCoordinatesImage::TransformLocalVectorToPhysicalVector
void TransformLocalVectorToPhysicalVector(FixedArray< TCoordRep, 3 > &) const
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:368
itk::ImportImageContainer
Defines an itk::Image front-end to a standard C-array.
Definition: itkImportImageContainer.h:45
itk::FixedArray
Simulate a standard C array with copy semantics.
Definition: itkFixedArray.h:52
itk::Offset
Represent a n-dimensional offset between two n-dimensional indexes of n-dimensional image.
Definition: itkOffset.h:67
itk::WeakPointer
Implements a weak reference to an object.
Definition: itkWeakPointer.h:44
itk::PhasedArray3DSpecialCoordinatesImage::TransformPhysicalPointToContinuousIndex
bool TransformPhysicalPointToContinuousIndex(const Point< TCoordRep, 3 > &point, ContinuousIndex< TIndexRep, 3 > &index) const
Get the continuous index from a physical point.
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:218
itk::PhasedArray3DSpecialCoordinatesImage::TransformPhysicalPointToContinuousIndex
ContinuousIndex< TIndexRep, 3 > TransformPhysicalPointToContinuousIndex(const Point< TCoordRep, 3 > &point) const
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:187
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
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::PhasedArray3DSpecialCoordinatesImage::m_ElevationAngularSeparation
double m_ElevationAngularSeparation
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:421
itk::IndexValueType
signed long IndexValueType
Definition: itkIntTypes.h:90
itk::PhasedArray3DSpecialCoordinatesImage::TransformIndexToPhysicalPoint
Point< TCoordRep, 3 > TransformIndexToPhysicalPoint(const IndexType &index) const
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:347
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:62
itk::Point< PointValueType, VImageDimension >
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:64
itkMath.h
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::PhasedArray3DSpecialCoordinatesImage::PixelType
TPixel PixelType
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:115
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293