Loading [MathJax]/extensions/tex2jax.js
ITK 6.0.0
Insight Toolkit
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
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
27namespace itk
28{
94template <typename TPixel>
95class ITK_TEMPLATE_EXPORT PhasedArray3DSpecialCoordinatesImage : public SpecialCoordinatesImage<TPixel, 3>
96{
97public:
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>
188 {
189 const RegionType region = this->GetLargestPossibleRegion();
190 const double maxAzimuth = region.GetSize(0) - 1;
191 const double maxElevation = region.GetSize(1) - 1;
192
193 // Convert Cartesian coordinates into angular coordinates
194 TCoordinate azimuth = Math::pi_over_2;
195 TCoordinate elevation = Math::pi_over_2;
196 if (point[2] != 0.0)
197 {
198 azimuth = std::atan(point[0] / point[2]);
199 elevation = std::atan(point[1] / point[2]);
200 }
201 const TCoordinate radius = std::sqrt(point[0] * point[0] + point[1] * point[1] + point[2] * point[2]);
202
203 // Convert the "proper" angular coordinates into index format
205 index[0] = static_cast<TCoordinate>((azimuth / m_AzimuthAngularSeparation) + (maxAzimuth / 2.0));
206 index[1] = static_cast<TCoordinate>((elevation / m_ElevationAngularSeparation) + (maxElevation / 2.0));
207 index[2] = static_cast<TCoordinate>(((radius - m_FirstSampleDistance) / m_RadiusSampleSize));
208 return index;
209 }
210
219 template <typename TCoordinate, typename TIndexRep>
220 ITK_NODISCARD("Call the overload which has the point as the only parameter and returns the index")
221 bool TransformPhysicalPointToContinuousIndex(const Point<TCoordinate, 3> & point,
222 ContinuousIndex<TIndexRep, 3> & index) const
223 {
225
226 // Now, check to see if the index is within allowed bounds
227 const bool isInside = this->GetLargestPossibleRegion().IsInside(index);
228
229 return isInside;
230 }
231
235 template <typename TCoordinate>
236 [[nodiscard]] IndexType
238 {
239 const RegionType region = this->GetLargestPossibleRegion();
240 const double maxAzimuth = region.GetSize(0) - 1;
241 const double maxElevation = region.GetSize(1) - 1;
242
243 // Convert Cartesian coordinates into angular coordinates
244 TCoordinate azimuth = Math::pi_over_2;
245 TCoordinate elevation = Math::pi_over_2;
246 if (point[2] != 0.0)
247 {
248 azimuth = std::atan(point[0] / point[2]);
249 elevation = std::atan(point[1] / point[2]);
250 }
251 const TCoordinate radius = std::sqrt(point[0] * point[0] + point[1] * point[1] + point[2] * point[2]);
252
253 // Convert the "proper" angular coordinates into index format
254 IndexType index;
255 index[0] = static_cast<IndexValueType>((azimuth / m_AzimuthAngularSeparation) + (maxAzimuth / 2.0));
256 index[1] = static_cast<IndexValueType>((elevation / m_ElevationAngularSeparation) + (maxElevation / 2.0));
257 index[2] = static_cast<IndexValueType>(((radius - m_FirstSampleDistance) / m_RadiusSampleSize));
258 return index;
259 }
260
269 template <typename TCoordinate>
270 ITK_NODISCARD("Call the overload which has the point as the only parameter and returns the index")
271 bool TransformPhysicalPointToIndex(const Point<TCoordinate, 3> & point, IndexType & index) const
272 {
273 index = this->TransformPhysicalPointToIndex(point);
274
275 // Now, check to see if the index is within allowed bounds
276 const bool isInside = this->GetLargestPossibleRegion().IsInside(index);
277
278 return isInside;
279 }
280
285 template <typename TCoordinate, typename TIndexRep>
286 void
288 Point<TCoordinate, 3> & point) const
289 {
290 const RegionType region = this->GetLargestPossibleRegion();
291 const double maxAzimuth = region.GetSize(0) - 1;
292 const double maxElevation = region.GetSize(1) - 1;
293
294 // Convert the index into proper angular coordinates
295 const TCoordinate azimuth = (index[0] - (maxAzimuth / 2.0)) * m_AzimuthAngularSeparation;
296 const TCoordinate elevation = (index[1] - (maxElevation / 2.0)) * m_ElevationAngularSeparation;
297 const TCoordinate radius = (index[2] * m_RadiusSampleSize) + m_FirstSampleDistance;
298
299 // Convert the angular coordinates into Cartesian coordinates
300 const TCoordinate tanOfAzimuth = std::tan(azimuth);
301 const TCoordinate tanOfElevation = std::tan(elevation);
302
303 point[2] =
304 static_cast<TCoordinate>(radius / std::sqrt(1 + tanOfAzimuth * tanOfAzimuth + tanOfElevation * tanOfElevation));
305 point[1] = static_cast<TCoordinate>(point[2] * tanOfElevation);
306 point[0] = static_cast<TCoordinate>(point[2] * tanOfAzimuth);
307 }
308
310 template <typename TCoordinate, typename TIndexRep>
311 [[nodiscard]] Point<TCoordinate, 3>
313 {
315 this->TransformContinuousIndexToPhysicalPoint(index, point);
316 return point;
317 }
318
324 template <typename TCoordinate>
325 void
327 {
328 const RegionType region = this->GetLargestPossibleRegion();
329 const double maxAzimuth = region.GetSize(0) - 1;
330 const double maxElevation = region.GetSize(1) - 1;
331
332 // Convert the index into proper angular coordinates
333 const TCoordinate azimuth = (static_cast<double>(index[0]) - (maxAzimuth / 2.0)) * m_AzimuthAngularSeparation;
334 const TCoordinate elevation = (static_cast<double>(index[1]) - (maxElevation / 2.0)) * m_ElevationAngularSeparation;
335 const TCoordinate radius = (static_cast<double>(index[2]) * m_RadiusSampleSize) + m_FirstSampleDistance;
336
337 // Convert the angular coordinates into Cartesian coordinates
338 const TCoordinate tanOfAzimuth = std::tan(azimuth);
339 const TCoordinate tanOfElevation = std::tan(elevation);
340
341 point[2] =
342 static_cast<TCoordinate>(radius / std::sqrt(1.0 + tanOfAzimuth * tanOfAzimuth + tanOfElevation * tanOfElevation));
343 point[1] = static_cast<TCoordinate>(point[2] * tanOfElevation);
344 point[0] = static_cast<TCoordinate>(point[2] * tanOfAzimuth);
345 }
346
348 template <typename TCoordinate>
349 [[nodiscard]] Point<TCoordinate, 3>
351 {
353 this->TransformIndexToPhysicalPoint(index, point);
354 return point;
355 }
356
358 itkSetMacro(AzimuthAngularSeparation, double);
359
361 itkSetMacro(ElevationAngularSeparation, double);
362
364 itkSetMacro(RadiusSampleSize, double);
365
367 itkSetMacro(FirstSampleDistance, double);
368
369 template <typename TCoordinate>
370 void
373
374 template <typename TCoordinate>
375 void
378
380 AccessorType
382 {
383 return AccessorType();
384 }
385
387 const AccessorType
389 {
390 return AccessorType();
391 }
392
394 NeighborhoodAccessorFunctorType
399
401 const NeighborhoodAccessorFunctorType
406
407protected:
409 {
411 m_AzimuthAngularSeparation = 1 * (2.0 * itk::Math::pi / 360.0); // 1
412 // degree
413 m_ElevationAngularSeparation = 1 * (2.0 * itk::Math::pi / 360.0); // 1
414 // degree
416 }
417
419 void
420 PrintSelf(std::ostream & os, Indent indent) const override;
421
422private:
423 double m_AzimuthAngularSeparation{}; // in radians
424 double m_ElevationAngularSeparation{}; // in radians
427};
428} // end namespace itk
429
430#ifndef ITK_MANUAL_INSTANTIATION
431# include "itkPhasedArray3DSpecialCoordinatesImage.hxx"
432#endif
433
434#endif
A templated class holding a point in n-Dimensional image space.
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.
typename IndexType::IndexValueType IndexValueType
virtual const RegionType & GetLargestPossibleRegion() const
typename SizeType::SizeValueType SizeValueType
const SizeType & GetSize() const
Defines an itk::Image front-end to a standard C-array.
Control indentation during Print() invocation.
Definition itkIndent.h:50
Provides accessor interfaces to Get pixels and is meant to be used on pointers contained within Neigh...
const NeighborhoodAccessorFunctorType GetNeighborhoodAccessor() const
~PhasedArray3DSpecialCoordinatesImage() override=default
ImportImageContainer< SizeValueType, PixelType > PixelContainer
Point< TCoordinate, 3 > TransformIndexToPhysicalPoint(const IndexType &index) const
Point< TCoordinate, 3 > TransformContinuousIndexToPhysicalPoint(const ContinuousIndex< TIndexRep, 3 > &index) const
void TransformLocalVectorToPhysicalVector(FixedArray< TCoordinate, 3 > &) const
void TransformIndexToPhysicalPoint(const IndexType &index, Point< TCoordinate, 3 > &point) const
ContinuousIndex< TIndexRep, 3 > TransformPhysicalPointToContinuousIndex(const Point< TCoordinate, 3 > &point) const
IndexType TransformPhysicalPointToIndex(const Point< TCoordinate, 3 > &point) const
void PrintSelf(std::ostream &os, Indent indent) const override
void TransformPhysicalVectorToLocalVector(const FixedArray< TCoordinate, 3 > &, FixedArray< TCoordinate, 3 > &) const
void TransformContinuousIndexToPhysicalPoint(const ContinuousIndex< TIndexRep, 3 > &index, Point< TCoordinate, 3 > &point) const
A templated class holding a geometric point in n-Dimensional space.
Definition itkPoint.h:54
Implements transparent reference counting.
Point< PointValueType, VImageDimension > PointType
ImageRegion< VImageDimension > RegionType
Offset< VImageDimension > OffsetType
Vector< SpacingValueType, VImageDimension > SpacingType
Implements a weak reference to an object.
static constexpr double pi_over_2
Definition itkMath.h:70
static constexpr double pi
Definition itkMath.h:66
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....