27#ifndef math_fit_array2FitGaussian2D_hpp
28#define math_fit_array2FitGaussian2D_hpp
30#include "../../mxlib.hpp"
44template <
typename realT>
81 int m_maxNparams{ 7 };
90 void setFixed(
bool G0,
bool G,
bool x0,
bool y0,
bool sigma_x,
bool sigma_y,
bool theta );
94 void G0( realT *p, realT
nG0 );
98 void G( realT *p, realT
nG );
100 realT x0( realT *p );
102 void x0( realT *p, realT
nx0 );
104 realT y0( realT *p );
106 void y0( realT *p, realT
ny0 );
108 realT sigma_x( realT *p );
110 void sigma_x( realT *p, realT
nsigma_x );
112 realT sigma_y( realT *p );
114 void sigma_y( realT *p, realT
nsigma_y );
116 realT theta( realT *p );
118 void theta( realT *p, realT
ntheta );
120 realT sigma( realT *p );
122 void sigma( realT *p, realT
nsigma );
126 void a( realT *p, realT
na );
130 void b( realT *p, realT
nb );
134 void c( realT *p, realT
nc );
139template <
typename realT>
140void array2FitGaussian2D<realT>::setSymmetric()
145template <
typename realT>
146void array2FitGaussian2D<realT>::setGeneral()
151template <
typename realT>
176 if( m_maxNparams == 5 )
183 else if( sigma_x && sigma_y && theta )
191 if( sigma_x || sigma_y || theta )
196 m_sigma_x_idx =
idx++;
197 m_sigma_y_idx =
idx++;
204template <
typename realT>
217template <
typename realT>
218void array2FitGaussian2D<realT>::G0( realT *p, realT
nG0 )
230template <
typename realT>
231realT array2FitGaussian2D<realT>::G( realT *p )
243template <
typename realT>
244void array2FitGaussian2D<realT>::G( realT *p, realT
nG )
256template <
typename realT>
257realT array2FitGaussian2D<realT>::x0( realT *p )
269template <
typename realT>
270void array2FitGaussian2D<realT>::x0( realT *p, realT
nx0 )
282template <
typename realT>
283realT array2FitGaussian2D<realT>::y0( realT *p )
295template <
typename realT>
296void array2FitGaussian2D<realT>::y0( realT *p, realT
ny0 )
308template <
typename realT>
309realT array2FitGaussian2D<realT>::sigma_x( realT *p )
311 if( m_sigma_x_idx < 0 )
317 return p[m_sigma_x_idx];
321template <
typename realT>
322void array2FitGaussian2D<realT>::sigma_x( realT *p, realT
nsigma_x )
324 if( m_sigma_x_idx < 0 )
334template <
typename realT>
335realT array2FitGaussian2D<realT>::sigma_y( realT *p )
337 if( m_sigma_y_idx < 0 )
343 return p[m_sigma_y_idx];
347template <
typename realT>
348void array2FitGaussian2D<realT>::sigma_y( realT *p, realT
nsigma_y )
350 if( m_sigma_y_idx < 0 )
360template <
typename realT>
361realT array2FitGaussian2D<realT>::theta( realT *p )
363 if( m_theta_idx < 0 )
369 return p[m_theta_idx];
373template <
typename realT>
374void array2FitGaussian2D<realT>::theta( realT *p, realT
ntheta )
376 if( m_theta_idx < 0 )
386template <
typename realT>
387realT array2FitGaussian2D<realT>::sigma( realT *p )
389 if( m_sigma_idx < 0 )
395 return p[m_sigma_idx];
399template <
typename realT>
400void array2FitGaussian2D<realT>::sigma( realT *p, realT
nsigma )
402 if( m_sigma_idx < 0 )
412template <
typename realT>
413realT array2FitGaussian2D<realT>::a( realT *p )
416 if( m_sigma_x_idx < 0 )
422 return p[m_sigma_x_idx];
426template <
typename realT>
427void array2FitGaussian2D<realT>::a( realT *p, realT
na )
430 if( m_sigma_x_idx < 0 )
436 p[m_sigma_x_idx] =
na;
440template <
typename realT>
441realT array2FitGaussian2D<realT>::b( realT *p )
444 if( m_sigma_y_idx < 0 )
450 return p[m_sigma_y_idx];
454template <
typename realT>
455void array2FitGaussian2D<realT>::b( realT *p, realT
nb )
458 if( m_sigma_y_idx < 0 )
464 p[m_sigma_y_idx] =
nb;
468template <
typename realT>
469realT array2FitGaussian2D<realT>::c( realT *p )
472 if( m_theta_idx < 0 )
478 return p[m_theta_idx];
482template <
typename realT>
483void array2FitGaussian2D<realT>::c( realT *p, realT
nc )
486 if( m_theta_idx < 0 )
496template <
typename realT>
497int array2FitGaussian2D<realT>::nparams()
@ notimpl
A component or technique is not implemented.
error_t mxlib_error_report(const error_t &code, const std::string &expl, const std::source_location &loc=std::source_location::current())
Print a report to stderr given an mxlib error_t code and explanation and return the code.
constexpr floatT six_fifths()
Return 6/5 in the specified precision.
Wrapper for a native array to pass to levmarInterface, with 2D Gaussian details.
int m_sigma_x_idx
Index of sigma_x in the parameters. Re-used for a.
size_t ny
Y dimension of the array.
int m_sigma_idx
Index of sigma in the symmetric case.
int m_sigma_y_idx
Index of sigma_y in the parameters. Re-used for b.
void setFixed(bool G0, bool G, bool x0, bool y0, bool sigma_x, bool sigma_y, bool theta)
Set whether each parameter is fixed.
size_t nx
X dimension of the array.
realT * data
Pointer to the array.
int m_theta_idx
Index of theta in the parameters. Re-used for c.
realT * mask
Pointer to the (optional) mask array. Any 0 pixels are excluded from the fit.