27#ifndef math_fit_array2FitGaussian2D_hpp
28#define math_fit_array2FitGaussian2D_hpp
30#include "../../mxError.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 )
194 "array2FitGaussian2D::setFixed",
MXE_NOTIMPL,
"cannot fix sigma_x, sigma_y, and theta separately" );
197 m_sigma_x_idx =
idx++;
198 m_sigma_y_idx =
idx++;
205template <
typename realT>
218template <
typename realT>
219void array2FitGaussian2D<realT>::G0( realT *p, realT
nG0 )
231template <
typename realT>
232realT array2FitGaussian2D<realT>::G( realT *p )
244template <
typename realT>
245void array2FitGaussian2D<realT>::G( realT *p, realT
nG )
257template <
typename realT>
258realT array2FitGaussian2D<realT>::x0( realT *p )
270template <
typename realT>
271void array2FitGaussian2D<realT>::x0( realT *p, realT
nx0 )
283template <
typename realT>
284realT array2FitGaussian2D<realT>::y0( realT *p )
296template <
typename realT>
297void array2FitGaussian2D<realT>::y0( realT *p, realT
ny0 )
309template <
typename realT>
310realT array2FitGaussian2D<realT>::sigma_x( realT *p )
312 if( m_sigma_x_idx < 0 )
318 return p[m_sigma_x_idx];
322template <
typename realT>
323void array2FitGaussian2D<realT>::sigma_x( realT *p, realT
nsigma_x )
325 if( m_sigma_x_idx < 0 )
335template <
typename realT>
336realT array2FitGaussian2D<realT>::sigma_y( realT *p )
338 if( m_sigma_y_idx < 0 )
344 return p[m_sigma_y_idx];
348template <
typename realT>
349void array2FitGaussian2D<realT>::sigma_y( realT *p, realT
nsigma_y )
351 if( m_sigma_y_idx < 0 )
361template <
typename realT>
362realT array2FitGaussian2D<realT>::theta( realT *p )
364 if( m_theta_idx < 0 )
370 return p[m_theta_idx];
374template <
typename realT>
375void array2FitGaussian2D<realT>::theta( realT *p, realT
ntheta )
377 if( m_theta_idx < 0 )
387template <
typename realT>
388realT array2FitGaussian2D<realT>::sigma( realT *p )
390 if( m_sigma_idx < 0 )
396 return p[m_sigma_idx];
400template <
typename realT>
401void array2FitGaussian2D<realT>::sigma( realT *p, realT
nsigma )
403 if( m_sigma_idx < 0 )
413template <
typename realT>
414realT array2FitGaussian2D<realT>::a( realT *p )
417 if( m_sigma_x_idx < 0 )
423 return p[m_sigma_x_idx];
427template <
typename realT>
428void array2FitGaussian2D<realT>::a( realT *p, realT
na )
431 if( m_sigma_x_idx < 0 )
437 p[m_sigma_x_idx] =
na;
441template <
typename realT>
442realT array2FitGaussian2D<realT>::b( realT *p )
445 if( m_sigma_y_idx < 0 )
451 return p[m_sigma_y_idx];
455template <
typename realT>
456void array2FitGaussian2D<realT>::b( realT *p, realT
nb )
459 if( m_sigma_y_idx < 0 )
465 p[m_sigma_y_idx] =
nb;
469template <
typename realT>
470realT array2FitGaussian2D<realT>::c( realT *p )
473 if( m_theta_idx < 0 )
479 return p[m_theta_idx];
483template <
typename realT>
484void array2FitGaussian2D<realT>::c( realT *p, realT
nc )
487 if( m_theta_idx < 0 )
497template <
typename realT>
498int array2FitGaussian2D<realT>::nparams()
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.