27 #ifndef math_fit_array2FitGaussian2D_hpp
28 #define math_fit_array2FitGaussian2D_hpp
30 #include "../../mxError.hpp"
45 template<
typename realT>
97 realT G0( realT * p );
103 realT G( realT * p );
109 realT x0( realT * p );
115 realT y0( realT * p );
121 realT sigma_x( realT * p );
123 void sigma_x( realT * p,
127 realT sigma_y( realT * p );
129 void sigma_y( realT * p,
133 realT theta( realT * p );
135 void theta( realT * p,
139 realT sigma( realT * p );
141 void sigma( realT * p,
145 realT a( realT * p );
151 realT b( realT * p );
157 realT c( realT * p );
167 template<
typename realT>
168 void array2FitGaussian2D<realT>::setSymmetric()
173 template<
typename realT>
174 void array2FitGaussian2D<realT>::setGeneral()
179 template<
typename realT>
191 if(G0) m_G0_idx = -1;
192 else m_G0_idx = idx++;
195 else m_G_idx = idx++;
197 if(x0) m_x0_idx = -1;
198 else m_x0_idx = idx++;
200 if(y0) m_y0_idx = -1;
201 else m_y0_idx = idx++;
203 if(m_maxNparams == 5)
205 if(sigma_x) m_sigma_idx = -1;
206 else m_sigma_idx = idx++;
208 else if(sigma_x && sigma_y && theta)
216 if(sigma_x || sigma_y || theta)
218 mxError(
"array2FitGaussian2D::setFixed", MXE_NOTIMPL,
"cannot fix sigma_x, sigma_y, and theta separately");
221 m_sigma_x_idx = idx++;
222 m_sigma_y_idx = idx++;
229 template<
typename realT>
242 template<
typename realT>
243 void array2FitGaussian2D<realT>::G0( realT * p,
257 template<
typename realT>
258 realT array2FitGaussian2D<realT>::G( realT * p )
270 template<
typename realT>
271 void array2FitGaussian2D<realT>::G( realT * p,
285 template<
typename realT>
286 realT array2FitGaussian2D<realT>::x0( realT * p )
298 template<
typename realT>
299 void array2FitGaussian2D<realT>::x0( realT * p,
313 template<
typename realT>
314 realT array2FitGaussian2D<realT>::y0( realT * p )
326 template<
typename realT>
327 void array2FitGaussian2D<realT>::y0( realT * p,
341 template<
typename realT>
342 realT array2FitGaussian2D<realT>::sigma_x( realT * p )
344 if( m_sigma_x_idx < 0 )
350 return p[m_sigma_x_idx];
354 template<
typename realT>
355 void array2FitGaussian2D<realT>::sigma_x( realT * p,
359 if( m_sigma_x_idx < 0 )
361 m_sigma_x = nsigma_x;
365 p[m_sigma_x_idx] = nsigma_x;
369 template<
typename realT>
370 realT array2FitGaussian2D<realT>::sigma_y( realT * p )
372 if( m_sigma_y_idx < 0 )
378 return p[m_sigma_y_idx];
382 template<
typename realT>
383 void array2FitGaussian2D<realT>::sigma_y( realT * p,
387 if( m_sigma_y_idx < 0 )
389 m_sigma_y = nsigma_y;
393 p[m_sigma_y_idx] = nsigma_y;
397 template<
typename realT>
398 realT array2FitGaussian2D<realT>::theta( realT * p )
400 if( m_theta_idx < 0 )
406 return p[m_theta_idx];
410 template<
typename realT>
411 void array2FitGaussian2D<realT>::theta( realT * p,
415 if( m_theta_idx < 0 )
421 p[m_theta_idx] = ntheta;
425 template<
typename realT>
426 realT array2FitGaussian2D<realT>::sigma( realT * p )
428 if( m_sigma_idx < 0 )
434 return p[m_sigma_idx];
438 template<
typename realT>
439 void array2FitGaussian2D<realT>::sigma( realT * p,
443 if( m_sigma_idx < 0 )
449 p[m_sigma_idx] = nsigma;
453 template<
typename realT>
454 realT array2FitGaussian2D<realT>::a( realT * p )
457 if( m_sigma_x_idx < 0 )
463 return p[m_sigma_x_idx];
467 template<
typename realT>
468 void array2FitGaussian2D<realT>::a( realT * p,
473 if( m_sigma_x_idx < 0 )
479 p[m_sigma_x_idx] = na;
483 template<
typename realT>
484 realT array2FitGaussian2D<realT>::b( realT * p )
487 if( m_sigma_y_idx < 0 )
493 return p[m_sigma_y_idx];
497 template<
typename realT>
498 void array2FitGaussian2D<realT>::b( realT * p,
503 if( m_sigma_y_idx < 0 )
509 p[m_sigma_y_idx] = nb;
513 template<
typename realT>
514 realT array2FitGaussian2D<realT>::c( realT * p )
517 if( m_theta_idx < 0 )
523 return p[m_theta_idx];
527 template<
typename realT>
528 void array2FitGaussian2D<realT>::c( realT * p,
533 if( m_theta_idx < 0 )
543 template<
typename realT>
544 int array2FitGaussian2D<realT>::nparams()
constexpr units::realT G()
Newton's Gravitational Constant.
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.