Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkToFProcessingCommon.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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef MITKTOFPROCESSINGCOMMON_H
18 #define MITKTOFPROCESSINGCOMMON_H
19 
20 #include <MitkToFProcessingExports.h>
21 #include <mitkCameraIntrinsics.h>
22 #include "mitkNumericTypes.h"
23 #include <vnl/vnl_math.h>
24 
25 namespace mitk
26 {
42  class MITKTOFPROCESSING_EXPORT ToFProcessingCommon
43  {
44  public:
45  typedef double ToFScalarType;
46  typedef itk::Point<ToFScalarType, 2> ToFPoint2D;
47  typedef itk::Point<ToFScalarType, 3> ToFPoint3D;
48  typedef itk::Vector<ToFScalarType, 2> ToFVector2D;
49  typedef itk::Vector<ToFScalarType, 3> ToFVector3D;
50 
62  static ToFPoint3D IndexToCartesianCoordinates(unsigned int i, unsigned int j, ToFScalarType distance,
63  ToFScalarType focalLengthX, ToFScalarType focalLengthY, ToFScalarType principalPointX, ToFScalarType principalPointY);
64 
74  inline static ToFPoint3D IndexToCartesianCoordinates(unsigned int i, unsigned int j, ToFScalarType distance,
75  ToFPoint2D focalLength, ToFPoint2D principalPoint)
76  {
77  return IndexToCartesianCoordinates(i,j,distance,focalLength[0],focalLength[1],principalPoint[0],principalPoint[1]);
78  }
79 
88  inline static ToFPoint3D IndexToCartesianCoordinates(itk::Index<3> index, ToFScalarType distance,
89  ToFPoint2D focalLength, ToFPoint2D principalPoint)
90  {
91  return IndexToCartesianCoordinates(index[0],index[1],distance,focalLength[0],focalLength[1],principalPoint[0], principalPoint[1]);
92  }
102  inline static ToFPoint3D IndexToCartesianCoordinates(unsigned int i, unsigned int j, ToFScalarType distance,
103  ToFScalarType focalLength[2], ToFScalarType principalPoint[2])
104  {
105  return IndexToCartesianCoordinates(i,j,distance,focalLength[0],focalLength[1],principalPoint[0],principalPoint[1]);
106  }
107 
108 
121  static ToFPoint3D IndexToCartesianCoordinatesWithInterpixdist(unsigned int i, unsigned int j, ToFScalarType distance, ToFScalarType focalLength,
122  ToFScalarType interPixelDistanceX, ToFScalarType interPixelDistanceY, ToFScalarType principalPointX, ToFScalarType principalPointY);
123 
134  inline static ToFPoint3D IndexToCartesianCoordinatesWithInterpixdist(unsigned int i, unsigned int j, ToFScalarType distance, ToFScalarType focalLength,
135  ToFPoint2D interPixelDistance, ToFPoint2D principalPoint)
136  {
137  return IndexToCartesianCoordinatesWithInterpixdist(i,j,distance,focalLength,interPixelDistance[0],interPixelDistance[1],principalPoint[0],principalPoint[1]);
138  }
148  inline static ToFPoint3D IndexToCartesianCoordinatesWithInterpixdist(itk::Index<3> index, ToFScalarType distance, ToFScalarType focalLength,
149  ToFPoint2D interPixelDistance, ToFPoint2D principalPoint)
150  {
151  return IndexToCartesianCoordinatesWithInterpixdist(index[0],index[1],distance,focalLength,interPixelDistance[0], interPixelDistance[1],principalPoint[0], principalPoint[1]);
152  }
163  inline static ToFPoint3D IndexToCartesianCoordinatesWithInterpixdist(unsigned int i, unsigned int j, ToFScalarType distance, ToFScalarType focalLength,
164  ToFScalarType interPixelDistance[2], ToFScalarType principalPoint[2])
165  {
166  return IndexToCartesianCoordinatesWithInterpixdist(i,j,distance,focalLength,interPixelDistance[0],interPixelDistance[1],principalPoint[0],principalPoint[1]);
167  }
168 
169 
182  static ToFPoint3D CartesianToIndexCoordinates(ToFScalarType cartesianPointX, ToFScalarType cartesianPointY,ToFScalarType cartesianPointZ,
183  ToFScalarType focalLengthX, ToFScalarType focalLengthY,
184  ToFScalarType principalPointX, ToFScalarType principalPointY, bool calculateDistance=true);
185 
194  inline static ToFPoint3D CartesianToIndexCoordinates(ToFScalarType cartesianPoint[3], ToFScalarType focalLength[2],
195  ToFScalarType principalPoint[2], bool calculateDistance=true)
196  {
197  return CartesianToIndexCoordinates(cartesianPoint[0],cartesianPoint[1],cartesianPoint[2],focalLength[0], focalLength[1],
198  principalPoint[0],principalPoint[1],calculateDistance);
199  }
208  inline static ToFPoint3D CartesianToIndexCoordinates(ToFPoint3D cartesianPoint, ToFPoint2D focalLength,
209  ToFPoint2D principalPoint, bool calculateDistance=true)
210  {
211  return CartesianToIndexCoordinates(cartesianPoint[0],cartesianPoint[1],cartesianPoint[2],focalLength[0], focalLength[1],
212  principalPoint[0],principalPoint[1],calculateDistance);
213  }
214 
215 
229  static ToFPoint3D CartesianToIndexCoordinatesWithInterpixdist(ToFScalarType cartesianPointX, ToFScalarType cartesianPointY,ToFScalarType cartesianPointZ,
230  ToFScalarType focalLength, ToFScalarType interPixelDistanceX, ToFScalarType interPixelDistanceY,
231  ToFScalarType principalPointX, ToFScalarType principalPointY, bool calculateDistance=true);
232 
242  inline static ToFPoint3D CartesianToIndexCoordinatesWithInterpixdist(ToFScalarType cartesianPoint[3], ToFScalarType focalLength,
243  ToFScalarType interPixelDistance[2], ToFScalarType principalPoint[2],
244  bool calculateDistance=true)
245  {
246  return CartesianToIndexCoordinatesWithInterpixdist(cartesianPoint[0],cartesianPoint[1],cartesianPoint[2],focalLength,
247  interPixelDistance[0],interPixelDistance[1],principalPoint[0],principalPoint[1],calculateDistance);
248  }
258  inline static ToFPoint3D CartesianToIndexCoordinatesWithInterpixdist(ToFPoint3D cartesianPoint, ToFScalarType focalLength,
259  ToFPoint2D interPixelDistance, ToFPoint2D principalPoint, bool calculateDistance=true)
260  {
261  return CartesianToIndexCoordinatesWithInterpixdist(cartesianPoint[0],cartesianPoint[1],cartesianPoint[2],focalLength,
262  interPixelDistance[0],interPixelDistance[1],principalPoint[0],principalPoint[1],calculateDistance);
263  }
264 
278  static ToFProcessingCommon::ToFPoint3D KinectIndexToCartesianCoordinates(unsigned int i, unsigned int j, ToFScalarType distance, ToFScalarType focalLengthX, ToFScalarType focalLengthY, ToFScalarType principalPointX, ToFScalarType principalPointY);
279 
280  inline static ToFPoint3D KinectIndexToCartesianCoordinates(unsigned int i, unsigned int j, ToFScalarType distance,
281  ToFScalarType focalLength[2], ToFScalarType principalPoint[2])
282  {
283  return KinectIndexToCartesianCoordinates(i,j,distance,focalLength[0],focalLength[1],principalPoint[0],principalPoint[1]);
284  }
285 
286  inline static ToFPoint3D KinectIndexToCartesianCoordinates(unsigned int i, unsigned int j, ToFScalarType distance,
287  ToFPoint2D focalLength, ToFPoint2D principalPoint)
288  {
289  return KinectIndexToCartesianCoordinates(i,j,distance,focalLength[0],focalLength[1],principalPoint[0],principalPoint[1]);
290  }
291 
292  inline static ToFPoint3D KinectIndexToCartesianCoordinates(itk::Index<3> index, ToFScalarType distance, ToFPoint2D focalLength, ToFPoint2D principalPoint)
293  {
294  return KinectIndexToCartesianCoordinates(index[0],index[1],distance,focalLength[0],focalLength[1],principalPoint[0], principalPoint[1]);
295  }
310  static ToFPoint3D CartesianToKinectIndexCoordinates(ToFScalarType cartesianPointX, ToFScalarType cartesianPointY,
311  ToFScalarType cartesianPointZ, ToFScalarType focalLengthX,
312  ToFScalarType focalLengthY, ToFScalarType principalPointX,
313  ToFScalarType principalPointY, bool calculateDistance=true);
314 
315  inline static ToFProcessingCommon::ToFPoint3D CartesianToKinectIndexCoordinates(ToFPoint3D cartesianPoint, ToFPoint2D focalLength, ToFPoint2D principalPoint, bool calculateDistance=true)
316  {
317  return CartesianToKinectIndexCoordinates( cartesianPoint[0], cartesianPoint[1], cartesianPoint[2], focalLength[0], focalLength[1], principalPoint[0], principalPoint[1], calculateDistance);
318  }
333  static ToFProcessingCommon::ToFPoint3D ContinuousKinectIndexToCartesianCoordinates(mitk::Point2D continuousIndex, ToFScalarType distance, ToFScalarType focalLengthX, ToFScalarType focalLengthY, ToFScalarType principalPointX, ToFScalarType principalPointY);
334 
342  static ToFScalarType CalculateViewAngle(mitk::CameraIntrinsics::Pointer intrinsics, unsigned int dimX);
343  };
344 }
345 #endif
itk::Vector< ToFScalarType, 3 > ToFVector3D
itk::SmartPointer< Self > Pointer
static ToFPoint3D IndexToCartesianCoordinates(unsigned int i, unsigned int j, ToFScalarType distance, ToFPoint2D focalLength, ToFPoint2D principalPoint)
Convert index based distances to cartesian coordinates.
static ToFPoint3D IndexToCartesianCoordinatesWithInterpixdist(itk::Index< 3 > index, ToFScalarType distance, ToFScalarType focalLength, ToFPoint2D interPixelDistance, ToFPoint2D principalPoint)
Convert index based distances to cartesian coordinates.
DataCollection - Class to facilitate loading/accessing structured data.
static ToFPoint3D KinectIndexToCartesianCoordinates(unsigned int i, unsigned int j, ToFScalarType distance, ToFScalarType focalLength[2], ToFScalarType principalPoint[2])
KinectIndexToCartesianCoordinates Convert a pixel (i,j) with value d to a 3D world point...
static ToFPoint3D KinectIndexToCartesianCoordinates(itk::Index< 3 > index, ToFScalarType distance, ToFPoint2D focalLength, ToFPoint2D principalPoint)
KinectIndexToCartesianCoordinates Convert a pixel (i,j) with value d to a 3D world point...
static ToFPoint3D IndexToCartesianCoordinates(unsigned int i, unsigned int j, ToFScalarType distance, ToFScalarType focalLength[2], ToFScalarType principalPoint[2])
Convenience method to convert index based distances to cartesian coordinates using array as input...
itk::Point< ToFScalarType, 2 > ToFPoint2D
itk::Point< ToFScalarType, 3 > ToFPoint3D
static ToFPoint3D CartesianToIndexCoordinates(ToFScalarType cartesianPoint[3], ToFScalarType focalLength[2], ToFScalarType principalPoint[2], bool calculateDistance=true)
Convenience method to convert cartesian coordinates to index based distances using arrays...
Helper class providing functions which are useful for multiple usage.
static ToFPoint3D CartesianToIndexCoordinatesWithInterpixdist(ToFPoint3D cartesianPoint, ToFScalarType focalLength, ToFPoint2D interPixelDistance, ToFPoint2D principalPoint, bool calculateDistance=true)
Convert cartesian coordinates to index based distances.
static ToFPoint3D IndexToCartesianCoordinatesWithInterpixdist(unsigned int i, unsigned int j, ToFScalarType distance, ToFScalarType focalLength, ToFScalarType interPixelDistance[2], ToFScalarType principalPoint[2])
Convenience method to convert index based distances to cartesian coordinates using array as input...
static ToFPoint3D KinectIndexToCartesianCoordinates(unsigned int i, unsigned int j, ToFScalarType distance, ToFPoint2D focalLength, ToFPoint2D principalPoint)
KinectIndexToCartesianCoordinates Convert a pixel (i,j) with value d to a 3D world point...
itk::Vector< ToFScalarType, 2 > ToFVector2D
static ToFPoint3D IndexToCartesianCoordinatesWithInterpixdist(unsigned int i, unsigned int j, ToFScalarType distance, ToFScalarType focalLength, ToFPoint2D interPixelDistance, ToFPoint2D principalPoint)
Convert index based distances to cartesian coordinates.
static ToFProcessingCommon::ToFPoint3D CartesianToKinectIndexCoordinates(ToFPoint3D cartesianPoint, ToFPoint2D focalLength, ToFPoint2D principalPoint, bool calculateDistance=true)
CartesianCoordinatesToKinectIndexCoordinates Transform a 3D world point back to distance image pixel ...
static ToFPoint3D IndexToCartesianCoordinates(itk::Index< 3 > index, ToFScalarType distance, ToFPoint2D focalLength, ToFPoint2D principalPoint)
Convert index based distances to cartesian coordinates.
static ToFPoint3D CartesianToIndexCoordinatesWithInterpixdist(ToFScalarType cartesianPoint[3], ToFScalarType focalLength, ToFScalarType interPixelDistance[2], ToFScalarType principalPoint[2], bool calculateDistance=true)
Convenience method to convert cartesian coordinates to index based distances using arrays...
static ToFPoint3D CartesianToIndexCoordinates(ToFPoint3D cartesianPoint, ToFPoint2D focalLength, ToFPoint2D principalPoint, bool calculateDistance=true)
Convert cartesian coordinates to index based distances.