/usr/include/InsightToolkit/Numerics/itkCumulativeGaussianOptimizer.h is in libinsighttoolkit3-dev 3.20.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | /*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: itkCumulativeGaussianOptimizer.h
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/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 notices for more information.
=========================================================================*/
#ifndef __itkCumulativeGaussianOptimizer_h
#define __itkCumulativeGaussianOptimizer_h
#include "itkMultipleValuedNonLinearOptimizer.h"
#include "itkCumulativeGaussianCostFunction.h"
namespace itk
{
/** \class CumulativeGaussianOptimizer
* \brief This is an optimizer specific to estimating
* the parameters of Cumulative Gaussian sampled data.
*
* This optimizer will only work if the data array is
* sampled from a Cumulative Gaussian curve. It's more
* of a curve fitter than an optimizer, with the
* advantage of being fast and specific. It works by
* taking the derivative of the Cumulative Gaussian sample
* then repeatedly extending the tails of the Gaussian
* and recalculating the Gaussian parameters until
* the change in iterations is within tolerance or very small.
* The Gaussian is then integrated to reproduce the
* Cumulative Gaussian and the asymptotes are estimated
* by using least squares fit to estimate the constant
* from integration.
*
* \ingroup Numerics Optimizers
*/
class ITK_EXPORT CumulativeGaussianOptimizer :
public MultipleValuedNonLinearOptimizer
{
public:
/** Standard typedefs. */
typedef CumulativeGaussianOptimizer Self;
typedef MultipleValuedNonLinearOptimizer Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
/** Cost function typedef. NOTE: This optimizer is specific to fitting a Cumulative Gaussian. */
typedef CumulativeGaussianCostFunction CostFunctionType;
/** Data array typedef. */
typedef CostFunctionType::MeasureType MeasureType;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(CumulativeGaussianOptimizer, MultipleValuedNonLinearOptimizer);
/** Set and get macros. */
itkSetMacro(DifferenceTolerance, double);
itkSetMacro(Verbose, bool);
itkGetMacro(ComputedMean, double);
itkGetMacro(ComputedStandardDeviation, double);
itkGetMacro(UpperAsymptote, double);
itkGetMacro(LowerAsymptote, double);
itkGetMacro(FinalSampledArray, MeasureType*);
itkGetMacro(FitError, double);
void SetDataArray(MeasureType * dataArray);
/** Start the optimizer. */
void StartOptimization();
/** Print an array. */
void PrintArray(MeasureType * array);
/** Report the reason for stopping. */
const std::string GetStopConditionDescription() const;
protected:
CumulativeGaussianOptimizer();
virtual ~CumulativeGaussianOptimizer();
void PrintSelf(std::ostream &os, Indent indent) const;
private:
/** When to stop the iteration for the Gaussian extension loop. */
double m_DifferenceTolerance;
/** The final mean of the Cumulative Gaussian. */
double m_ComputedMean;
/** The final standard deviation of the Cumulative Gaussian. */
double m_ComputedStandardDeviation;
/** The final amplitude of the Gaussian. */
double m_ComputedAmplitude;
/** The transition height (distance between upper and lower
* asymptotes) of the Cumulative Gaussian. */
double m_ComputedTransitionHeight;
/** The final upper asymptote of the Cumulative Gaussian. */
double m_UpperAsymptote;
/** The final lower asymptote of the Cumulative Gaussian. */
double m_LowerAsymptote;
/** Offset for the mean calculation. */
double m_OffsetForMean;
/** Flag to print iteration results. */
bool m_Verbose;
/** Least squares fit error as a measure of goodness. */
double m_FitError;
/** Array of values computed from the final parameters of the
* Cumulative Gaussian. */
MeasureType * m_FinalSampledArray;
/** Original data array. */
MeasureType * m_CumulativeGaussianArray;
/** Extend the tails of the Gaussian. */
MeasureType * ExtendGaussian(MeasureType * originalArray, MeasureType * extendedArray, int startingPointForInsertion);
/** Recalulate the parameters of the extended Gaussian array. */
MeasureType * RecalculateExtendedArrayFromGaussianParameters(MeasureType * originalArray,
MeasureType * extendedArray,
int startingPointForInsertion);
/** Calculates the squared difference error between each Gaussian
* iteration loop. */
double FindAverageSumOfSquaredDifferences(MeasureType * array1, MeasureType * array2);
/** Given an array sampled from a Gaussin, compute the final parameters. */
void FindParametersOfGaussian(MeasureType * sampledGaussianArray);
/** Measure the parameters of a Gaussian sampled array. */
void MeasureGaussianParameters(MeasureType * array);
/** Print the header for output table. */
void PrintComputedParameterHeader();
/** Print the computed parameters. */
void PrintComputedParameters();
/** Find the constant of the integrated sample. */
double VerticalBestShift(MeasureType * originalArray, MeasureType * newArray);
/** Describe the stop condition */
OStringStream m_StopConditionDescription;
};
} // end namespace itk
#endif
|