ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkCurvilinearArraySpecialCoordinatesImage.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 itkCurvilinearArraySpecialCoordinatesImage_h
19#define itkCurvilinearArraySpecialCoordinatesImage_h
20
22#include "itkPoint.h"
23#include "itkMath.h"
25
26namespace itk
27{
87template <typename TPixel, unsigned int VDimension>
88class ITK_TEMPLATE_EXPORT CurvilinearArraySpecialCoordinatesImage : public SpecialCoordinatesImage<TPixel, VDimension>
89{
90public:
91 ITK_DISALLOW_COPY_AND_MOVE(CurvilinearArraySpecialCoordinatesImage);
92
99
101 itkNewMacro(Self);
102
104 itkOverrideGetNameOfClassMacro(CurvilinearArraySpecialCoordinatesImage);
105
108 using PixelType = TPixel;
109
111 using ValueType = TPixel;
112
117 using InternalPixelType = TPixel;
118
120
124
129
133
138 static constexpr unsigned int ImageDimension = VDimension;
139
143
146
150
153
158
166
172
176
187 void
188 Graft(const ImageBase<VDimension> * image) override;
189 using Superclass::Graft;
190
195 template <typename TCoordRep, typename TIndexRep>
196 bool
199 {
200 const RegionType & region = this->GetLargestPossibleRegion();
201 const double maxLateral = region.GetSize(1) - 1;
202
203 // Convert Cartesian coordinates into angular coordinates
204 TCoordRep lateral = Math::pi_over_2;
205 if (point[1] != 0.0)
206 {
207 lateral = std::atan(point[0] / point[1]);
208 }
209 const TCoordRep radius = std::sqrt(point[0] * point[0] + point[1] * point[1]);
210
211 // Convert the "proper" angular coordinates into index format
212 index[0] = static_cast<TCoordRep>(((radius - m_FirstSampleDistance) / m_RadiusSampleSize));
213 index[1] = static_cast<TCoordRep>((lateral / m_LateralAngularSeparation) + (maxLateral / 2.0));
215 for (unsigned int kk = 0; kk < VDimension; ++kk)
216 {
217 cvector[kk] = point[kk] - this->m_Origin[kk];
218 }
219 cvector = this->m_PhysicalPointToIndex * cvector;
220 for (unsigned int ii = 2; ii < VDimension; ++ii)
221 {
222 index[ii] = static_cast<TIndexRep>(cvector[ii]);
223 }
224
225 // Now, check to see if the index is within allowed bounds
226 const bool isInside = region.IsInside(index);
227
228 return isInside;
229 }
230
245 template <typename TIndexRep, typename TCoordRep>
253
258 template <typename TCoordRep>
259 bool
261 {
262 const RegionType & region = this->GetLargestPossibleRegion();
263 const double maxLateral = region.GetSize(1) - 1;
264
265 // Convert Cartesian coordinates into angular coordinates
266 TCoordRep lateral = Math::pi_over_2;
267 if (point[1] != 0.0)
268 {
269 lateral = std::atan(point[0] / point[1]);
270 }
271 const TCoordRep radius = std::sqrt(point[0] * point[0] + point[1] * point[1]);
272
273 // Convert the "proper" angular coordinates into index format
274 index[0] = static_cast<IndexValueType>(((radius - m_FirstSampleDistance) / m_RadiusSampleSize));
275 index[1] = static_cast<IndexValueType>((lateral / m_LateralAngularSeparation) + (maxLateral / 2.0));
276 for (unsigned int ii = 2; ii < VDimension; ++ii)
277 {
278 TCoordRep sum = NumericTraits<TCoordRep>::ZeroValue();
279 for (unsigned int jj = 0; jj < VDimension; ++jj)
280 {
281 sum += this->m_PhysicalPointToIndex[ii][jj] * (point[jj] - this->m_Origin[jj]);
282 }
284 }
285
286 // Now, check to see if the index is within allowed bounds
287 const bool isInside = region.IsInside(index);
288
289 return isInside;
290 }
291
307 template <typename TCoordRep>
308 IndexType
310 {
311 IndexType index;
312 TransformPhysicalPointToIndex(point, index);
313 return index;
314 }
315
320 template <typename TCoordRep, typename TIndexRep>
321 void
323 Point<TCoordRep, VDimension> & point) const
324 {
325 const RegionType & region = this->GetLargestPossibleRegion();
326 const double maxLateral = region.GetSize(1) - 1;
327
328 // Convert the index into proper angular coordinates
329 const TCoordRep radius = (index[0] * m_RadiusSampleSize) + m_FirstSampleDistance;
330 const TCoordRep lateral = (index[1] - (maxLateral / 2.0)) * m_LateralAngularSeparation;
331
332 // Convert the angular coordinates into Cartesian coordinates
333 point[0] = static_cast<TCoordRep>(radius * std::sin(lateral));
334 point[1] = static_cast<TCoordRep>(radius * std::cos(lateral));
335 for (unsigned int rr = 2; rr < VDimension; ++rr)
336 {
337 TCoordRep sum = NumericTraits<TCoordRep>::ZeroValue();
338 for (unsigned int cc = 0; cc < VDimension; ++cc)
339 {
340 sum += this->m_IndexToPhysicalPoint(rr, cc) * index[cc];
341 }
342 point[rr] = sum + this->m_Origin[rr];
343 }
344 }
345
350 template <typename TCoordRep, typename TIndexRep>
358
364 template <typename TCoordRep>
365 void
367 {
368 const RegionType & region = this->GetLargestPossibleRegion();
369 const double maxLateral = region.GetSize(1) - 1;
370
371 // Convert the index into proper angular coordinates
372 const TCoordRep radius = (index[0] * m_RadiusSampleSize) + m_FirstSampleDistance;
373 const TCoordRep lateral = (index[1] - (maxLateral / 2.0)) * m_LateralAngularSeparation;
374
375 // Convert the angular coordinates into Cartesian coordinates
376 point[0] = static_cast<TCoordRep>(radius * std::sin(lateral));
377 point[1] = static_cast<TCoordRep>(radius * std::cos(lateral));
378 for (unsigned int ii = 2; ii < VDimension; ++ii)
379 {
380 point[ii] = this->m_Origin[ii];
381 for (unsigned int jj = 0; jj < VDimension; ++jj)
382 {
383 point[ii] += this->m_IndexToPhysicalPoint[ii][jj] * index[jj];
384 }
385 }
386 }
387
393 template <typename TCoordRep>
396 {
398 TransformIndexToPhysicalPoint(index, point);
399 return point;
400 }
401
403 itkSetMacro(LateralAngularSeparation, double);
404 itkGetConstMacro(LateralAngularSeparation, double);
405
407 itkSetMacro(RadiusSampleSize, double);
408 itkGetConstMacro(RadiusSampleSize, double);
409
411 itkSetMacro(FirstSampleDistance, double);
412 itkGetConstMacro(FirstSampleDistance, double);
413
414 template <typename TCoordRep>
415 void
418
419 template <typename TCoordRep>
420 void
424
426 AccessorType
428 {
429 return AccessorType();
430 }
431
433 const AccessorType
435 {
436 return AccessorType();
437 }
438
440 NeighborhoodAccessorFunctorType
445
447 const NeighborhoodAccessorFunctorType
452
453 virtual void
454 CopyInformation(const DataObject * data) override;
455
456protected:
464
465 virtual void
466 PrintSelf(std::ostream & os, Indent indent) const override;
467
468private:
469 double m_LateralAngularSeparation; // in radians
472};
473} // end namespace itk
474
475#ifndef ITK_MANUAL_INSTANTIATION
476# include "itkCurvilinearArraySpecialCoordinatesImage.hxx"
477#endif
478
479#endif
A templated class holding a point in n-Dimensional image space.
Point< TCoordRep, VDimension > TransformContinuousIndexToPhysicalPoint(const ContinuousIndex< TIndexRep, VDimension > &index) const
virtual void PrintSelf(std::ostream &os, Indent indent) const override
void Graft(const ImageBase< VDimension > *image) override
~CurvilinearArraySpecialCoordinatesImage() override=default
void TransformContinuousIndexToPhysicalPoint(const ContinuousIndex< TIndexRep, VDimension > &index, Point< TCoordRep, VDimension > &point) const
ContinuousIndex< TIndexRep, VDimension > TransformPhysicalPointToContinuousIndex(const Point< TCoordRep, VDimension > &point) const
Returns the continuous index from a physical point.
ImportImageContainer< SizeValueType, PixelType > PixelContainer
void TransformPhysicalVectorToLocalVector(const FixedArray< TCoordRep, VDimension > &, FixedArray< TCoordRep, VDimension > &) const
Point< TCoordRep, VDimension > TransformIndexToPhysicalPoint(const IndexType &index) const
bool TransformPhysicalPointToContinuousIndex(const Point< TCoordRep, VDimension > &point, ContinuousIndex< TIndexRep, VDimension > &index) const
Get the continuous index from a physical point.
void TransformLocalVectorToPhysicalVector(FixedArray< TCoordRep, VDimension > &) const
const NeighborhoodAccessorFunctorType GetNeighborhoodAccessor() const
bool TransformPhysicalPointToIndex(const Point< TCoordRep, VDimension > &point, IndexType &index) const
IndexType TransformPhysicalPointToIndex(const Point< TCoordRep, VDimension > &point) const
void TransformIndexToPhysicalPoint(const IndexType &index, Point< TCoordRep, VDimension > &point) const
virtual void CopyInformation(const DataObject *data) override
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.
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.
Control indentation during Print() invocation.
Definition itkIndent.h:53
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.
Definition itkPoint.h:54
Implements transparent reference counting.
Point< PointValueType, VImageDimension > PointType
Vector< SpacingValueType, VImageDimension > SpacingType
A templated class holding a n-Dimensional vector.
Definition itkVector.h:63
Implements a weak reference to an object.
constexpr double pi_over_2
Definition itkMath.h:69
TInput RoundHalfIntegerUp(TInput x) template< typename TReturn
Round towards nearest integer (This is a synonym for RoundHalfIntegerUp)
constexpr double pi
Definition itkMath.h:65
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
#define itkSetMacro(name, type)