8 namespace ModelFitting {
10 template<
typename ImageType>
23 template<
typename ImageType>
41 return scale * rotation * m_inv_jacobian *
pixel_scale;
44 template<
typename ImageType>
45 template<
typename ModelEvaluator>
49 float x_model = (x - 0.5 + (ix+1) * 1.0 / (subsampling+1));
51 float y_model = (y - 0.5 + (iy+1) * 1.0 / (subsampling+1));
52 acc += model_eval.evaluateModel(x_model, y_model);
56 return acc / (subsampling*subsampling);
59 template<
typename ImageType>
60 template<
typename ModelEvaluator>
62 float value = samplePixel(model_eval, x,y, 1);
63 for (
unsigned int i=2; i<=max_subsampling; i+=2) {
64 float newValue = samplePixel(model_eval, x,y, i);
65 float ratio = newValue / value;
76 template<
typename ImageType>
79 float x_x = (size_x * 0.95f / 2.f - 1) * transform[0];
80 float x_y = (size_x * 0.95f / 2.f - 1) * transform[2];
82 float y_x = (size_y * 0.95f / 2.f - 1) * transform[1];
83 float y_y = (size_y * 0.95f / 2.f - 1) * transform[3];
85 float xy_x = x_x + y_x;
86 float xy_y = x_y + y_y;
88 float d1 = (xy_x * x_y - xy_y * x_x) * (xy_x * x_y - xy_y * x_x) / ((xy_x - x_x) * (xy_x - x_x) + (xy_y - x_y) * (xy_y - x_y));
89 float d2 = (xy_x * y_y - xy_y * y_x) * (xy_x * y_y - xy_y * y_x) / ((xy_x - y_x) * (xy_x - y_x) + (xy_y - y_y) * (xy_y - y_y));
float samplePixel(const ModelEvaluator &model_eval, int x, int y, unsigned int subsampling) const
double getMaxRadiusSqr(std::size_t size_x, std::size_t size_y, const Mat22 &transform) const
Mat22 getCombinedTransform(double pixel_scale) const
float adaptiveSamplePixel(const ModelEvaluator &model_eval, int x, int y, unsigned int max_subsampling, float threshold=1.1) const
CompactModelBase(std::shared_ptr< BasicParameter > x_scale, std::shared_ptr< BasicParameter > y_scale, std::shared_ptr< BasicParameter > rotation, double width, double height, std::shared_ptr< BasicParameter > x, std::shared_ptr< BasicParameter > y, std::tuple< double, double, double, double > transform)