File: vtkDijkstraImageGeodesicPath.h

package info (click to toggle)
vtk6 6.3.0%2Bdfsg2-8.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 118,972 kB
  • sloc: cpp: 1,442,790; ansic: 113,395; python: 72,383; tcl: 46,998; xml: 8,119; yacc: 4,525; java: 4,239; perl: 3,108; lex: 1,694; sh: 1,093; asm: 154; makefile: 68; objc: 17
file content (121 lines) | stat: -rw-r--r-- 4,633 bytes parent folder | download | duplicates (5)
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
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkDijkstraImageGeodesicPath.h

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
// .NAME vtkDijkstraImageGeodesicPath - Dijkstra algorithm to compute the graph geodesic.
// .SECTION Description
// 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.
//
// .SECTION Caveats
// 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 sheme:
// 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.
//
// .SECTION Thanks
// The class was contributed by Dean Inglis.


#ifndef vtkDijkstraImageGeodesicPath_h
#define vtkDijkstraImageGeodesicPath_h

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

class vtkImageData;

class VTKFILTERSMODELING_EXPORT vtkDijkstraImageGeodesicPath :
                           public vtkDijkstraGraphGeodesicPath
{
public:

  // Description:
  // Instantiate the class
  static vtkDijkstraImageGeodesicPath *New();

  // Description:
  // Standard methids for printing and determining type information.
  vtkTypeMacro( vtkDijkstraImageGeodesicPath, vtkDijkstraGraphGeodesicPath );
  void PrintSelf( ostream& os, vtkIndent indent );

  // Description:
  // Specify the image object which is used as a cost function.
  void SetInputData( vtkDataObject* );
  vtkImageData* GetInputAsImageData();

  // Description:
  // Image cost weight.
  void SetImageWeight( double );
  vtkGetMacro( ImageWeight, double );

  // Description:
  // Edge length cost weight.
  void SetEdgeLengthWeight( double );
  vtkGetMacro( EdgeLengthWeight, double );

  // Description:
  // Curvature cost weight.
  vtkSetClampMacro( CurvatureWeight, double, 0.0, 1.0 );
  vtkGetMacro( CurvatureWeight, double );

protected:
  vtkDijkstraImageGeodesicPath();
  ~vtkDijkstraImageGeodesicPath();

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

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

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

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

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

private:
  vtkDijkstraImageGeodesicPath(const vtkDijkstraImageGeodesicPath&);  // Not implemented.
  void operator=(const vtkDijkstraImageGeodesicPath&);  // Not implemented.

};

#endif