00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifdef HAVE_CONFIG_H
00027 # include <config.h>
00028 #endif
00029
00030
00036
00039
00040
00041
00042 #include <xsh_utils.h>
00043 #include <xsh_error.h>
00044 #include <xsh_msg.h>
00045 #include <tests.h>
00046 #include <cpl.h>
00047 #include <math.h>
00048 #include <time.h>
00049 #include <sys/time.h>
00050
00051
00052
00053 #define MODULE_ID "XSH_CPL_FIT"
00054
00055
00061
00062 int main( int argc, char** argv)
00063 {
00064 int ret = 0;
00065 char *image_name = NULL;
00066 cpl_image* image = NULL;
00067 double norm=0.0, xcen=0.0, ycen=0.0, sig_x=0.0, sig_y=0.0;
00068 int nx,ny;
00069
00070 TESTS_INIT( MODULE_ID);
00071 cpl_msg_set_level( CPL_MSG_DEBUG);
00072 xsh_debug_level_set( XSH_DEBUG_LEVEL_MEDIUM) ;
00073
00074 if (argc > 1){
00075 image_name = argv[1];
00076 }
00077 else{
00078 return 0;
00079 }
00080 check( image = cpl_image_load( image_name, CPL_TYPE_FLOAT, 0, 0));
00081 check( nx = cpl_image_get_size_x( image));
00082 check( ny = cpl_image_get_size_y( image));
00083
00084 xsh_msg( "nx %d ny %d", nx, ny);
00085
00086 cpl_image_fit_gaussian( image, 4, 4, 6, &norm, &xcen, &ycen, &sig_x, &sig_y, NULL, NULL);
00087
00088 if ( cpl_error_get_code() != CPL_ERROR_NONE){
00089 xsh_msg("Can not fit gaussian the image");
00090 }
00091 else{
00092 xsh_msg(" find center at %f %f", xcen, ycen);
00093 }
00094 cleanup:
00095 if (cpl_error_get_code() != CPL_ERROR_NONE) {
00096 xsh_error_dump(CPL_MSG_ERROR);
00097 ret = 1;
00098 }
00099 return ret;
00100 }
00101