forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkImageAnisotropicDiffusion3D.h
138 lines (120 loc) · 4.81 KB
/
vtkImageAnisotropicDiffusion3D.h
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
128
129
130
131
132
133
134
135
136
137
138
/*=========================================================================
Program: Visualization Toolkit
Module: vtkImageAnisotropicDiffusion3D.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.
=========================================================================*/
/**
* @class vtkImageAnisotropicDiffusion3D
* @brief edge preserving smoothing.
*
*
* vtkImageAnisotropicDiffusion3D diffuses an volume iteratively.
* The neighborhood of the diffusion is determined by the instance
* flags. if "Faces" is on, the 6 voxels adjoined by faces are included
* in the neighborhood. If "Edges" is on the 12 edge connected voxels
* are included, and if "Corners" is on, the 8 corner connected voxels
* are included. "DiffusionFactor" determines how far a pixel value
* moves toward its neighbors, and is insensitive to the number of
* neighbors chosen. The diffusion is anisotropic because it only occurs
* when a gradient measure is below "GradientThreshold". Two gradient measures
* exist and are toggled by the "GradientMagnitudeThreshold" flag.
* When "GradientMagnitudeThreshold" is on, the magnitude of the gradient,
* computed by central differences, above "DiffusionThreshold"
* a voxel is not modified. The alternative measure examines each
* neighbor independently. The gradient between the voxel and the neighbor
* must be below the "DiffusionThreshold" for diffusion to occur with
* THAT neighbor.
*
* @sa
* vtkImageAnisotropicDiffusion2D
*/
#ifndef vtkImageAnisotropicDiffusion3D_h
#define vtkImageAnisotropicDiffusion3D_h
#include "vtkImageSpatialAlgorithm.h"
#include "vtkImagingGeneralModule.h" // For export macro
class VTKIMAGINGGENERAL_EXPORT vtkImageAnisotropicDiffusion3D : public vtkImageSpatialAlgorithm
{
public:
static vtkImageAnisotropicDiffusion3D* New();
vtkTypeMacro(vtkImageAnisotropicDiffusion3D, vtkImageSpatialAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent) override;
/**
* This method sets the number of iterations which also affects the
* input neighborhood needed to compute one output pixel. Each iterations
* requires an extra pixel layer on the neighborhood. This is only relevant
* when you are trying to stream or are requesting a sub extent of the "wholeExtent".
*/
void SetNumberOfIterations(int num);
///@{
/**
* Get the number of iterations.
*/
vtkGetMacro(NumberOfIterations, int);
///@}
///@{
/**
* Set/Get the difference threshold that stops diffusion.
* when the difference between two pixel is greater than this threshold,
* the pixels are not diffused. This causes diffusion to avoid sharp edges.
* If the GradientMagnitudeThreshold is set, then gradient magnitude is used
* for comparison instead of pixel differences.
*/
vtkSetMacro(DiffusionThreshold, double);
vtkGetMacro(DiffusionThreshold, double);
///@}
///@{
/**
* Set/Get the difference factor
*/
vtkSetMacro(DiffusionFactor, double);
vtkGetMacro(DiffusionFactor, double);
///@}
///@{
/**
* Choose neighbors to diffuse (6 faces, 12 edges, 8 corners).
*/
vtkSetMacro(Faces, vtkTypeBool);
vtkGetMacro(Faces, vtkTypeBool);
vtkBooleanMacro(Faces, vtkTypeBool);
vtkSetMacro(Edges, vtkTypeBool);
vtkGetMacro(Edges, vtkTypeBool);
vtkBooleanMacro(Edges, vtkTypeBool);
vtkSetMacro(Corners, vtkTypeBool);
vtkGetMacro(Corners, vtkTypeBool);
vtkBooleanMacro(Corners, vtkTypeBool);
///@}
///@{
/**
* Switch between gradient magnitude threshold and pixel gradient threshold.
*/
vtkSetMacro(GradientMagnitudeThreshold, vtkTypeBool);
vtkGetMacro(GradientMagnitudeThreshold, vtkTypeBool);
vtkBooleanMacro(GradientMagnitudeThreshold, vtkTypeBool);
///@}
protected:
vtkImageAnisotropicDiffusion3D();
~vtkImageAnisotropicDiffusion3D() override = default;
int NumberOfIterations;
double DiffusionThreshold;
double DiffusionFactor;
// to determine which neighbors to diffuse
vtkTypeBool Faces;
vtkTypeBool Edges;
vtkTypeBool Corners;
// What threshold to use
vtkTypeBool GradientMagnitudeThreshold;
void ThreadedRequestData(vtkInformation* request, vtkInformationVector** inputVector,
vtkInformationVector* outputVector, vtkImageData*** inData, vtkImageData** outData,
int outExt[6], int id) override;
void Iterate(vtkImageData* in, vtkImageData* out, double ar0, double ar1, double ar2,
int* coreExtent, int count);
private:
vtkImageAnisotropicDiffusion3D(const vtkImageAnisotropicDiffusion3D&) = delete;
void operator=(const vtkImageAnisotropicDiffusion3D&) = delete;
};
#endif