66 #define PRINT_USAGE(rc) \
67 fprintf(stderr, "Usage: %s [ -d datavalue ] [ -q dqvalue] [ -s statvalue ] " \
68 "IMAGE_IN IMAGE_OUT\n", argv[0]); \
69 cpl_end(); return (rc);
71 int main(
int argc,
char **argv)
73 cpl_init(CPL_INIT_DEFAULT);
85 cpl_size dqvalue = -1;
89 for (i = 1; i < argc; i++) {
90 if (strncmp(argv[i],
"-d", 3) == 0) {
94 datavalue = atof(argv[i]);
98 }
else if (strncmp(argv[i],
"-q", 3) == 0) {
102 dqvalue = atoi(argv[i]);
103 if (dqvalue < 0 || dqvalue > UINT_MAX) {
109 }
else if (strncmp(argv[i],
"-s", 3) == 0) {
113 statvalue = atof(argv[i]);
120 }
else if (strncmp(argv[i],
"-", 1) == 0) {
123 if (iname && oname) {
138 printf(
"Loaded \"%s\".\n", iname);
141 cpl_error_code rc = CPL_ERROR_NONE;
142 cpl_size nx = cpl_image_get_size_x(image->
data),
143 ny = cpl_image_get_size_y(image->
data);
144 rc = cpl_image_fill_window(image->
data, 1, 1, nx, ny, datavalue);
145 printf(
"Filled DATA image with %g (rc = %d)\n", datavalue, rc);
146 rc = cpl_image_fill_window(image->
stat, 1, 1, nx, ny, statvalue);
147 printf(
"Filled STAT image with %g (rc = %d)\n", statvalue, rc);
149 rc = cpl_image_fill_window(image->
dq, 1, 1, nx, ny, dqvalue);
150 printf(
"Filled DQ image with %u (rc = %d)\n", (
unsigned int)dqvalue, rc);
152 if (!cpl_propertylist_has(image->
header,
"BUNIT")) {
153 cpl_propertylist_append_string(image->
header,
"BUNIT",
"count");
157 if (rc != CPL_ERROR_NONE) {
158 fprintf(stderr,
"Some error occurred while saving to \"%s\" "
159 "(rc = %d, %s)\n", oname, rc, cpl_error_get_message());
162 printf(
"Saved to \"%s\".\n", oname);
void muse_image_delete(muse_image *aImage)
Deallocate memory associated to a muse_image object.
cpl_image * data
the data extension
cpl_image * stat
the statistics extension
Structure definition of MUSE three extension FITS file.
cpl_propertylist * header
the FITS header
cpl_image * dq
the data quality extension
cpl_error_code muse_image_save(muse_image *aImage, const char *aFilename)
Save the three image extensions and the FITS headers of a MUSE image to a file.
muse_image * muse_image_load(const char *aFilename)
Load the three extensions and the FITS headers of a MUSE image from a file.