56#define MODULE_ID "XSH_DATA_IMAGE_3D"
64 {
"nx", required_argument, 0,
NX_OPT},
65 {
"ny", required_argument, 0,
NY_OPT},
66 {
"nz", required_argument, 0,
NZ_OPT},
67 {
"debug", required_argument, 0,
DBG_OPT},
75static int Help(
void ) ;
79 printf(
"Test 3D images handling\n" ) ;
80 printf(
"Options:\n" ) ;
81 printf(
" --nx=<size> : X size of images (default 3)" ) ;
82 printf(
" --ny=<size> : Y size of images (default 4)" ) ;
83 printf(
" --nz=<size> : X size of images (default 3)" ) ;
84 printf(
" --dbg=<level> : Set debug level. <level> is one of:\n" ) ;
85 printf(
" none, low, high, medium.\n" ) ;
86 printf(
" Default is medium.\n" ) ;
95 while (( opt = getopt_long( argc, argv,
Options,
99 sscanf( optarg,
"%64d", &
Nx ) ;
102 sscanf( optarg,
"%64d", &
Ny ) ;
105 sscanf( optarg,
"%64d", &
Nz ) ;
109 else if ( strcmp( optarg,
"low" ) == 0 )
111 else if ( strcmp( optarg,
"medium" ) == 0 )
113 else if ( strcmp( optarg,
"high" ) == 0 )
125 int * pixels = NULL ;
129 check( pixels = cpl_image_get_data_int( img ) ) ;
132 for( iy = 0 ; iy <
Ny ; iy++,
first++ )
133 for( ix = 0 ; ix <
Nx ; ix++ ) {
134 *(pixels + ix + iy*
Nx) =
first ;
142 if ( one->
nx != two->
nx || one->
ny != two->
ny || one->
nz != two->
nz ) {
143 xsh_msg(
"Sizes not equal (nx: %d-%d, ny: %d-%d, nz: %d-%d",
144 one->
nx, two->
nx, one->
ny, two->
ny, one->
nz, two->
nz ) ;
150int main(
int argc,
char** argv)
154 cpl_image * img = NULL ;
157 cpl_propertylist * header = NULL ;
158 const char *
img_name =
"TEST_3D_IMAGE.fits" ;
162 cpl_msg_set_level( CPL_MSG_DEBUG);
169 xsh_msg(
"Img 3D: axis: %dx%dx%d, type: %d", img_3d->
nx, img_3d->
ny,
170 img_3d->
nz, img_3d->
type ) ;
173 for( iz = 0 ; iz <
Nz ; iz++ ) {
174 cpl_error_code err = CPL_ERROR_NONE ;
178 check( img = cpl_image_new(
Nx,
Ny, CPL_TYPE_INT ) ) ;
181 sprintf( i_name,
"TEST_3D_IMG_%d.fits", iz ) ;
182 cpl_image_save( img, i_name, CPL_BPP_32_SIGNED, NULL, CPL_IO_DEFAULT ) ;
185 xsh_msg(
" Insert Image err=%d", err ) ;
191 header, CPL_IO_DEFAULT ) ) ;
202 else xsh_msg(
"Finished OK" ) ;
int main()
Unit test of xsh_bspline_interpol.
static void HandleOptions(int argc, char **argv)
static const char * Options
static void fill_image(cpl_image *img, int first)
static struct option LongOptions[]
static int compare_img_3d(xsh_image_3d *one, xsh_image_3d *two)
static const char * img_name
cpl_error_code xsh_image_3d_insert(xsh_image_3d *img_3d, cpl_image *img, int iz)
cpl_error_code xsh_image_3d_save(xsh_image_3d *img_3d, const char *fname, cpl_propertylist *header, unsigned mode)
xsh_image_3d * xsh_image_3d_new(int nx, int ny, int nz, cpl_type type)
xsh_image_3d * xsh_image_3d_load(const char *filename, cpl_type type, int xtnum)
#define XSH_ASSURE_NOT_NULL(pointer)
#define xsh_msg(...)
Print a message on info level.
int xsh_debug_level_set(int level)
set debug level
#define TESTS_INIT(DRL_ID)