STIR  6.2.0
RelativeDifferencePrior.h
Go to the documentation of this file.
1 //
2 //
3 /*
4  Copyright (C) 2000- 2011, Hammersmith Imanet Ltd
5  Copyright (C) 2019- 2020, UCL,
6  This file is part of STIR.
7 
8  SPDX-License-Identifier: Apache-2.0
9 
10  See STIR/LICENSE.txt for details.
11 */
23 #ifndef __stir_recon_buildblock_RelativeDifferencePrior_H__
24 #define __stir_recon_buildblock_RelativeDifferencePrior_H__
25 
28 #include "stir/Array.h"
30 #include "stir/shared_ptr.h"
31 #include <string>
32 
33 START_NAMESPACE_STIR
34 
96 template <typename elemT>
97 class RelativeDifferencePrior : public RegisteredParsingObject<RelativeDifferencePrior<elemT>,
98  GeneralisedPrior<DiscretisedDensity<3, elemT>>,
99  GeneralisedPrior<DiscretisedDensity<3, elemT>>>
100 {
101 private:
104  GeneralisedPrior<DiscretisedDensity<3, elemT>>>
105  base_type;
106 
107 public:
109  static const char* const registered_name;
110 
113 
115  RelativeDifferencePrior(const bool only_2D, float penalization_factor, float gamma, float epsilon);
116 
118  double compute_value(const DiscretisedDensity<3, elemT>& current_image_estimate) override;
119 
121  void compute_gradient(DiscretisedDensity<3, elemT>& prior_gradient,
122  const DiscretisedDensity<3, elemT>& current_image_estimate) override;
123 
124  void compute_Hessian(DiscretisedDensity<3, elemT>& prior_Hessian_for_single_densel,
125  const BasicCoordinate<3, int>& coords,
126  const DiscretisedDensity<3, elemT>& current_image_estimate) const override;
127 
128  void add_multiplication_with_approximate_Hessian(DiscretisedDensity<3, elemT>& output,
129  const DiscretisedDensity<3, elemT>& input) const override;
130 
132  void accumulate_Hessian_times_input(DiscretisedDensity<3, elemT>& output,
133  const DiscretisedDensity<3, elemT>& current_estimate,
134  const DiscretisedDensity<3, elemT>& input) const override;
135 
137  float get_gamma() const;
139  void set_gamma(float e);
140 
142  float get_epsilon() const;
144  void set_epsilon(float e);
145 
147  Array<3, float> get_weights() const;
148 
150  void set_weights(const Array<3, float>&);
151 
153 
157  shared_ptr<DiscretisedDensity<3, elemT>> get_kappa_sptr() const;
158 
160  void set_kappa_sptr(const shared_ptr<DiscretisedDensity<3, elemT>>&);
161 
163  virtual Succeeded set_up(shared_ptr<const DiscretisedDensity<3, elemT>> const& target_sptr) override;
164 
165  bool is_convex() const override;
166 
167 protected:
169  float gamma;
170 
172  float epsilon;
173 
175  bool only_2D;
177 
182 
184 
190  std::string kappa_filename;
191 
193  void check(DiscretisedDensity<3, elemT> const& current_image_estimate) const override;
194 
195  void set_defaults() override;
196  void initialise_keymap() override;
197  bool post_processing() override;
198 
199 protected:
200  shared_ptr<DiscretisedDensity<3, elemT>> kappa_ptr;
201 
203 
221  double value(const elemT x_j, const elemT x_k) const;
222  elemT derivative_10(const elemT x, const elemT y) const;
223  elemT derivative_20(const elemT x_j, const elemT x_k) const;
224  elemT derivative_11(const elemT x_j, const elemT x_k) const;
226 };
227 
228 END_NAMESPACE_STIR
229 
230 #endif
float epsilon
Create variable epsilon for Relative Difference Penalty.
Definition: RelativeDifferencePrior.h:172
static const char *const registered_name
Name which will be used when parsing a GeneralisedPrior object.
Definition: RelativeDifferencePrior.h:109
std::string gradient_filename_prefix
filename prefix for outputing the gradient whenever compute_gradient() is called. ...
Definition: RelativeDifferencePrior.h:181
Import of std::shared_ptr, std::dynamic_pointer_cast and std::static_pointer_cast (or corresponding b...
defines the stir::DiscretisedDensity class
defines the Array class for multi-dimensional (numeric) arrays
bool only_2D
can be set during parsing to restrict the weights to the 2D case
Definition: RelativeDifferencePrior.h:175
A base class for &#39;generalised&#39; priors, i.e. priors for which at least a &#39;gradient&#39; is defined...
Definition: GeneralisedPrior.h:41
std::string kappa_filename
Filename for the image that will be read by post_processing()
Definition: RelativeDifferencePrior.h:190
A class in the GeneralisedPrior hierarchy. This implements a Relative Difference prior.
Definition: RelativeDifferencePrior.h:97
Parent class for all leaves in a RegisteredObject hierarchy that do parsing of parameter files...
Definition: RegisteredParsingObject.h:77
Declaration of class stir::GeneralisedPrior.
float gamma
Create variable gamma for Relative Difference Penalty.
Definition: RelativeDifferencePrior.h:169
a class containing an enumeration type that can be used by functions to signal successful operation o...
Definition: Succeeded.h:43
Declaration of class stir::RegisteredParsingObject.
Array< 3, float > weights
penalty weights
Definition: RelativeDifferencePrior.h:188
This abstract class is the basis for all image representations.
Definition: FBP2DReconstruction.h:35