27#ifndef fitEmpirical_hpp
28#define fitEmpirical_hpp
32#include "../../improc/eigenImage.hpp"
33#include "../../improc/imageTransforms.hpp"
43template <
typename realT>
44struct array2FitEmpirical;
47template <
typename _realT>
48struct empirical2D_sym_fitter;
60template <
typename fitterT>
65 typedef typename fitterT::realT realT;
104 arr.scale( this->
p, scale );
105 arr.dx( this->
p, dx );
106 arr.dy( this->
p, dy );
115 arr.setup( data,
ref, weights );
134 return arr.scale( this->
p );
143 return arr.dx( this->
p );
152 return arr.dy( this->
p );
159template <
typename realT>
174 int m_scale_idx{ 0 };
187 std::cerr <<
"ref and data not same size\n";
193 if( weights->rows() !=
m_nx || weights->cols() !=
m_ny )
195 std::cerr <<
"ref and data not same size\n";
208 setup( data,
ref,
nullptr );
236 realT scale( realT *p )
238 if( m_scale_idx < 0 )
244 return p[m_scale_idx];
248 void scale( realT *p, realT
nscale )
250 if( m_scale_idx < 0 )
272 void dx( realT *p, realT
ndx )
296 void dy( realT *p, realT
ndy )
318template <
typename _realT>
323 static const int nparams = 3;
325 static void func( realT *p, realT *
hx,
int m,
int n,
void *adata )
333 realT scale = arr->scale( p );
334 realT dx = arr->dx( p );
335 realT dy = arr->dy( p );
371template <
typename realT>
Class to manage fitting a 2D Moffat to data via the levmarInterface.
void setArray(const eigenImage< realT > *data, const eigenImage< realT > *ref)
Set the data aray.
realT dx()
Get the current value of dx, the x shift.
realT scale()
Get the current value of the scale factor.
void setFixed(bool scale, bool dx, bool dy)
Set whether each parameter is fixed.
realT dy()
Get the current value of dy, the y shift.
void setArray(const eigenImage< realT > *data, const eigenImage< realT > *ref, const eigenImage< realT > *weights)
Set the data aray.
void setGuess(realT scale, realT dx, realT dy)
Set the initial guess for the empirical fit.
A templatized interface to the levmar package.
void allocate_params()
Allocate parameters array based on previous call to nParams.
realT * p
Parameter array. On input is the initial estimates. On output has the estimated solution.
int n
I: measurement vector dimension.
void * adata
Pointer to possibly additional data, passed uninterpreted to func & jacf.
constexpr floatT six_fifths()
Return 6/5 in the specified precision.
A c++ interface to the templatized levmar minimization routines..
Wrapper for a native array to pass to levmarInterface, with empirical function fit details.
const eigenImage< realT > * m_weights
Pointer to the weight image.
void setFixed(bool scale, bool dx, bool dy)
Set whether each parameter is fixed.
eigenImage< realT > m_refShifted
Working memory for the shifted reference image.
size_t m_nx
X dimension of the array.
size_t m_ny
Y dimension of the array.
const eigenImage< realT > * m_data
Pointer to the data array.
const eigenImage< realT > * m_ref
Pointer to the reference image to fit to the data.
levmarInterface fitter structure for 2D empirical functions.