ITK  5.2.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_ASSIGN(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 
188  template <typename TCoordRep, typename TIndexRep>
189  bool
191  ContinuousIndex<TIndexRep, 3> & index) const
192  {
193  const RegionType region = this->GetLargestPossibleRegion();
194  const double maxAzimuth = region.GetSize(0) - 1;
195  const double maxElevation = region.GetSize(1) - 1;
196 
197  // Convert Cartesian coordinates into angular coordinates
198  TCoordRep azimuth = Math::pi_over_2;
199  TCoordRep elevation = Math::pi_over_2;
200  if (point[2] != 0.0)
201  {
202  azimuth = std::atan(point[0] / point[2]);
203  elevation = std::atan(point[1] / point[2]);
204  }
205  const TCoordRep radius = std::sqrt(point[0] * point[0] + point[1] * point[1] + point[2] * point[2]);
206 
207  // Convert the "proper" angular coordinates into index format
208  index[0] = static_cast<TCoordRep>((azimuth / m_AzimuthAngularSeparation) + (maxAzimuth / 2.0));
209  index[1] = static_cast<TCoordRep>((elevation / m_ElevationAngularSeparation) + (maxElevation / 2.0));
210  index[2] = static_cast<TCoordRep>(((radius - m_FirstSampleDistance) / m_RadiusSampleSize));
211 
212  // Now, check to see if the index is within allowed bounds
213  const bool isInside = region.IsInside(index);
214 
215  return isInside;
216  }
217 
222  template <typename TCoordRep>
223  bool
225  {
226  const RegionType region = this->GetLargestPossibleRegion();
227  const double maxAzimuth = region.GetSize(0) - 1;
228  const double maxElevation = region.GetSize(1) - 1;
230 
231  // Convert Cartesian coordinates into angular coordinates
232  TCoordRep azimuth = Math::pi_over_2;
233  TCoordRep elevation = Math::pi_over_2;
234  if (point[2] != 0.0)
235  {
236  azimuth = std::atan(point[0] / point[2]);
237  elevation = std::atan(point[1] / point[2]);
238  }
239  const TCoordRep radius = std::sqrt(point[0] * point[0] + point[1] * point[1] + point[2] * point[2]);
240 
241  // Convert the "proper" angular coordinates into index format
242  index[0] = static_cast<IndexValueType>((azimuth / m_AzimuthAngularSeparation) + (maxAzimuth / 2.0));
243  index[1] = static_cast<IndexValueType>((elevation / m_ElevationAngularSeparation) + (maxElevation / 2.0));
244  index[2] = static_cast<IndexValueType>(((radius - m_FirstSampleDistance) / m_RadiusSampleSize));
245 
246  // Now, check to see if the index is within allowed bounds
247  const bool isInside = region.IsInside(index);
248 
249  return isInside;
250  }
251 
256  template <typename TCoordRep, typename TIndexRep>
257  void
259  Point<TCoordRep, 3> & point) const
260  {
261  const RegionType region = this->GetLargestPossibleRegion();
262  const double maxAzimuth = region.GetSize(0) - 1;
263  const double maxElevation = region.GetSize(1) - 1;
265 
266  // Convert the index into proper angular coordinates
267  const TCoordRep azimuth = (index[0] - (maxAzimuth / 2.0)) * m_AzimuthAngularSeparation;
268  const TCoordRep elevation = (index[1] - (maxElevation / 2.0)) * m_ElevationAngularSeparation;
269  const TCoordRep radius = (index[2] * m_RadiusSampleSize) + m_FirstSampleDistance;
270 
271  // Convert the angular coordinates into Cartesian coordinates
272  const TCoordRep tanOfAzimuth = std::tan(azimuth);
273  const TCoordRep tanOfElevation = std::tan(elevation);
274 
275  point[2] =
276  static_cast<TCoordRep>(radius / std::sqrt(1 + tanOfAzimuth * tanOfAzimuth + tanOfElevation * tanOfElevation));
277  point[1] = static_cast<TCoordRep>(point[2] * tanOfElevation);
278  point[0] = static_cast<TCoordRep>(point[2] * tanOfAzimuth);
279  }
280 
286  template <typename TCoordRep>
287  void
289  {
290  const RegionType region = this->GetLargestPossibleRegion();
291  const double maxAzimuth = region.GetSize(0) - 1;
292  const double maxElevation = region.GetSize(1) - 1;
294 
295  // Convert the index into proper angular coordinates
296  const TCoordRep azimuth = (static_cast<double>(index[0]) - (maxAzimuth / 2.0)) * m_AzimuthAngularSeparation;
297  const TCoordRep elevation = (static_cast<double>(index[1]) - (maxElevation / 2.0)) * m_ElevationAngularSeparation;
298  const TCoordRep radius = (static_cast<double>(index[2]) * m_RadiusSampleSize) + m_FirstSampleDistance;
299 
300  // Convert the angular coordinates into Cartesian coordinates
301  const TCoordRep tanOfAzimuth = std::tan(azimuth);
302  const TCoordRep tanOfElevation = std::tan(elevation);
303 
304  point[2] =
305  static_cast<TCoordRep>(radius / std::sqrt(1.0 + tanOfAzimuth * tanOfAzimuth + tanOfElevation * tanOfElevation));
306  point[1] = static_cast<TCoordRep>(point[2] * tanOfElevation);
307  point[0] = static_cast<TCoordRep>(point[2] * tanOfAzimuth);
308  }
309 
311  itkSetMacro(AzimuthAngularSeparation, double);
312 
314  itkSetMacro(ElevationAngularSeparation, double);
315 
317  itkSetMacro(RadiusSampleSize, double);
318 
320  itkSetMacro(FirstSampleDistance, double);
321 
322  template <typename TCoordRep>
324  {}
325 
326  template <typename TCoordRep>
327  void
329  {}
330 
332  AccessorType
334  {
335  return AccessorType();
336  }
337 
339  const AccessorType
341  {
342  return AccessorType();
343  }
344 
346  NeighborhoodAccessorFunctorType
348  {
350  }
351 
353  const NeighborhoodAccessorFunctorType
355  {
357  }
358 
359 protected:
361  {
362  m_RadiusSampleSize = 1;
363  m_AzimuthAngularSeparation = 1 * (2.0 * itk::Math::pi / 360.0); // 1
364  // degree
365  m_ElevationAngularSeparation = 1 * (2.0 * itk::Math::pi / 360.0); // 1
366  // degree
367  m_FirstSampleDistance = 0;
368  }
369 
370  ~PhasedArray3DSpecialCoordinatesImage() override = default;
371  void
372  PrintSelf(std::ostream & os, Indent indent) const override;
373 
374 private:
375  double m_AzimuthAngularSeparation; // in radians
376  double m_ElevationAngularSeparation; // in radians
379 };
380 } // end namespace itk
381 
382 #ifndef ITK_MANUAL_INSTANTIATION
383 # include "itkPhasedArray3DSpecialCoordinatesImage.hxx"
384 #endif
385 
386 #endif
itkSpecialCoordinatesImage.h
itk::PhasedArray3DSpecialCoordinatesImage::GetPixelAccessor
const AccessorType GetPixelAccessor() const
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:340
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:288
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:378
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:347
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:328
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:224
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itkDefaultPixelAccessor.h
itk::ImageRegion::IsInside
bool IsInside(const IndexType &index) const
Definition: itkImageRegion.h:248
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:360
itk::PhasedArray3DSpecialCoordinatesImage::GetPixelAccessor
AccessorType GetPixelAccessor()
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:333
itk::PhasedArray3DSpecialCoordinatesImage::m_AzimuthAngularSeparation
double m_AzimuthAngularSeparation
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:375
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:354
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:258
itk::PhasedArray3DSpecialCoordinatesImage::m_RadiusSampleSize
double m_RadiusSampleSize
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:377
itk::PhasedArray3DSpecialCoordinatesImage::TransformLocalVectorToPhysicalVector
void TransformLocalVectorToPhysicalVector(FixedArray< TCoordRep, 3 > &) const
Definition: itkPhasedArray3DSpecialCoordinatesImage.h:323
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:190
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:376
itk::IndexValueType
signed long IndexValueType
Definition: itkIntTypes.h:90
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