MIDI Pipeline Reference Manual  2.8.3
midi_opdff.c
1 /* $Id: midi_opdff.c,v 1.16 2010-05-28 09:16:01 agabasch Exp $
2  *
3  * This file is part of the MIDI Pipeline
4  * Copyright (C) 2002,2003 European Southern Observatory
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 
21 /*
22  * $Author: agabasch $
23  * $Date: 2010-05-28 09:16:01 $
24  * $Revision: 1.16 $
25  * $Name: not supported by cvs2svn $
26  */
27 
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 
32 /*-----------------------------------------------------------------------------
33  Includes
34  -----------------------------------------------------------------------------*/
35 
36 #include <cpl.h>
37 #include "midi_utils.h"
38 #include "midi_cplutils.h"
39 #include "cpl_image_filter.h"
40 
41 #include "midi_dfs.h"
42 #include "string.h"
43 
44 #define DIMENDATA 2
45 /*-----------------------------------------------------------------------------
46  Private function prototypes
47  -----------------------------------------------------------------------------*/
48 
49 static int midi_opdff_create(cpl_plugin *);
50 static int midi_opdff_exec(cpl_plugin *);
51 static int midi_opdff_destroy(cpl_plugin *);
52 static int midi_opdff(cpl_frameset *, const cpl_parameterlist *);
53 
54 static void midi_check_medianwindow(int * medianwindowX, int * medianwindowY);
55 
56 
57 static int append_image_to_table(cpl_table * table, const char * columname,
58  cpl_image * image, int row);
59 
60 
61 /*-----------------------------------------------------------------------------
62  Static variables
63  -----------------------------------------------------------------------------*/
64 
65 static char midi_opdff_description[] =
66 "TBD\n"
67 "\n";
68 
69 /*-----------------------------------------------------------------------------
70  Function code
71  -----------------------------------------------------------------------------*/
72 
73 /*----------------------------------------------------------------------------*/
78 /*----------------------------------------------------------------------------*/
79 
82 /*----------------------------------------------------------------------------*/
92 /*----------------------------------------------------------------------------*/
93 int cpl_plugin_get_info(cpl_pluginlist * list)
94 {
95  cpl_recipe * recipe = cpl_calloc(1, sizeof *recipe );
96  cpl_plugin * plugin = &recipe->interface;
97 
98  if (cpl_plugin_init(plugin,
99  CPL_PLUGIN_API,
100  MIDI_BINARY_VERSION,
101  CPL_PLUGIN_TYPE_RECIPE,
102  "midi_opdff",
103  "Derives the flatfield for the OPD measurements",
104  midi_opdff_description,
105  "Armin Gabasch",
106  PACKAGE_BUGREPORT,
108  midi_opdff_create,
109  midi_opdff_exec,
110  midi_opdff_destroy)) {
111  cpl_msg_error(cpl_func, "Plugin initialization failed");
112  (void)cpl_error_set_where(cpl_func);
113  return 1;
114  }
115 
116  if (cpl_pluginlist_append(list, plugin)) {
117  cpl_msg_error(cpl_func, "Error adding plugin to list");
118  (void)cpl_error_set_where(cpl_func);
119  return 1;
120  }
121 
122  return 0;
123 }
124 
125 /*----------------------------------------------------------------------------*/
133 /*----------------------------------------------------------------------------*/
134 static int midi_opdff_create(cpl_plugin * plugin)
135 {
136  cpl_recipe * recipe;
137  cpl_parameter * p;
138 
139  /* Do not create the recipe if an error code is already set */
140  if (cpl_error_get_code() != CPL_ERROR_NONE) {
141  cpl_msg_error(cpl_func, "%s():%d: An error is already set: %s",
142  cpl_func, __LINE__, cpl_error_get_where());
143  return (int)cpl_error_get_code();
144  }
145 
146  if (plugin == NULL) {
147  cpl_msg_error(cpl_func, "Null plugin");
148  cpl_ensure_code(0, (int)CPL_ERROR_NULL_INPUT);
149  }
150 
151  /* Verify plugin type */
152  if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
153  cpl_msg_error(cpl_func, "Plugin is not a recipe");
154  cpl_ensure_code(0, (int)CPL_ERROR_TYPE_MISMATCH);
155  }
156 
157  /* Get the recipe */
158  recipe = (cpl_recipe *)plugin;
159 
160  /* Create the parameters list in the cpl_recipe object */
161  recipe->parameters = cpl_parameterlist_new();
162  if (recipe->parameters == NULL) {
163  cpl_msg_error(cpl_func, "Parameter list allocation failed");
164  cpl_ensure_code(0, (int)CPL_ERROR_ILLEGAL_OUTPUT);
165  }
166 
167  /* Fill the parameters list */
168 
169  p = cpl_parameter_new_value("midi.midi_opdff.Xmedianwindow",
170  CPL_TYPE_INT, "The window size in x-direction of the median filter", "midi.midi_opdff",5);
171  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "Xmedianwindow");
172  cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
173  cpl_parameterlist_append(recipe->parameters, p);
174 
175  p = cpl_parameter_new_value("midi.midi_opdff.Ymedianwindow",
176  CPL_TYPE_INT, "The window size in y-direction of the median filter", "midi.midi_opdff",5);
177  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "Ymedianwindow");
178  cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
179  cpl_parameterlist_append(recipe->parameters, p);
180 
181 
182  return 0;
183 }
184 
185 /*----------------------------------------------------------------------------*/
191 /*----------------------------------------------------------------------------*/
192 static int midi_opdff_exec(cpl_plugin * plugin)
193 {
194 
195  cpl_recipe * recipe;
196  int recipe_status;
197  cpl_errorstate initial_errorstate = cpl_errorstate_get();
198 
199  /* Return immediately if an error code is already set */
200  if (cpl_error_get_code() != CPL_ERROR_NONE) {
201  cpl_msg_error(cpl_func, "%s():%d: An error is already set: %s",
202  cpl_func, __LINE__, cpl_error_get_where());
203  return (int)cpl_error_get_code();
204  }
205 
206  if (plugin == NULL) {
207  cpl_msg_error(cpl_func, "Null plugin");
208  cpl_ensure_code(0, (int)CPL_ERROR_NULL_INPUT);
209  }
210 
211  /* Verify plugin type */
212  if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
213  cpl_msg_error(cpl_func, "Plugin is not a recipe");
214  cpl_ensure_code(0, (int)CPL_ERROR_TYPE_MISMATCH);
215  }
216 
217  /* Get the recipe */
218  recipe = (cpl_recipe *)plugin;
219 
220  /* Verify parameter and frame lists */
221  if (recipe->parameters == NULL) {
222  cpl_msg_error(cpl_func, "Recipe invoked with NULL parameter list");
223  cpl_ensure_code(0, (int)CPL_ERROR_NULL_INPUT);
224  }
225  if (recipe->frames == NULL) {
226  cpl_msg_error(cpl_func, "Recipe invoked with NULL frame set");
227  cpl_ensure_code(0, (int)CPL_ERROR_NULL_INPUT);
228  }
229 
230  /* Invoke the recipe */
231  recipe_status = midi_opdff(recipe->frames, recipe->parameters);
232 
233  /* Ensure DFS-compliance of the products */
234  if (cpl_dfs_update_product_header(recipe->frames)) {
235  if (!recipe_status) recipe_status = (int)cpl_error_get_code();
236  }
237 
238  if (!cpl_errorstate_is_equal(initial_errorstate)) {
239  /* Dump the error history since recipe execution start.
240  At this point the recipe cannot recover from the error */
241  cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);
242  }
243 
244  return recipe_status;
245 }
246 
247 /*----------------------------------------------------------------------------*/
253 /*----------------------------------------------------------------------------*/
254 static int midi_opdff_destroy(cpl_plugin * plugin)
255 {
256  cpl_recipe * recipe;
257 
258  if (plugin == NULL) {
259  cpl_msg_error(cpl_func, "Null plugin");
260  cpl_ensure_code(0, (int)CPL_ERROR_NULL_INPUT);
261  }
262 
263  /* Verify plugin type */
264  if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
265  cpl_msg_error(cpl_func, "Plugin is not a recipe");
266  cpl_ensure_code(0, (int)CPL_ERROR_TYPE_MISMATCH);
267  }
268 
269  /* Get the recipe */
270  recipe = (cpl_recipe *)plugin;
271 
272  cpl_parameterlist_delete(recipe->parameters);
273 
274  return 0;
275 }
276 
277 /*----------------------------------------------------------------------------*/
284 /*----------------------------------------------------------------------------*/
285 static int midi_opdff(cpl_frameset * frameset,
286  const cpl_parameterlist * parlist)
287 {
288 
289  const cpl_parameter * paramX=NULL;
290  const cpl_parameter * paramY=NULL;
291  cpl_frame * cur_frame=NULL;
292  int dimenDATA=DIMENDATA; /* Assumption: HS Data */
293  cpl_imagelist * imglst_AOPEN_DATA_T[DIMENDATA]={NULL,NULL}; /* Assumption: HS Data */
294  cpl_imagelist * imglst_BOPEN_DATA_T[DIMENDATA]={NULL,NULL}; /* Assumption: HS Data */
295  cpl_image * dummy_image;
296  cpl_image * image_AOPEN_DATA_T[DIMENDATA]; /* Assumption: HS Data */
297  cpl_image * image_BOPEN_DATA_T[DIMENDATA]; /* Assumption: HS Data */
298  cpl_image * image_AOPEN_DATA_T_filtered[DIMENDATA]; /* Assumption: HS Data */
299  cpl_image * image_BOPEN_DATA_T_filtered[DIMENDATA]; /* Assumption: HS Data */
300  cpl_image * flatfield_AOPEN[DIMENDATA]; /* Assumption: HS Data */
301  cpl_image * flatfield_BOPEN[DIMENDATA]; /* Assumption: HS Data */
302  cpl_errorstate prestate = cpl_errorstate_get();
303  int medianwindowX=0;
304  int medianwindowY=0;
305  int i=0;
306  char * tag=NULL;
307  int ext_imaging_data=0;
308  cpl_table * table=NULL;
309  char * dataname=NULL;
310  cpl_propertylist * qclist=NULL;
311  cpl_propertylist * pro_list=NULL;
312  cpl_mask * mask=NULL;
313  cpl_table * opdff_table=NULL;
314 
315 
316 
317 /* Check if siutable files are present in the SOF */
318  if(midi_check_sof(frameset,MIDI_DOME_AOPEN)<1)
319  {
320  return (int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
321  "SOF has no appropriate AOPEN fitsfiles! Aborting!");
322 
323  }
324 
325  if(midi_check_sof(frameset,MIDI_DOME_BOPEN)<1)
326  {
327  return (int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
328  "SOF has no appropriate BOPEN fitsfiles! Aborting!");
329 
330  }
331 
332  /* RETRIEVE THE INPUT PARAMETERS */
333 
334  paramX = cpl_parameterlist_find_const(parlist,
335  "midi.midi_opdff.Xmedianwindow");
336  paramY = cpl_parameterlist_find_const(parlist,
337  "midi.midi_opdff.Ymedianwindow");
338  medianwindowX = cpl_parameter_get_int(paramX);
339  medianwindowY = cpl_parameter_get_int(paramY);
340  midi_check_medianwindow(&medianwindowX, &medianwindowY);
341 
342  if (!cpl_errorstate_is_equal(prestate)) {
343  return (int)cpl_error_set_message(cpl_func, cpl_error_get_code(), "Could not retrieve the input parameters");
344  }
345 
346  /* Identify the RAW and CALIB frames in the input frameset */
347  cpl_ensure_code(midi_dfs_set_groups(frameset) == CPL_ERROR_NONE,
348  cpl_error_get_code());
349 
350 
351  for (i=0; i<dimenDATA;i++){
352  imglst_AOPEN_DATA_T[i]=cpl_imagelist_new();
353  imglst_BOPEN_DATA_T[i]=cpl_imagelist_new();
354 
355  }
356 
357  cur_frame = cpl_frameset_get_first(frameset);
358  if (cur_frame == NULL) {
359  return (int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
360  "SOF does not have any file");
361  }
362 
363 /* Walk through the whole Set of Frames SOF and */
364 /* append the images from the tables to the various imagelists */
365 
366  while(cur_frame)
367  {
368 
369  tag = (char*)cpl_frame_get_tag(cur_frame);
370  if (strcmp(tag, MIDI_DOME_AOPEN) && strcmp(tag, MIDI_DOME_BOPEN)) {
371  cur_frame = cpl_frameset_get_next( frameset );
372  continue;
373  }
374  cpl_msg_info(cpl_func, "Processing file %s",cpl_frame_get_filename(cur_frame));
375  ext_imaging_data=cpl_fits_find_extension(cpl_frame_get_filename(cur_frame),"IMAGING_DATA");
376 
377  if (strcmp(tag, MIDI_DOME_AOPEN)==0)
378  {
379  /* Load extension Imaging Data */
380  table = cpl_table_load(cpl_frame_get_filename(cur_frame), ext_imaging_data, 1);
381  if (table == NULL) {
382  return (int)cpl_error_set_message(cpl_func, cpl_error_get_code(),
383  "Could not load the table");
384  }
385  cpl_ensure_code(cpl_errorstate_is_equal(prestate), cpl_error_get_code());
386 
387 
388  for (i=0; i<dimenDATA;i++){
389 
390  dataname=cpl_sprintf("DATA%d",i+1);
391 
392  /* cpl_msg_info(cpl_func, "Scanning for dataname ..."); */
393  if (cpl_table_has_column(table,dataname)){
394  table_to_imglst(dataname,imglst_AOPEN_DATA_T[i],table);
395  }
396 
397  cpl_msg_info(cpl_func, "Number of so far processed AOPEN %s Frames: %d",dataname,cpl_imagelist_get_size(imglst_AOPEN_DATA_T[i]));
398  cpl_free(dataname);
399  }
400 
401  cpl_ensure_code(cpl_errorstate_is_equal(prestate), cpl_error_get_code());
402 
403  cpl_table_delete(table);
404  }
405  if (strcmp(tag, MIDI_DOME_BOPEN)==0)
406  {
407  /* Load extension Imaging Data */
408  table = cpl_table_load(cpl_frame_get_filename(cur_frame), ext_imaging_data, 1);
409  if (table == NULL) {
410  return (int)cpl_error_set_message(cpl_func, cpl_error_get_code(),
411  "Could not load the table");
412  }
413  cpl_ensure_code(cpl_errorstate_is_equal(prestate), cpl_error_get_code());
414 
415 
416  for (i=0; i<dimenDATA;i++){
417 
418  dataname=cpl_sprintf("DATA%d",i+1);
419 
420  /* cpl_msg_info(cpl_func, "Scanning for dataname ..."); */
421  if (cpl_table_has_column(table,dataname)){
422  table_to_imglst(dataname,imglst_BOPEN_DATA_T[i],table);
423  }
424 
425  cpl_msg_info(cpl_func, "Number of so far processed BOPEN %s Frames: %d",dataname,cpl_imagelist_get_size(imglst_BOPEN_DATA_T[i]));
426  cpl_free(dataname);
427  }
428 
429  cpl_ensure_code(cpl_errorstate_is_equal(prestate), cpl_error_get_code());
430 
431  cpl_table_delete(table);
432  }
433 
434  cur_frame = cpl_frameset_get_next( frameset );
435  }
436 
437 
438 
439 /* Collapse the imagelists */
440 
441  for (i=0; i<dimenDATA;i++){
442 
443  dummy_image=cpl_imagelist_collapse_create(imglst_AOPEN_DATA_T[i]);
444  image_AOPEN_DATA_T[i]=cpl_image_cast(dummy_image,CPL_TYPE_DOUBLE);
445  cpl_image_delete(dummy_image);
446 
447  dummy_image=cpl_imagelist_collapse_create(imglst_BOPEN_DATA_T[i]);
448  image_BOPEN_DATA_T[i]=cpl_image_cast(dummy_image,CPL_TYPE_DOUBLE);
449  cpl_image_delete(dummy_image);
450 
451  }
452 
453 /* Smooth the images by a median filter */
454 
455  mask = cpl_mask_new(medianwindowX, medianwindowY);
456  cpl_mask_not(mask);
457 
458  cpl_msg_info(cpl_func, "Smoothing the images ...");
459 
460 
461  for (i=0; i<dimenDATA;i++){
462  image_AOPEN_DATA_T_filtered[i]=cpl_image_duplicate(image_AOPEN_DATA_T[i]);
463  image_BOPEN_DATA_T_filtered[i]=cpl_image_duplicate(image_BOPEN_DATA_T[i]);
464  }
465 
466 
467  for (i=0; i<dimenDATA;i++){
468  cpl_image_filter_mask(image_AOPEN_DATA_T_filtered[i],image_AOPEN_DATA_T[i], mask,CPL_FILTER_MEDIAN ,CPL_BORDER_FILTER);
469  cpl_image_filter_mask(image_BOPEN_DATA_T_filtered[i],image_BOPEN_DATA_T[i], mask,CPL_FILTER_MEDIAN ,CPL_BORDER_FILTER);
470 
471  }
472 
473 
474 /* Devide the image through the median filtered image */
475 
476  for (i=0; i<dimenDATA;i++){
477  flatfield_AOPEN[i]=cpl_image_divide_create(image_AOPEN_DATA_T[i],image_AOPEN_DATA_T_filtered[i]);
478  flatfield_BOPEN[i]=cpl_image_divide_create(image_BOPEN_DATA_T[i],image_BOPEN_DATA_T_filtered[i]);
479  }
480 
481 
482 /* Average BOPEN and AOPEN case */
483 
484  for (i=0; i<dimenDATA;i++){
485  cpl_image_add(flatfield_AOPEN[i],flatfield_BOPEN[i]);
486  cpl_image_divide_scalar(flatfield_AOPEN[i],2.0);
487  }
488 
489 
490 /* Save the flatfields */
491  qclist = cpl_propertylist_new();
492  cpl_propertylist_update_string(qclist, CPL_DFS_PRO_CATG, "MIDI_OPDFF_DATA1");
493  if (cpl_dfs_save_image(frameset, NULL, parlist, frameset, NULL, flatfield_AOPEN[0],
494  CPL_BPP_IEEE_FLOAT, "flatfield_DATA1",
495  qclist, NULL,
496  PACKAGE "/" PACKAGE_VERSION,
497  "flatfield_DATA1.fits")) {
498  /* Propagate the error */
499  (void)cpl_error_set_where(cpl_func);
500  }
501  cpl_propertylist_update_string(qclist, CPL_DFS_PRO_CATG, "MIDI_OPDFF_DATA2");
502  if (cpl_dfs_save_image(frameset, NULL, parlist, frameset, NULL, flatfield_AOPEN[1],
503  CPL_BPP_IEEE_FLOAT, "flatfield_DATA2",
504  qclist, NULL,
505  PACKAGE "/" PACKAGE_VERSION,
506  "flatfield_DATA2.fits")) {
507  /* Propagate the error */
508  (void)cpl_error_set_where(cpl_func);
509  }
510 
511 
512 /* Save it to a fits table */
513 
514  opdff_table=cpl_table_new(1);
515 
516 /* Propertylist to write to the extension */
517 
518  cpl_propertylist_update_string(qclist, CPL_DFS_PRO_CATG, "MIDI_OPDFF");
519  cpl_propertylist_append_string(qclist, "EXTNAME", "IMAGING_DATA");
520 
521  append_image_to_table(opdff_table,"DATA1",flatfield_AOPEN[0],0);
522  append_image_to_table(opdff_table,"DATA2",flatfield_AOPEN[1],0);
523 
524  cpl_dfs_save_table(frameset, NULL, parlist, frameset, NULL, opdff_table,
525  qclist, "midi_opdff",
526  qclist, NULL,
527  PACKAGE "/" PACKAGE_VERSION,
528  "midi_opdff.fits");
529  cpl_table_delete(opdff_table);
530 
531 
532 
533 
534 
535 /* Release the memory */
536 
537  cpl_mask_delete(mask);
538  cpl_propertylist_delete(qclist);
539  cpl_propertylist_delete(pro_list);
540 
541  for (i=0; i<dimenDATA;i++){
542  cpl_image_delete(flatfield_AOPEN[i]);
543  cpl_image_delete(flatfield_BOPEN[i]);
544  cpl_image_delete(image_AOPEN_DATA_T[i]);
545  cpl_image_delete(image_BOPEN_DATA_T[i]);
546  cpl_image_delete(image_AOPEN_DATA_T_filtered[i]);
547  cpl_image_delete(image_BOPEN_DATA_T_filtered[i]);
548  }
549 
550  for (i=0; i<dimenDATA;i++){
551  while(cpl_imagelist_get_size(imglst_AOPEN_DATA_T[i])>0){
552  cpl_image_delete(cpl_imagelist_unset(imglst_AOPEN_DATA_T[i],0));
553  }
554  while(cpl_imagelist_get_size(imglst_BOPEN_DATA_T[i])>0){
555  cpl_image_delete(cpl_imagelist_unset(imglst_BOPEN_DATA_T[i],0));
556  }
557  cpl_imagelist_delete(imglst_AOPEN_DATA_T[i]);
558  cpl_imagelist_delete(imglst_BOPEN_DATA_T[i]);
559  }
560 
561  return (int)cpl_error_get_code();
562 }
563 
564 
565 
566 
567 
568 
569 
570 
571 /*----------------------------------------------------------------------------*/
580 /*----------------------------------------------------------------------------*/
581 
582 static int append_image_to_table(cpl_table * table, const char * columname, cpl_image * image, int row)
583 {
584 
585  cpl_array * array_dimension=NULL;
586  cpl_array * array_dummy=NULL;
587 
588  array_dimension=cpl_array_new(2,CPL_TYPE_INT);
589  cpl_array_set(array_dimension, 0,cpl_image_get_size_x(image));
590  cpl_array_set(array_dimension, 1,cpl_image_get_size_y(image));
591 
592  cpl_table_new_column_array(table, columname, CPL_TYPE_DOUBLE, cpl_image_get_size_x(image)*cpl_image_get_size_y(image));
593  cpl_table_set_column_dimensions(table,columname,array_dimension);
594  array_dummy = cpl_array_wrap_double(cpl_image_get_data_double(image), cpl_image_get_size_x(image)*cpl_image_get_size_y(image));
595  cpl_table_set_array(table, columname, row, array_dummy);
596  cpl_array_unwrap(array_dummy);
597 
598 
599  cpl_array_delete(array_dimension);
600 
601  return 0;
602 }
603 
604 
605 /*----------------------------------------------------------------------------*/
612 /*----------------------------------------------------------------------------*/
613 
614 static void midi_check_medianwindow(int * medianwindowX, int * medianwindowY)
615 {
616 
617  if((*medianwindowX)%2 == 0)/* even number */
618  {
619  cpl_msg_warning(cpl_func, "The x window size of the median filter is not odd,");
620  cpl_msg_warning(cpl_func, "therefore the size is increased by unity");
621  *medianwindowX=*medianwindowX+1;
622  }
623  if((*medianwindowY)%2 == 0)/* even number */
624  {
625  cpl_msg_warning(cpl_func, "The y window size of the median filter is not odd,");
626  cpl_msg_warning(cpl_func, "therefore the size is increased by unity");
627  *medianwindowY=*medianwindowY+1;
628  }
629 
630 /* if((*medianwindowX)*(*medianwindowY)> 81) */
631 /* { */
632 /* cpl_msg_warning(cpl_func, "The window size of the median filter exceeds the maximal supported value,"); */
633 /* cpl_msg_warning(cpl_func, "therefore the size is reset to 9x9"); */
634 /* *medianwindowX=9; */
635 /* *medianwindowY=9; */
636 
637 /* } */
638 
639  if(*medianwindowX < 0)
640  {
641  cpl_msg_warning(cpl_func, "The x window size of the median filter must be positive,");
642  cpl_msg_warning(cpl_func, "therefore the size is reset to 1");
643  *medianwindowX=1;
644  }
645 
646  if(*medianwindowY < 0)
647  {
648  cpl_msg_warning(cpl_func, "The y window size of the median filter must be positive,");
649  cpl_msg_warning(cpl_func, "therefore the size is reset to 1");
650  *medianwindowY=1;
651  }
652 
653 
654 }
655 
656 
657 
658