X-shooter Pipeline Reference Manual 3.8.15
xsh_fit.c
Go to the documentation of this file.
1/* $Id: xsh_fit.c,v 1.9 2011-12-02 14:15:28 amodigli Exp $
2 *
3 * This file is part of the irplib package
4 * Copyright (C) 2002,2003 European Southern Observatory
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA
19 */
20
21/*
22 * $Author: amodigli $
23 * $Date: 2011-12-02 14:15:28 $
24 * $Revision: 1.9 $
25 * $Name: not supported by cvs2svn $
26 */
27
28#ifdef HAVE_CONFIG_H
29#include <config.h>
30#endif
31
32/*-----------------------------------------------------------------------------
33 Includes
34 -----------------------------------------------------------------------------*/
35
36#include <math.h>
37#include <assert.h>
38
39#include "xsh_fit.h"
40
41/*---------------------------------------------------------------------------*/
47/*---------------------------------------------------------------------------*/
50/*-----------------------------------------------------------------------------
51 Private function prototypes
52 -----------------------------------------------------------------------------*/
53
54static double irplib_tools_ipow(double, int);
55
56static cpl_vector * irplib_vector_transform_mean(const cpl_vector *, double *);
57
58static cpl_matrix * irplib_matrix_product_normal_create(const cpl_matrix *);
59
60static cpl_error_code irplib_matrix_product_transpose(cpl_matrix *,
61 const cpl_matrix *,
62 const cpl_matrix *);
63
64static cpl_error_code irplib_matrix_solve_chol_transpose(const cpl_matrix *,
65 cpl_matrix *);
66
67static void irplib_fit_imagelist_polynomial_double(cpl_imagelist *,
68 const cpl_matrix *,
69 const cpl_matrix *,
70 const cpl_vector *,
71 const cpl_imagelist *,
72 const cpl_vector *,
73 double, int, int,
74 cpl_image *);
75
76static void irplib_fit_imagelist_polynomial_float(cpl_imagelist *,
77 const cpl_matrix *,
78 const cpl_matrix *,
79 const cpl_vector *,
80 const cpl_imagelist *,
81 const cpl_vector *,
82 double, int, int,
83 cpl_image *);
84
85static void irplib_fit_imagelist_polynomial_int(cpl_imagelist *,
86 const cpl_matrix *,
87 const cpl_matrix *,
88 const cpl_vector *,
89 const cpl_imagelist *,
90 const cpl_vector *,
91 double, int, int,
92 cpl_image *);
93
94static void irplib_fit_imagelist_residual_double(cpl_image *, int,
95 const cpl_vector *,
96 const cpl_vector *,
97 const cpl_matrix *,
98 const cpl_matrix *);
99
100static void irplib_fit_imagelist_residual_float(cpl_image *, int,
101 const cpl_vector *,
102 const cpl_vector *,
103 const cpl_matrix *,
104 const cpl_matrix *);
105
106static void irplib_fit_imagelist_residual_int(cpl_image *, int,
107 const cpl_vector *,
108 const cpl_vector *,
109 const cpl_matrix *,
110 const cpl_matrix *);
111
112static void irplib_polynomial_shift_double(double *, int, double);
113
114
115/*----------------------------------------------------------------------------*/
170/*----------------------------------------------------------------------------*/
171cpl_imagelist * xsh_fit_imagelist_polynomial(const cpl_vector * x_pos,
172 const cpl_imagelist * values,
173 int mindeg,
174 int maxdeg,
175 cpl_boolean is_eqdist,
176 cpl_image * fiterror)
177{
178
179 cpl_imagelist * self = NULL; /* Avoid (false) uninit warning */
180 cpl_matrix * mv; /* The transpose of the Vandermonde matrix, V' */
181 cpl_matrix * mh; /* Upper triangular part of SPD Hankel matrix,
182 H = V' * V */
183 cpl_vector * xhat;
184
185 const cpl_image * value = cpl_imagelist_get_const(values, 0);
186 const double * dx;
187 double xmean;
188
189 cpl_error_code error;
190
191 /* Number of unknowns to determine */
192 const int nc = 1 + maxdeg - mindeg;
193 const int np = cpl_vector_get_size(x_pos);
194 const int nx = cpl_image_get_size_x(value);
195 const int ny = cpl_image_get_size_y(value);
196
197 const cpl_boolean is_eqzero = is_eqdist && mindeg == 0;
198
199 int i, j, k;
200
201
202 cpl_ensure(x_pos != NULL, CPL_ERROR_NULL_INPUT, NULL);
203 cpl_ensure(values != NULL, CPL_ERROR_NULL_INPUT, NULL);
204
205 cpl_ensure(mindeg >= 0, CPL_ERROR_ILLEGAL_INPUT, NULL);
206 cpl_ensure(maxdeg >= mindeg, CPL_ERROR_ILLEGAL_INPUT, NULL);
207
208 assert( nc > 0);
209
210 cpl_ensure(np == cpl_imagelist_get_size(values),
211 CPL_ERROR_INCOMPATIBLE_INPUT, NULL);
212
213 cpl_ensure(cpl_imagelist_is_uniform(values)==0,
214 CPL_ERROR_INCOMPATIBLE_INPUT, NULL);
215
216 if (fiterror != NULL) {
217 cpl_ensure(cpl_image_get_size_x(fiterror) == nx &&
218 cpl_image_get_size_y(fiterror) == ny,
219 CPL_ERROR_INCOMPATIBLE_INPUT, NULL);
220 }
221
222 if (mindeg == 0) {
223 /* Transform: xhat = x - mean(x) */
224 xhat = irplib_vector_transform_mean(x_pos, &xmean);
225 assert( xhat != NULL );
226
227 /* Ensure that the center element of xhat is zero */
228 if (is_eqdist && (np & 1)) cpl_vector_set(xhat, np>>1, 0.0);
229
230 } else {
231 xhat = (cpl_vector*)x_pos; /* xhat is not modified */
232 xmean = 0.0;
233 }
234
235 dx = cpl_vector_get_data(xhat);
236
237 /* Create matrices */
238 mv = cpl_matrix_wrap(nc, np,
239 cpl_malloc(nc * np * sizeof(double)));
240
241 /* Fill Vandermonde matrix */
242 for (j=0; j < np; j++) {
243 double f_prod = irplib_tools_ipow(dx[j], mindeg);
244 cpl_matrix_set(mv, 0, j, f_prod);
245 for (k=1; k < nc; k++) {
246 f_prod *= dx[j];
247 cpl_matrix_set(mv, k, j, f_prod);
248 }
249 }
250
251 if (xhat != x_pos) cpl_vector_delete(xhat);
252
253 /* Form upper triangular part of the matrix of the normal equations,
254 H = V' * V.
255 As in cpl_polynomial_fit_1d_create() this could be done in
256 O(nc * np) flops, rather than 2 * nc^2 * np, but this is
257 negligible for any practical image size and is not done since
258 mv still has to be formed in order to block-optimize the formation
259 of the right-hand-size */
261
262 if (is_eqzero) {
263
264 /* Ensure that the Hankel matrix has zeros on all odd skew diagonals
265 - above the (non-skew) main diagonal */
266
267 double * dmh = cpl_matrix_get_data(mh);
268
269 for (i = 0; i < nc; i++) {
270 for (j = i + 1; j < nc; j += 2) {
271 dmh[nc * i + j] = 0.0;
272 }
273 }
274 }
275
276 error = cpl_matrix_decomp_chol(mh);
277
278 if (!error) {
279
280 cpl_vector * xpow = NULL;
281
282 /* Should not be able to fail at this point */
283
284 /* Allocate nc images to store the results */
285 self = cpl_imagelist_new();
286 for (i=0; i < nc; i++) {
287 cpl_imagelist_set(self, cpl_image_new(nx, ny, CPL_TYPE_DOUBLE),
288 i);
289 }
290
291 if (mindeg > 0) {
292 const double * d_pos = cpl_vector_get_data_const(x_pos);
293 double * ppow = cpl_malloc(np * sizeof(double));
294
295 xpow = cpl_vector_wrap(np, ppow);
296
297 for (i = 0; i < np; i++) {
298 ppow[i] = irplib_tools_ipow(d_pos[i], mindeg);
299 }
300 }
301
302 switch (cpl_image_get_type(value)) {
303 case CPL_TYPE_DOUBLE:
304 irplib_fit_imagelist_polynomial_double(self, mh, mv, x_pos, values,
305 xpow, -xmean, np, nc,
306 fiterror);
307 break;
308 case CPL_TYPE_FLOAT:
309 irplib_fit_imagelist_polynomial_float(self, mh, mv, x_pos, values,
310 xpow, -xmean, np, nc,
311 fiterror);
312 break;
313 case CPL_TYPE_INT:
314 irplib_fit_imagelist_polynomial_int(self, mh, mv, x_pos, values,
315 xpow, -xmean, np, nc,
316 fiterror);
317 break;
318 default:
319 /* It is an error in CPL to reach this point */
320 assert( 0 );
321 }
322
323 cpl_vector_unwrap(xpow);
324
325 }
326
327 cpl_matrix_delete(mh);
328 cpl_matrix_delete(mv);
329
330 /* Propagate the error, if any */
331 cpl_ensure(!error, error, NULL);
332
333 return self;
334
335}
336
337/*----------------------------------------------------------------------------*/
347/*----------------------------------------------------------------------------*/
348static double irplib_tools_ipow(double x, int p)
349{
350
351 double result;
352 double pow2 = x;
353
354 /* Compute the result as a product of powers of 2 of x.
355 - this method may produce (slightly) different results than pow(x, p) */
356
357 /* Handle least significant bit in p here in order to avoid an unnecessary
358 multiplication of pow2 - which could cause an over- or underflow */
359 /* Also, 0^0 is 1, while any other power of 0 is 0 */
360 result = p & 1 ? x : 1.0;
361
362 while (p >>= 1) {
363 pow2 *= pow2;
364 /* Process least significant bit in p */
365 if (p & 1) result *= pow2;
366 }
367
368 return result;
369}
370
371/*----------------------------------------------------------------------------*/
383/*----------------------------------------------------------------------------*/
384static cpl_error_code irplib_matrix_product_transpose(cpl_matrix * self,
385 const cpl_matrix * ma,
386 const cpl_matrix * mb)
387{
388
389 double sum;
390
391 double * ds = cpl_matrix_get_data(self);
392 const double * d1 = cpl_matrix_get_data_const( ma);
393 const double * d2 = cpl_matrix_get_data_const( mb);
394 const double * di;
395
396 const int nr = cpl_matrix_get_nrow(ma);
397 const int nc = cpl_matrix_get_nrow(mb);
398 const int nk = cpl_matrix_get_ncol(mb);
399 int i, j, k;
400
401
402 cpl_ensure_code(self != NULL, CPL_ERROR_NULL_INPUT);
403 cpl_ensure_code(ma != NULL, CPL_ERROR_NULL_INPUT);
404 cpl_ensure_code(mb != NULL, CPL_ERROR_NULL_INPUT);
405
406 cpl_ensure_code(cpl_matrix_get_ncol(ma) == nk,
407 CPL_ERROR_INCOMPATIBLE_INPUT);
408
409 if (cpl_matrix_get_nrow(self) != nr || cpl_matrix_get_ncol(self) != nc)
410 cpl_matrix_set_size(self, nr, nc);
411
412 for (i = 0; i < nr; i++, d1 += nk) {
413 /* Since ma and mb are addressed in the same manner,
414 they can use the same index, k */
415
416 di = d2; /* di points to first entry in i'th row */
417 for (j = 0; j < nc; j++, di += nk) {
418 sum = 0.0;
419 for (k = 0; k < nk; k++) {
420 sum += d1[k] * di[k];
421 }
422 ds[nc * i + j] = sum;
423 }
424 }
425
426 return CPL_ERROR_NONE;
427
428}
429
430/*----------------------------------------------------------------------------*/
444/*----------------------------------------------------------------------------*/
445static void irplib_polynomial_shift_double(double * coeffs, int n, double u)
446{
447
448 int i, j;
449
450
451 assert( coeffs );
452
453 assert( n > 0 );
454
455 for (j = 0; j < n-1; j++)
456 for (i = 1; i < n - j; i++ )
457 coeffs[n-1-i] += coeffs[n-i] * u;
458
459}
460
461/*----------------------------------------------------------------------------*/
473/*----------------------------------------------------------------------------*/
474static cpl_vector * irplib_vector_transform_mean(const cpl_vector * x,
475 double * pm)
476{
477
478 cpl_vector * xhat = cpl_vector_duplicate(x);
479
480
481 assert( xhat != NULL );
482 assert( pm != NULL );
483
484 *pm = cpl_vector_get_mean(xhat);
485 cpl_vector_subtract_scalar(xhat, *pm);
486
487 return xhat;
488
489}
490
491
519static cpl_matrix * irplib_matrix_product_normal_create(const cpl_matrix * self)
520{
521
522 cpl_matrix * product;
523 const double * ai = cpl_matrix_get_data_const(self);
524 const double * aj;
525 double * bwrite;
526 double sum;
527 const int m = cpl_matrix_get_nrow(self);
528 const int n = cpl_matrix_get_ncol(self);
529 int i, j, k;
530
531
532 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
533
534 bwrite = (double *) cpl_malloc(m * m * sizeof(double));
535
536 product = cpl_matrix_wrap(m, m, bwrite);
537
538 /* The result at (i,j) is the dot-product of i'th and j'th row */
539 for (i = 0; i < m; i++, ai += n, bwrite += m) {
540 aj = ai; /* aj points to first entry in j'th row */
541 for (j = i; j < m; j++, aj += n) {
542 sum = 0.0;
543 for (k = 0; k < n; k++) {
544 sum += ai[k] * aj[k];
545 }
546 bwrite[j] = sum;
547 }
548 }
549
550 return product;
551
552}
553
554
555
556/*----------------------------------------------------------------------------*/
598/*----------------------------------------------------------------------------*/
599static cpl_error_code
601 cpl_matrix * rhs)
602{
603
604 int n, i, j, k;
605 int nrhs;
606 const double * aread;
607 const double * ai;
608 double * bk;
609 double sub;
610
611 cpl_ensure_code(self != NULL, CPL_ERROR_NULL_INPUT);
612 cpl_ensure_code(rhs != NULL, CPL_ERROR_NULL_INPUT);
613
614 n = cpl_matrix_get_ncol(self);
615
616 cpl_ensure_code(cpl_matrix_get_nrow(self) == n, CPL_ERROR_ILLEGAL_INPUT);
617 cpl_ensure_code(cpl_matrix_get_ncol(rhs) == n, CPL_ERROR_INCOMPATIBLE_INPUT);
618
619 nrhs = cpl_matrix_get_nrow(rhs);
620
621 aread = cpl_matrix_get_data_const(self);
622
623 /* bk points to first entry in k'th right hand side */
624 bk = cpl_matrix_get_data(rhs);
625
626 for (k=0; k < nrhs; k++, bk += n) {
627
628 /* Forward substitution in column k */
629
630 /* Since self and rhs are addressed in the same manner,
631 they can use the same index, j */
632 ai = aread; /* ai points to first entry in i'th row */
633 for (i = 0; i < n; i++, ai += n) {
634 sub = 0.0;
635 for (j = 0; j < i; j++) {
636 sub += ai[j] * bk[j];
637 }
638 cpl_ensure_code(k > 0 || ai[j] != 0.0, CPL_ERROR_DIVISION_BY_ZERO);
639 bk[j] = (bk[j] - sub) / ai[j];
640 }
641
642 /* Back substitution in column k */
643
644 for (i = n-1; i >= 0; i--) {
645 sub = bk[i];
646 for (j = i+1; j < n; j++) {
647 sub -= aread[n * j + i] * bk[j];
648 }
649 bk[i] = sub/aread[n * i + i];
650 }
651 }
652
653 return CPL_ERROR_NONE;
654
655}
656
657
658/*---------------------------------------------------------------------------*/
694/*---------------------------------------------------------------------------*/
695cpl_error_code
697 const cpl_image * im,
698 int xpos,
699 int ypos,
700 int size,
701 double * norm,
702 double * xcen,
703 double * ycen,
704 double * sig_x,
705 double * sig_y,
706 double * fwhm_x,
707 double * fwhm_y)
708{
709 cpl_image * extracted ;
710 int is_rejected;
711 int llx, lly, urx, ury ;
712 double u0, ux, uy, uxx, uyy ;
713 double cenx, ceny;
714 const double * pi ;
715 int pos ;
716 double max_val ;
717 int i, j ;
718 int nx=0;
719 int ny=0;
720 int enx=0;
721 int eny=0;
722
723 /* Check entries */
724 cpl_ensure_code(im, CPL_ERROR_NULL_INPUT) ;
725
726 nx=cpl_image_get_size_x(im);
727 ny=cpl_image_get_size_y(im);
728
729 cpl_ensure_code(xpos>=1 && xpos<=nx, CPL_ERROR_ILLEGAL_INPUT);
730 cpl_ensure_code(ypos>=1 && ypos<=ny, CPL_ERROR_ILLEGAL_INPUT);
731
732 cpl_ensure_code(size>1 && size<nx && size<ny,
733 CPL_ERROR_ILLEGAL_INPUT) ;
734
735 /* Extraction zone */
736 llx = xpos - (int)(size/2) ;
737 lly = ypos - (int)(size/2) ;
738 urx = xpos + (int)(size/2) ;
739 ury = ypos + (int)(size/2) ;
740 if (llx < 1) llx = 1 ;
741 if (lly < 1) lly = 1 ;
742 if (urx > nx) urx = nx ;
743 if (ury > ny) ury = ny ;
744
745 /* Extract the image zone to fit */
746 extracted = cpl_image_extract(im, llx, lly, urx, ury) ;
747 cpl_ensure_code(extracted, CPL_ERROR_ILLEGAL_INPUT) ;
748
749 /* Check if there are enough good pixels */
750 if (5 * cpl_image_count_rejected(extracted) >
751 cpl_image_get_size_x(extracted) * cpl_image_get_size_y(extracted)) {
752 cpl_image_delete(extracted) ;
753 cpl_ensure_code(0, CPL_ERROR_ILLEGAL_INPUT) ;
754 }
755
756 if (cpl_image_get_type(extracted) != CPL_TYPE_DOUBLE) {
757 /* Convert the image to double */
758 cpl_image * tmp = extracted;
759 extracted = cpl_image_cast(tmp, CPL_TYPE_DOUBLE);
760 cpl_image_delete(tmp);
761 cpl_ensure_code(extracted, CPL_ERROR_TYPE_MISMATCH);
762 }
763 pi = cpl_image_get_data_double(extracted);
764
765
766 enx=cpl_image_get_size_x(extracted);
767 eny=cpl_image_get_size_y(extracted);
768 /* Compute xcen and ycen */
769 u0 = ux = uy = 0.0 ;
770 for (j=0 ; j<eny ; j++) {
771 for (i=0 ; i<enx ; i++) {
772 if (!cpl_image_is_rejected(extracted, i+1, j+1)) {
773 pos = i + j * enx ;
774 u0 += pi[pos] ;
775 ux += (i+1) * pi[pos] ;
776 uy += (j+1) * pi[pos] ;
777 }
778 }
779 }
780
781 /* cenx = ux/u0 may not be outside 1 and nx and
782 ceny = uy/u0 may not be outside 1 and ny */
783 if (u0 == 0 || u0 > ux || ux > u0*enx ||
784 u0 > uy || uy > u0*eny) {
785 cpl_image_delete(extracted) ;
786 cpl_ensure_code(0, CPL_ERROR_ILLEGAL_INPUT) ;
787 }
788
789 cenx = ux/u0;
790 ceny = uy/u0;
791
792 /* Compute sig_x and sig_y */
793 uxx = uyy = 0.0 ;
794 for (j=0 ; j<eny ; j++) {
795 for (i=0 ; i<enx ; i++) {
796 if (!cpl_image_is_rejected(extracted, i+1, j+1)) {
797 pos = i + j * enx ;
798 uxx += ((i+1)-cenx) * ((i+1)-cenx) * pi[pos] ;
799 uyy += ((j+1)-ceny) * ((j+1)-ceny) * pi[pos] ;
800 }
801 }
802 }
803 if (sig_x) *sig_x = sqrt(fabs(uxx/u0)) ;
804 if (sig_y) *sig_y = sqrt(fabs(uyy/u0)) ;
805 if (fwhm_x) *fwhm_x = 2 * sqrt(2 * log(2.0)) * sqrt(fabs(uxx/u0)) ;
806 if (fwhm_y) *fwhm_y = 2 * sqrt(2 * log(2.0)) * sqrt(fabs(uyy/u0)) ;
807
808 /* Compute norm */
809 max_val = cpl_image_get(extracted, (int)cenx, (int)ceny,
810 &is_rejected);
811 cpl_ensure_code(is_rejected >= 0, cpl_error_get_code());
812
813 if (is_rejected) {
814 cpl_errorstate pstate = cpl_errorstate_get();
815 max_val = cpl_image_get_mean_window(extracted, (int)cenx,
816 (int)ceny, (int)(cenx+1), (int)(ceny+1)) ;
817 cpl_ensure_code(cpl_errorstate_is_equal(pstate), cpl_error_get_code());
818 }
819
820 cpl_image_delete(extracted) ;
821
822 if (norm) *norm = max_val*2*CX_PI*sqrt(fabs(uxx/u0))*sqrt(fabs(uyy/u0)) ;
823
824 /* Shift xcen and ycen to coordinates in the input big image */
825 if (xcen) *xcen = cenx + llx - 1 ;
826 if (ycen) *ycen = ceny + lly - 1 ;
827
828
829 return CPL_ERROR_NONE ;
830}
831
832
833/* Define the C-type dependent functions */
834
835/* These two macros are needed for support of the different pixel types */
836
837#define CONCAT(a,b) a ## _ ## b
838#define CONCAT2X(a,b) CONCAT(a,b)
839
840#define CPL_TYPE double
841#include "xsh_fit_body.h"
842#undef CPL_TYPE
843
844#define CPL_TYPE float
845#include "xsh_fit_body.h"
846#undef CPL_TYPE
847
848#define CPL_TYPE int
849#include "xsh_fit_body.h"
850#undef CPL_TYPE
851
static cpl_error_code irplib_matrix_product_transpose(cpl_matrix *, const cpl_matrix *, const cpl_matrix *)
Fill a matrix with the product of A * B'.
Definition: xsh_fit.c:384
static double irplib_tools_ipow(double, int)
Compute x to the power of p.
Definition: xsh_fit.c:348
static cpl_matrix * irplib_matrix_product_normal_create(const cpl_matrix *)
Create and compute A = B * transpose(B)
Definition: xsh_fit.c:519
static void irplib_fit_imagelist_polynomial_float(cpl_imagelist *, const cpl_matrix *, const cpl_matrix *, const cpl_vector *, const cpl_imagelist *, const cpl_vector *, double, int, int, cpl_image *)
static void irplib_fit_imagelist_residual_float(cpl_image *, int, const cpl_vector *, const cpl_vector *, const cpl_matrix *, const cpl_matrix *)
static void irplib_fit_imagelist_polynomial_int(cpl_imagelist *, const cpl_matrix *, const cpl_matrix *, const cpl_vector *, const cpl_imagelist *, const cpl_vector *, double, int, int, cpl_image *)
static cpl_vector * irplib_vector_transform_mean(const cpl_vector *, double *)
Transform: xhat = x - mean(x)
Definition: xsh_fit.c:474
cpl_imagelist * xsh_fit_imagelist_polynomial(const cpl_vector *x_pos, const cpl_imagelist *values, int mindeg, int maxdeg, cpl_boolean is_eqdist, cpl_image *fiterror)
Fit a polynomial to each pixel in a list of images.
Definition: xsh_fit.c:171
static cpl_error_code irplib_matrix_solve_chol_transpose(const cpl_matrix *, cpl_matrix *)
Solve a L*transpose(L)-system with a transposed Right Hand Side.
Definition: xsh_fit.c:600
cpl_error_code xsh_image_find_barycenter(const cpl_image *im, int xpos, int ypos, int size, double *norm, double *xcen, double *ycen, double *sig_x, double *sig_y, double *fwhm_x, double *fwhm_y)
Apply a gaussian fit on an image sub window.
Definition: xsh_fit.c:696
static void irplib_fit_imagelist_polynomial_double(cpl_imagelist *, const cpl_matrix *, const cpl_matrix *, const cpl_vector *, const cpl_imagelist *, const cpl_vector *, double, int, int, cpl_image *)
static void irplib_polynomial_shift_double(double *, int, double)
Given p and u, modify the polynomial to p(x) := p(x+u)
Definition: xsh_fit.c:445
static void irplib_fit_imagelist_residual_double(cpl_image *, int, const cpl_vector *, const cpl_vector *, const cpl_matrix *, const cpl_matrix *)
static void irplib_fit_imagelist_residual_int(cpl_image *, int, const cpl_vector *, const cpl_vector *, const cpl_matrix *, const cpl_matrix *)
int size
int * x
int nx
int lly
Definition: xsh_detmon_lg.c:86
int llx
Definition: xsh_detmon_lg.c:85
int m
Definition: xsh_detmon_lg.c:91
int n
Definition: xsh_detmon_lg.c:92
int urx
Definition: xsh_detmon_lg.c:87
int ury
Definition: xsh_detmon_lg.c:88
int ny