27#ifndef fitEmpirical_hpp
28#define fitEmpirical_hpp
32#include "../../improc/eigenImage.hpp"
33#include "../../improc/imageTransforms.hpp"
44template <
typename realT>
45struct array2FitEmpirical;
48template <
typename _realT>
49struct empirical2D_sym_fitter;
61template <
typename fitterT>
66 typedef typename fitterT::realT realT;
105 arr.scale( this->
p, scale );
106 arr.dx( this->
p, dx );
107 arr.dy( this->
p, dy );
115 arr.setup(data,
ref);
126 return arr.scale( this->
p );
135 return arr.dx( this->
p );
144 return arr.dy( this->
p );
152template <
typename realT>
166 int m_scale_idx{ 0 };
180 std::cerr <<
"ref and data not same size\n";
214 realT scale( realT *p )
216 if( m_scale_idx < 0 )
222 return p[m_scale_idx];
226 void scale( realT *p, realT
nscale )
228 if( m_scale_idx < 0 )
250 void dx( realT *p, realT
ndx )
274 void dy( realT *p, realT
ndy )
296template <
typename _realT>
301 static const int nparams = 3;
303 static void func( realT *p, realT *
hx,
int m,
int n,
void *adata )
311 realT scale = arr->scale( p );
312 realT dx = arr->dx( p );
313 realT dy = arr->dy( p );
333template <
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 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.
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.