CASToR  3.0
Tomographic Reconstruction (PET/SPECT/CT)
vPenalty.hh
Go to the documentation of this file.
1 /*
2 This file is part of CASToR.
3 
4  CASToR is free software: you can redistribute it and/or modify it under the
5  terms of the GNU General Public License as published by the Free Software
6  Foundation, either version 3 of the License, or (at your option) any later
7  version.
8 
9  CASToR is distributed in the hope that it will be useful, but WITHOUT ANY
10  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12  details.
13 
14  You should have received a copy of the GNU General Public License along with
15  CASToR (in file GNU_GPL.TXT). If not, see <http://www.gnu.org/licenses/>.
16 
17 Copyright 2017-2019 all CASToR contributors listed below:
18 
19  --> Didier BENOIT, Claude COMTAT, Marina FILIPOVIC, Thibaut MERLIN, Mael MILLARDET, Simon STUTE, Valentin VIELZEUF
20 
21 This is CASToR version 3.0.
22 */
23 
30 #ifndef VPENALTY_HH
31 #define VPENALTY_HH 1
32 
33 #include "gVariables.hh"
35 #include "oImageSpace.hh"
36 #include "vDataFile.hh"
37 #include "oProjectionLine.hh"
38 
48 class vPenalty
49 {
50  // -------------------------------------------------------------------
51  // Constructor & Destructor
52  public:
59  vPenalty();
67  virtual ~vPenalty();
68 
69 
70  // -------------------------------------------------------------------
71  // Public member functions
72  public:
73 
79  void ShowHelp();
88  int CheckParameters();
97  int Initialize();
105  virtual int GlobalPreProcessingStep();
119  virtual int LocalPreProcessingStep(int a_tbf, int a_rbf, int a_cbf, INTNB a_voxel, int a_th);
132  virtual FLTNB ComputePenaltyValue(int a_tbf, int a_rbf, int a_cbf, INTNB a_voxel, int a_th) = 0;
145  virtual FLTNB ComputeFirstDerivative(int a_tbf, int a_rbf, int a_cbf, INTNB a_voxel, int a_th) = 0;
158  virtual FLTNB ComputeSecondDerivative(int a_tbf, int a_rbf, int a_cbf, INTNB a_voxel, int a_th) = 0;
159 
160 
161  // -------------------------------------------------------------------
162  // Public Get & Set functions
163  public:
169  inline void SetVerbose(int a_verbose)
170  {m_verbose = a_verbose;}
176  inline void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification* ap_ImageDimensionsAndQuantification)
177  {mp_ImageDimensionsAndQuantification = ap_ImageDimensionsAndQuantification;}
183  inline void SetImageSpace(oImageSpace* ap_ImageSpace)
184  {mp_ImageSpace = ap_ImageSpace;}
190  inline void SetPenaltyStrength(FLTNB a_penaltyStrength)
191  {m_penaltyStrength = a_penaltyStrength;}
198  {return m_penaltyStrength;}
205  {return m_penaltyDerivativesOrder;}
211  inline void SetPenaltyID(const string& a_penaltyID)
212  {m_penaltyID = a_penaltyID;}
217  inline const string& GetPenaltyID()
218  {return m_penaltyID;}
219 
220 
221  // -----------------------------------------------------------------------------------------
222  // Pure virtual private member functions that need to be implemented by child optimizers
223  private:
232  virtual int CheckSpecificParameters() = 0;
241  virtual void ShowHelpSpecific() = 0;
251  virtual int InitializeSpecific() = 0;
252 
253 
254  // -------------------------------------------------------------------
255  // Virtual public member functions that may be overloaded by specific child penalties
256  public:
257 
268  virtual int ReadConfigurationFile( const string& a_configurationFile ) = 0;
279  virtual int ReadOptionsList( const string& a_optionsList ) = 0;
280 
281  // -------------------------------------------------------------------
282  // Data members
283  protected:
284  // Penalty ID
285  string m_penaltyID;
286  // Image dimensions
290  // Verbosity
291  int m_verbose;
292  // Order of penalty derivatives
295 };
296 
297 
298 // ---------------------------------------------------------------------
299 // Part of code that manages the auto declaration of children classes
300 // ---------------------------------------------------------------------
301 
302 // Macro for the function that creates the object
303 #define FUNCTION_PENALTY(CLASS) \
304  static vPenalty *make_penalty() { return new CLASS(); };
305 
306 // Macro for the class that links the appropriate function to the map of objects
307 #define CLASS_PENALTY(NAME,CLASS) \
308  class NAME##PenaltyCreator \
309  { \
310  public: \
311  NAME##PenaltyCreator() \
312  { sAddonManager::GetInstance()->mp_listOfPenalties[#NAME] = CLASS::make_penalty; } \
313  }; \
314  static NAME##PenaltyCreator PenaltyCreator##NAME;
315 
316 #endif
This header file is mainly used to declare some macro definitions and all includes needed from the st...
void SetPenaltyStrength(FLTNB a_penaltyStrength)
Set the penalty strength.
Definition: vPenalty.hh:190
Declaration of class oImageDimensionsAndQuantification.
virtual int InitializeSpecific()=0
A private function used to initialize everything specific to the child penalty.
int m_penaltyDerivativesOrder
Definition: vPenalty.hh:293
#define FLTNB
Definition: gVariables.hh:81
oImageSpace * mp_ImageSpace
Definition: vPenalty.hh:289
virtual int ReadConfigurationFile(const string &a_configurationFile)=0
A function used to read options from a configuration file and check that the corresponding values are...
FLTNB m_penaltyStrength
Definition: vPenalty.hh:294
const string & GetPenaltyID()
Definition: vPenalty.hh:217
virtual int LocalPreProcessingStep(int a_tbf, int a_rbf, int a_cbf, INTNB a_voxel, int a_th)
A public function computing a local pre-processing step for the penalty.
Definition: vPenalty.cc:149
string m_penaltyID
Definition: vPenalty.hh:285
virtual FLTNB ComputeSecondDerivative(int a_tbf, int a_rbf, int a_cbf, INTNB a_voxel, int a_th)=0
A public function computing the second derivative of the penalty (the two derivatives are according t...
FLTNB GetPenaltyStrength()
Get the penalty strength.
Definition: vPenalty.hh:197
virtual void ShowHelpSpecific()=0
A function used to show help about the child module.
int Initialize()
A public function used to initialize the penalty.
Definition: vPenalty.cc:116
void ShowHelp()
A function used to show help about the penalty.
Definition: vPenalty.cc:63
int m_verbose
Definition: vPenalty.hh:291
vPenalty()
The constructor of vPenalty.
Definition: vPenalty.cc:38
Declaration of class oProjectionLine.
virtual ~vPenalty()
The destructor of vPenalty.
Definition: vPenalty.cc:54
oImageDimensionsAndQuantification * mp_ImageDimensionsAndQuantification
Definition: vPenalty.hh:288
Declaration of class vDataFile.
virtual int GlobalPreProcessingStep()
A public function computing a global pre-processing step for the penalty.
Definition: vPenalty.cc:138
void SetPenaltyID(const string &a_penaltyID)
Set the penalty ID.
Definition: vPenalty.hh:211
This class is designed to generically described any penalty applied to MAP algorithms.
Definition: vPenalty.hh:48
void SetImageSpace(oImageSpace *ap_ImageSpace)
Set the pointer to the image space in use.
Definition: vPenalty.hh:183
void SetVerbose(int a_verbose)
Set the verbose level.
Definition: vPenalty.hh:169
int GetPenaltyDerivativesOrder()
Get the penalty deratives order.
Definition: vPenalty.hh:204
int CheckParameters()
A public function used to check the parameters settings.
Definition: vPenalty.cc:75
virtual int CheckSpecificParameters()=0
A private function used to check the parameters settings specific to the child penalty.
#define INTNB
Definition: gVariables.hh:92
Declaration of class oImageSpace.
virtual FLTNB ComputePenaltyValue(int a_tbf, int a_rbf, int a_cbf, INTNB a_voxel, int a_th)=0
A public function computing the value of the penalty function.
This class holds all the matrices in the image domain that can be used in the algorithm: image...
Definition: oImageSpace.hh:60
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
Set the pointer to the image dimensions in use.
Definition: vPenalty.hh:176
This class is designed to manage all dimensions and quantification related stuff. ...
virtual int ReadOptionsList(const string &a_optionsList)=0
A function used to read options from a list of options.
virtual FLTNB ComputeFirstDerivative(int a_tbf, int a_rbf, int a_cbf, INTNB a_voxel, int a_th)=0
A public function computing the derivative of the penalty.