STIR  6.2.0
QuadraticPrior.h
Go to the documentation of this file.
1 //
2 //
3 /*
4  Copyright (C) 2000- 2011, Hammersmith Imanet Ltd
5  This file is part of STIR.
6 
7  SPDX-License-Identifier: Apache-2.0
8 
9  See STIR/LICENSE.txt for details.
10 */
21 #ifndef __stir_recon_buildblock_QuadraticPrior_H__
22 #define __stir_recon_buildblock_QuadraticPrior_H__
23 
26 #include "stir/Array.h"
28 #include "stir/shared_ptr.h"
29 #include <string>
30 
31 START_NAMESPACE_STIR
32 
78 template <typename elemT>
79 class QuadraticPrior : public RegisteredParsingObject<QuadraticPrior<elemT>,
80  GeneralisedPrior<DiscretisedDensity<3, elemT>>,
81  PriorWithParabolicSurrogate<DiscretisedDensity<3, elemT>>>
82 {
83 private:
87  base_type;
88 
89 public:
91  static const char* const registered_name;
92 
95 
97  QuadraticPrior(const bool only_2D, float penalization_factor);
98 
99  bool parabolic_surrogate_curvature_depends_on_argument() const override { return false; }
100 
101  bool is_convex() const override;
102 
104  double compute_value(const DiscretisedDensity<3, elemT>& current_image_estimate) override;
105 
107  void compute_gradient(DiscretisedDensity<3, elemT>& prior_gradient,
108  const DiscretisedDensity<3, elemT>& current_image_estimate) override;
109 
111 
112  void parabolic_surrogate_curvature(DiscretisedDensity<3, elemT>& parabolic_surrogate_curvature,
113  const DiscretisedDensity<3, elemT>& current_image_estimate) override;
114 
115  void compute_Hessian(DiscretisedDensity<3, elemT>& prior_Hessian_for_single_densel,
116  const BasicCoordinate<3, int>& coords,
117  const DiscretisedDensity<3, elemT>& current_image_estimate) const override;
118 
120  void add_multiplication_with_approximate_Hessian(DiscretisedDensity<3, elemT>& output,
121  const DiscretisedDensity<3, elemT>& input) const override;
122 
126  void accumulate_Hessian_times_input(DiscretisedDensity<3, elemT>& output,
127  const DiscretisedDensity<3, elemT>& current_estimate,
128  const DiscretisedDensity<3, elemT>& input) const override;
129 
131  Array<3, float> get_weights() const;
132 
134  void set_weights(const Array<3, float>&);
135 
137 
141  shared_ptr<const DiscretisedDensity<3, elemT>> get_kappa_sptr() const;
142 
144  void set_kappa_sptr(const shared_ptr<const DiscretisedDensity<3, elemT>>&);
145 
147  Succeeded set_up(shared_ptr<const DiscretisedDensity<3, elemT>> const& target_sptr) override;
148 
149 protected:
151  bool only_2D;
153 
158 
160 
166  std::string kappa_filename;
167 
169  void check(DiscretisedDensity<3, elemT> const& current_image_estimate) const override;
170 
171  void set_defaults() override;
172  void initialise_keymap() override;
173  bool post_processing() override;
174 
175 private:
176  shared_ptr<const DiscretisedDensity<3, elemT>> kappa_ptr;
177 
179 
187  elemT derivative_20(const elemT x_j, const elemT x_k) const;
188  elemT derivative_11(const elemT x_j, const elemT x_k) const;
190 };
191 
192 END_NAMESPACE_STIR
193 
194 #endif
Array< 3, float > weights
penalty weights
Definition: QuadraticPrior.h:164
std::string gradient_filename_prefix
filename prefix for outputing the gradient whenever compute_gradient() is called. ...
Definition: QuadraticPrior.h:157
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
std::string kappa_filename
Filename for the image that will be read by post_processing()
Definition: QuadraticPrior.h:166
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
this class implements priors with a parabolic surrogate curvature
Definition: PriorWithParabolicSurrogate.h:39
Parent class for all leaves in a RegisteredObject hierarchy that do parsing of parameter files...
Definition: RegisteredParsingObject.h:77
static const char *const registered_name
Name which will be used when parsing a GeneralisedPrior object.
Definition: QuadraticPrior.h:91
Declaration of class stir::PriorWithParabolicSurrogate.
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.
A class in the GeneralisedPrior hierarchy. This implements a quadratic Gibbs prior.
Definition: QuadraticPrior.h:79
bool only_2D
can be set during parsing to restrict the weights to the 2D case
Definition: QuadraticPrior.h:151
bool parabolic_surrogate_curvature_depends_on_argument() const override
A function that allows skipping some computations if the curvature is independent of the current_esti...
Definition: QuadraticPrior.h:99
This abstract class is the basis for all image representations.
Definition: FBP2DReconstruction.h:35