X-shooter Pipeline Reference Manual 3.8.15
test-cpl_image_fit_gaussian.c
Go to the documentation of this file.
1/* *
2 * This file is part of the ESO X-shooter Pipeline *
3 * Copyright (C) 2006 European Southern Observatory *
4 * *
5 * This library is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA *
18 * */
19
20/*
21 * $Author: amodigli $
22 * $Date: 2011-12-02 14:13:14 $
23 * $Revision: 1.3 $
24 * $Name: not supported by cvs2svn $
25 */
26#ifdef HAVE_CONFIG_H
27# include <config.h>
28#endif
29
30/*--------------------------------------------------------------------------*/
36/*--------------------------------------------------------------------------*/
39/*---------------------------------------------------------------------------
40 Includes
41 ---------------------------------------------------------------------------*/
42#include <xsh_utils.h>
43#include <xsh_error.h>
44#include <xsh_msg.h>
45#include <tests.h>
46#include <cpl.h>
47#include <math.h>
48#include <time.h>
49#include <sys/time.h>
50/*---------------------------------------------------------------------------
51 Defines
52 ---------------------------------------------------------------------------*/
53#define MODULE_ID "CPL_IMAGE_FIT_GAUSSIAN"
54
55/*--------------------------------------------------------------------------*/
61/*--------------------------------------------------------------------------*/
62int main( int argc, char** argv)
63{
64 int ret = 0;
65 char *image_name = NULL;
66 cpl_image* image = NULL;
67 double norm=0.0, xcen=0.0, ycen=0.0, sig_x=0.0, sig_y=0.0;
68 int nx,ny;
69
71 cpl_msg_set_level( CPL_MSG_DEBUG);
73
74 if (argc > 1){
75 image_name = argv[1];
76 }
77 else{
78 return 0;
79 }
80 check( image = cpl_image_load( image_name, CPL_TYPE_FLOAT, 0, 0));
81 check( nx = cpl_image_get_size_x( image));
82 check( ny = cpl_image_get_size_y( image));
83
84 xsh_msg( "nx %d ny %d", nx, ny);
85
86 cpl_image_fit_gaussian( image, 4, 4, 6, &norm, &xcen, &ycen, &sig_x, &sig_y, NULL, NULL);
87
88 if ( cpl_error_get_code() != CPL_ERROR_NONE){
89 xsh_msg("Can not fit gaussian the image");
90 }
91 else{
92 xsh_msg(" find center at %f %f", xcen, ycen);
93 }
94 cleanup:
95 if (cpl_error_get_code() != CPL_ERROR_NONE) {
96 xsh_error_dump(CPL_MSG_ERROR);
97 ret = 1;
98 }
99 return ret;
100}
101
int main()
Unit test of xsh_bspline_interpol.
#define check(COMMAND)
Definition: xsh_error.h:71
#define xsh_error_dump(level)
Definition: xsh_error.h:92
#define xsh_msg(...)
Print a message on info level.
Definition: xsh_msg.h:121
#define MODULE_ID
int xsh_debug_level_set(int level)
set debug level
Definition: xsh_utils.c:3125
#define TESTS_INIT(DRL_ID)
Definition: tests.h:105
int nx
int ny
@ XSH_DEBUG_LEVEL_MEDIUM
Definition: xsh_utils.h:138