CTL  0.6.1
Computed Tomography Library
regularizers.h
1 #ifndef CTL_REGULARIZERS_H
2 #define CTL_REGULARIZERS_H
3 
4 #include <QObject>
5 
6 #include "processing/abstractvolumefilter.h"
7 
8 namespace CTL {
9 
19 {
21 
22  public: void filter(VoxelVolume<float>& volume) override;
23 };
24 
70 {
72  Q_GADGET
73 
74  public: void filter(VoxelVolume<float>& volume) override;
75 
76 public:
77  enum NeighborHood { Box3x3x3, NearestOnly };
78  Q_ENUM(NeighborHood)
79 
80  explicit MedianFilterRegularizer(float strength = 0.1f, NeighborHood neighbors = NearestOnly);
81 
82  void setNeighborHoodType(NeighborHood neighbors);
83  void setRegularizationStrength(float strength);
84 
85  // AbstractVolumeFilter interface
86  QVariant parameter() const override;
87  void setParameter(const QVariant& parameter) override;
88 
89 private:
90  float _strength = 0.1f;
91  NeighborHood _neighbors = NearestOnly;
92 
93  void applyMedian3(VoxelVolume<float>& volume);
94  void applyMedianNN(VoxelVolume<float>& volume);
95 
96  static QMetaEnum metaEnum();
97 };
98 
125 {
127  Q_GADGET
128 
129  public: void filter(VoxelVolume<float>& volume) override;
130 
131 public:
132  enum NeighborHood { Box3x3x3, NearestOnly };
133  Q_ENUM(NeighborHood)
134 
135  explicit TVRegularizer(float maxChangeIn10HU = 1.0f, NeighborHood neighbors = NearestOnly);
136 
137  void setNeighborHoodType(NeighborHood neighbors);
138  void setRegularizationStrength(float maxChangeIn10HU); // max change in 10 HU
139 
140  // AbstractVolumeFilter interface
141  QVariant parameter() const override;
142  void setParameter(const QVariant& parameter) override;
143 
144 private:
145  static constexpr float _step = 0.02269f / 1000.0f; // ~1 HU (at 50 keV)
146  float _strength = 10.0f; // default 10 HU max. change
147  NeighborHood _neighbors = NearestOnly;
148 
149  void applyTV3(VoxelVolume<float>& volume);
150  void applyTVNN(VoxelVolume<float>& volume);
151 
152  static QMetaEnum metaEnum();
153 };
154 
185 {
187 
188  public: void filter(VoxelVolume<float>& volume) override;
189 
190 public:
191  explicit HuberRegularizer(float strength = 1.0f, float huberEdgeIn100HU = 1.0,
192  float weightZ = 1.0f, float weightXY = 1.0f,
193  float directZweight = 1.0f);
194 
195  void setRegularizationStrength(float strength);
196  void setHuberEdge(float edgeIn100HU);
197  void setRelativeWeighting(float weightZ, float weightXY = 1.0f);
198  void setDirectZNeighborWeight(float weight);
199 
200  // AbstractVolumeFilter interface
201  QVariant parameter() const override;
202  void setParameter(const QVariant& parameter) override;
203 
204 private:
205  float _strength = 0.01f;
206  float _huberEdge = 100.0f * 0.02269f/1000.0f;
207  float _betaZ = 1.0f;
208  float _betaXY = 1.0f;
209  float _directZ = 1.0f;
210 };
211 
212 namespace assist {
213 constexpr float clamp(float val, float low, float high)
214 {
215  return (val<low) ? low : ((val>high) ? high : val);
216 }
217 } // namespace assist
218 
219 } //namespace CTL
220 
221 #endif // CTL_REGULARIZERS_H
The HuberRegularizer class is a regularizer based on the Huber potential function.
Definition: regularizers.h:184
void filter(VoxelVolume< float > &volume) override
Trivial implementation that does nothing.
Definition: regularizers.cpp:20
The VoxelVolume class provides a simple container for storage of voxelized 3D volume data.
Definition: ctsystemview.h:14
Definition: abstractvolumefilter.h:11
The MedianFilterRegularizer class is a volume filter that applies a fraction of a median filter opera...
Definition: regularizers.h:69
The TVRegularizer class provides an approximation of a total variation (TV) minimizing regularizer.
Definition: regularizers.h:124
#define CTL_TYPE_ID(newIndex)
Definition: serializationinterface.h:189
The IdentityRegularizer class is an implementation of AbstractVolumeFilter that does not change input...
Definition: regularizers.h:18