File: vtkDijkstraImageGeodesicPath.h

package info (click to toggle)
vtk9 9.5.2%2Bdfsg3-6
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 205,984 kB
  • sloc: cpp: 2,336,570; ansic: 327,116; python: 111,200; yacc: 4,104; java: 3,977; sh: 3,032; xml: 2,771; perl: 2,189; lex: 1,787; makefile: 181; javascript: 165; objc: 153; tcl: 59
file content (127 lines) | stat: -rw-r--r-- 4,346 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
/**
 * @class   vtkDijkstraImageGeodesicPath
 * @brief   Dijkstra algorithm to compute the graph geodesic.
 *
 * Takes as input a polyline and an image representing a 2D cost function
 * and performs a single source shortest path calculation.
 * Dijkstra's algorithm is used. The implementation is
 * similar to the one described in Introduction to Algorithms (Second Edition)
 * by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and
 * Cliff Stein, published by MIT Press and McGraw-Hill. Some minor
 * enhancement are added though. All vertices are not pushed on the heap
 * at start, instead a front set is maintained. The heap is implemented as
 * a binary heap. The output of the filter is a set of lines describing
 * the shortest path from StartVertex to EndVertex.  See parent class
 * vtkDijkstraGraphGeodesicPath for the implementation.
 *
 * @warning
 * The input cost image must have only VTK_PIXEL cells: i.e., a 2D image or
 * slice of a 3D volume. A cost function for a gray scale image might
 * be generated by the following pipeline:
 * vtkImageData->vtkImageGradientMagnitude->vtkImageShiftScale
 * wherein the gradient magnitude image is inverted so that strong edges
 * have low cost value.  Costs in moving from a vertex v to a vertex u
 * are calculated using a weighted additive scheme:
 * cost = Iw*f(I) + Ew*f(u,v) + Cw*f(t,u,v)
 * where Iw is the weight associated with f(I): the normalized image cost,
 * Ew is the weight associated with f(u,v): the normalized distance between
 * vertices u and v, and Cw is the weight associated with f(t,u,v):
 * the normalized curvature calculated from the vertex t which precedes
 * vertex u, and vertices u and v.  All weights range from 0 to 1.
 *
 * @par Thanks:
 * The class was contributed by Dean Inglis.
 */

#ifndef vtkDijkstraImageGeodesicPath_h
#define vtkDijkstraImageGeodesicPath_h

#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_5_0
#include "vtkDijkstraGraphGeodesicPath.h"
#include "vtkFiltersModelingModule.h" // For export macro

VTK_ABI_NAMESPACE_BEGIN
class vtkImageData;

class VTKFILTERSMODELING_EXPORT vtkDijkstraImageGeodesicPath : public vtkDijkstraGraphGeodesicPath
{
public:
  /**
   * Instantiate the class
   */
  static vtkDijkstraImageGeodesicPath* New();

  ///@{
  /**
   * Standard methods for printing and determining type information.
   */
  vtkTypeMacro(vtkDijkstraImageGeodesicPath, vtkDijkstraGraphGeodesicPath);
  void PrintSelf(ostream& os, vtkIndent indent) override;
  ///@}

  ///@{
  /**
   * Specify the image object which is used as a cost function.
   */
  void SetInputData(vtkDataObject*);
  vtkImageData* GetImageDataInput();
  VTK_DEPRECATED_IN_9_5_0("Use GetImageDataInput() instead.")
  vtkImageData* GetInputAsImageData() { return this->GetImageDataInput(); }
  ///@}

  ///@{
  /**
   * Image cost weight.
   */
  void SetImageWeight(double);
  vtkGetMacro(ImageWeight, double);
  ///@}

  ///@{
  /**
   * Edge length cost weight.
   */
  void SetEdgeLengthWeight(double);
  vtkGetMacro(EdgeLengthWeight, double);
  ///@}

  ///@{
  /**
   * Curvature cost weight.
   */
  vtkSetClampMacro(CurvatureWeight, double, 0.0, 1.0);
  vtkGetMacro(CurvatureWeight, double);
  ///@}

protected:
  vtkDijkstraImageGeodesicPath();
  ~vtkDijkstraImageGeodesicPath() override;

  int FillInputPortInformation(int port, vtkInformation* info) override;
  int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;

  // Build a graph description of the image
  void BuildAdjacency(vtkDataSet* inData) override;

  // Update static costs without rebuilding adjacencyh when static weights change
  void UpdateStaticCosts(vtkImageData* image);

  // Override parent class methods.
  double CalculateStaticEdgeCost(vtkDataSet* inData, vtkIdType u, vtkIdType v) override;
  double CalculateDynamicEdgeCost(vtkDataSet* inData, vtkIdType u, vtkIdType v) override;

  double PixelSize;
  double ImageWeight;
  double EdgeLengthWeight;
  double CurvatureWeight;
  bool RebuildStaticCosts;

private:
  vtkDijkstraImageGeodesicPath(const vtkDijkstraImageGeodesicPath&) = delete;
  void operator=(const vtkDijkstraImageGeodesicPath&) = delete;
};

VTK_ABI_NAMESPACE_END
#endif