X-shooter Pipeline Reference Manual 3.8.15
test-cpl_image_threshold.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_msg.h>
43#include <xsh_error.h>
44#include <tests.h>
45#include <cpl.h>
46#include <stdlib.h>
47#include <sys/time.h>
48/*---------------------------------------------------------------------------
49 Defines
50 ---------------------------------------------------------------------------*/
51#define MODULE_ID "CPL_IMAGE_THRESHOLD"
52/*--------------------------------------------------------------------------*/
58/*--------------------------------------------------------------------------*/
59int main( int argc, char** argv)
60{
61 int ret = 0;
62 char *image_name = NULL;
63 cpl_image* image = NULL;
64 double min=2;
65 double max=3;
66
68 check(cpl_msg_set_level( CPL_MSG_DEBUG));
70 xsh_msg_error("argc=%d",argc);
71 if (argc > 1){
72
73 image_name = argv[1];
74
75 if (argc == 3){
76 xsh_msg_error("ok1");
77 min=atof(argv[2]);
78 xsh_msg_error("ok2");
79 }
80 xsh_msg_error("ok3");
81
82 if (argc == 4){
83 min=atof(argv[2]);
84 max=atof(argv[3]);
85 }
86 }
87 else{
88 return 0;
89 }
90 xsh_msg( "min: %g max %g", min, max);
91 image = cpl_image_load( image_name, CPL_TYPE_FLOAT, 0, 0);
92 cpl_image_threshold(image,min,max,0,0);
93 cpl_image_threshold(image,0,1,0,1);
94 //cpl_image_threshold(image,max,max,0,1);
95 cpl_image_save(image,"image_thresh.fits", CPL_TYPE_FLOAT, NULL, CPL_IO_DEFAULT);
96 cpl_image_delete(image);
97cleanup:
98
99 if (cpl_error_get_code() != CPL_ERROR_NONE) {
100 xsh_error_dump(CPL_MSG_ERROR);
101 ret = 1;
102 }
103 return ret;
104}
105
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_error(...)
Print an error message.
Definition: xsh_msg.h:62
#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
#define max(a, b)
@ XSH_DEBUG_LEVEL_MEDIUM
Definition: xsh_utils.h:138