Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
itkShortestPathCostFunctionTbss.txx
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 #ifndef __itkShortestPathCostFunctionTbss_cpp
13 #define __itkShortestPathCostFunctionTbss_cpp
14 
15 #include <limits>
16 
17 namespace itk
18 {
19  // Constructor
20  template <class TInputImageType>
21  ShortestPathCostFunctionTbss<TInputImageType>::ShortestPathCostFunctionTbss()
22  {
23  }
24 
25  template <class TInputImageType>
26  double ShortestPathCostFunctionTbss<TInputImageType>::GetCost(IndexType p1, IndexType p2)
27  {
28  // Cost function for tbss tract definition
29  double c;
30 
31  if (this->m_Image->GetPixel(p2) < m_Threshold)
32  {
33  c = std::numeric_limits<double>::max();
34  }
35  else
36  {
37  double dxSqt = (p1[0] - p2[0]) * (p1[0] - p2[0]); // * (p1[0]-p2[0]);
38  double dySqt = (p1[1] - p2[1]) * (p1[1] - p2[1]);
39  double dzSqt = (p1[2] - p2[2]) * (p1[2] - p2[2]);
40 
41  double weight = this->m_Image->GetPixel(p2);
42 
43  c = sqrt(dxSqt + dySqt + dzSqt) + 1000 * (1 - weight);
44  }
45 
46  return c;
47  }
48 
49  template <class TInputImageType>
50  void ShortestPathCostFunctionTbss<TInputImageType>::Initialize()
51  {
52  }
53 
54  template <class TInputImageType>
55  double ShortestPathCostFunctionTbss<TInputImageType>::GetMinCost()
56  {
57  return 1;
58  }
59 
60 } // end namespace itk
61 
62 #endif // __itkShortestPathCostFunctionSimple_txx