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