Medical Imaging Interaction Toolkit  2018.4.99-4c24e3cb
Medical Imaging Interaction Toolkit
itkCurvilinearArraySpecialCoordinatesImage.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 /*=========================================================================
13  *
14  * Copyright Insight Software Consortium
15  *
16  * Licensed under the Apache License, Version 2.0 (the "License");
17  * you may not use this file except in compliance with the License.
18  * You may obtain a copy of the License at
19  *
20  * http://www.apache.org/licenses/LICENSE-2.0.txt
21  *
22  * Unless required by applicable law or agreed to in writing, software
23  * distributed under the License is distributed on an "AS IS" BASIS,
24  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25  * See the License for the specific language governing permissions and
26  * limitations under the License.
27  *
28  *=========================================================================*/
29 #ifndef itkCurvilinearArraySpecialCoordinatesImage_h
30 #define itkCurvilinearArraySpecialCoordinatesImage_h
31 
32 #include "itkSpecialCoordinatesImage.h"
33 #include "itkPoint.h"
34 #include "vnl/vnl_math.h"
35 #include "itkNeighborhoodAccessorFunctor.h"
36 
37 namespace itk
38 {
98 template< typename TPixel, unsigned int VDimension >
100  public SpecialCoordinatesImage< TPixel, VDimension >
101 {
102 public:
105  typedef SpecialCoordinatesImage< TPixel, VDimension > Superclass;
108  typedef WeakPointer< const Self > ConstWeakPointer;
109 
111  itkNewMacro(Self);
112 
114  itkTypeMacro(CurvilinearArraySpecialCoordinatesImage, SpecialCoordinatesImage);
115 
118  typedef TPixel PixelType;
119 
121  typedef TPixel ValueType;
122 
127  typedef TPixel InternalPixelType;
128 
129  typedef typename Superclass::IOPixelType IOPixelType;
130 
133  typedef DefaultPixelAccessor< PixelType > AccessorType;
134 
138  typedef DefaultPixelAccessorFunctor< Self > AccessorFunctorType;
139 
142  typedef NeighborhoodAccessorFunctor< Self > NeighborhoodAccessorFunctorType;
143 
148  itkStaticConstMacro(ImageDimension, unsigned int, VDimension);
149 
151  typedef typename Superclass::IndexType IndexType;
152  typedef typename Superclass::IndexValueType IndexValueType;
153 
155  typedef typename Superclass::OffsetType OffsetType;
156 
158  typedef typename Superclass::SizeType SizeType;
159  typedef typename Superclass::SizeValueType SizeValueType;
160 
162  typedef ImportImageContainer< SizeValueType, PixelType > PixelContainer;
163 
167  typedef typename Superclass::RegionType RegionType;
168 
175  typedef typename Superclass::SpacingType SpacingType;
176 
181  typedef typename Superclass::PointType PointType;
182 
184  typedef typename PixelContainer::Pointer PixelContainerPointer;
185  typedef typename PixelContainer::ConstPointer PixelContainerConstPointer;
186 
197  virtual void Graft(const DataObject *data) ITK_OVERRIDE;
198 
203  template< typename TCoordRep >
205  const Point< TCoordRep, VDimension > & point,
206  ContinuousIndex< TCoordRep, VDimension > & index) const
207  {
208  const RegionType & region = this->GetLargestPossibleRegion();
209  const double maxLateral = region.GetSize(1) - 1;
210 
211  // Convert Cartesian coordinates into angular coordinates
212  const TCoordRep lateral = std::atan(point[0] / point[1]);
213  const TCoordRep radius = std::sqrt(point[0] * point[0] + point[1] * point[1] );
214 
215  // Convert the "proper" angular coordinates into index format
216  index[0] = static_cast< TCoordRep >( ( ( radius - m_FirstSampleDistance )
217  / m_RadiusSampleSize ) );
218  index[1] = static_cast< TCoordRep >( ( lateral / m_LateralAngularSeparation )
219  + ( maxLateral / 2.0 ) );
220 
221  // Now, check to see if the index is within allowed bounds
222  const bool isInside = region.IsInside(index);
223 
224  return isInside;
225  }
226 
231  template< typename TCoordRep >
233  const Point< TCoordRep, VDimension > & point,
234  IndexType & index) const
235  {
236  const RegionType & region = this->GetLargestPossibleRegion();
237  const double maxLateral = region.GetSize(1) - 1;
238 
239  // Convert Cartesian coordinates into angular coordinates
240  const TCoordRep lateral = std::atan(point[0] / point[1]);
241  const TCoordRep radius = std::sqrt(point[0] * point[0] + point[1] * point[1] );
242 
243  // Convert the "proper" angular coordinates into index format
244  index[0] = static_cast< IndexValueType >( ( ( radius - m_FirstSampleDistance )
245  / m_RadiusSampleSize ) );
246  index[1] = static_cast< IndexValueType >( ( lateral / m_LateralAngularSeparation )
247  + ( maxLateral / 2.0 ) );
248 
249  // Now, check to see if the index is within allowed bounds
250  const bool isInside = region.IsInside(index);
251 
252  return isInside;
253  }
254 
259  template< typename TCoordRep >
261  const ContinuousIndex< TCoordRep, VDimension > & index,
262  Point< TCoordRep, VDimension > & point) const
263  {
264  const RegionType & region = this->GetLargestPossibleRegion();
265  const double maxLateral = region.GetSize(1) - 1;
266 
267  // Convert the index into proper angular coordinates
268  const TCoordRep radius = ( index[0] * m_RadiusSampleSize ) + m_FirstSampleDistance;
269  const TCoordRep lateral = ( index[1] - ( maxLateral / 2.0 ) ) * m_LateralAngularSeparation;
270 
271  // Convert the angular coordinates into Cartesian coordinates
272  point[0] = static_cast< TCoordRep >( radius * std::sin(lateral) );
273  point[1] = static_cast< TCoordRep >( radius * std::cos(lateral) );
274  }
275 
281  template< typename TCoordRep >
283  const IndexType & index,
284  Point< TCoordRep, VDimension > & point) const
285  {
286  const RegionType & region = this->GetLargestPossibleRegion();
287  const double maxLateral = region.GetSize(1) - 1;
288 
289  // Convert the index into proper angular coordinates
290  const TCoordRep radius = ( index[0] * m_RadiusSampleSize ) + m_FirstSampleDistance;
291  const TCoordRep lateral = ( index[1] - ( maxLateral / 2.0 ) ) * m_LateralAngularSeparation;
292 
293  // Convert the angular coordinates into Cartesian coordinates
294  point[0] = static_cast< TCoordRep >( radius * std::sin(lateral) );
295  point[1] = static_cast< TCoordRep >( radius * std::cos(lateral) );
296  }
297 
299  itkSetMacro(LateralAngularSeparation, double);
300  itkGetConstMacro(LateralAngularSeparation, double);
301 
303  itkSetMacro(RadiusSampleSize, double);
304  itkGetConstMacro(RadiusSampleSize, double);
305 
307  itkSetMacro(FirstSampleDistance, double);
308  itkGetConstMacro(FirstSampleDistance, double);
309 
310  template< typename TCoordRep >
312  FixedArray< TCoordRep, VDimension > & ) const
313  {}
314 
315  template< typename TCoordRep >
317  const FixedArray< TCoordRep, VDimension > & ,
318  FixedArray< TCoordRep, VDimension > & ) const
319  {}
320 
321 protected:
323  {
324  m_RadiusSampleSize = 1;
325  m_LateralAngularSeparation = 1 * ( 2.0 * vnl_math::pi / 360.0 ); // 1
326  // degree
327  m_FirstSampleDistance = 0;
328  }
329 
331  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
332 
333 private:
334  CurvilinearArraySpecialCoordinatesImage(const Self &); // purposely not implemented
335  void operator=(const Self &); // purposely not implemented
336 
337  double m_LateralAngularSeparation; // in radians
338  double m_RadiusSampleSize;
339  double m_FirstSampleDistance;
340 };
341 } // end namespace itk
342 
343 #ifndef ITK_MANUAL_INSTANTIATION
344 #include "itkCurvilinearArraySpecialCoordinatesImage.hxx"
345 #endif
346 
347 #endif
void TransformPhysicalVectorToLocalVector(const FixedArray< TCoordRep, VDimension > &, FixedArray< TCoordRep, VDimension > &) const
virtual void Graft(const DataObject *data) ITK_OVERRIDE
Templated 2D nonrectilinear-coordinate image class for curvilinear/phased-array "range" images...
void TransformIndexToPhysicalPoint(const IndexType &index, Point< TCoordRep, VDimension > &point) const
virtual void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE
ImportImageContainer< SizeValueType, PixelType > PixelContainer
bool TransformPhysicalPointToContinuousIndex(const Point< TCoordRep, VDimension > &point, ContinuousIndex< TCoordRep, VDimension > &index) const
Get the continuous index from a physical point.
bool TransformPhysicalPointToIndex(const Point< TCoordRep, VDimension > &point, IndexType &index) const
void TransformLocalVectorToPhysicalVector(FixedArray< TCoordRep, VDimension > &) const
void TransformContinuousIndexToPhysicalPoint(const ContinuousIndex< TCoordRep, VDimension > &index, Point< TCoordRep, VDimension > &point) const
itkStaticConstMacro(ImageDimension, unsigned int, VDimension)