This module is an instance of the same MedFilter that is run during outlier rejection in the Mosaic pipeline, and earlier in the APEX pipeline (before source detection). In this case, it performs the background subtraction of the image(s) that will be used for source extraction. In Multiframe pipelines, those are the individual input images, and in Single Frame pipelines it is the mosaic image. There are two options: the Median case (default) and the Sbkg case, which uses a background estimate like that of SExtractor.
INPUT
Window X, Y: (int) the X, Y size in input pixels of the window used to compute the background value.
Outliers / Window: (int) the number of high outlier pixels rejected from the X*Y window when computing the Median background. For a very crowded field, the fraction of rejected pixels should be higher than for a less crowded field. Values of a few percent should be acceptable for uncrowded fields. If Outliers / Window is set too high, the background will be under-estimated.
Min Good Pixels in Window: (int) The minimum number of good (non-NaN, non-masked) pixels needed to compute the median. If insufficient good pixels are present, the background is recorded as "missing" and the "missing" output pixel is replaced by interpolation of its neighbors if possible.
Min Good Neighbors Number: (int) The minimum number of good neighbor pixels needed to perform the replacement of "missing" output pixels.
SExtractor background filter size: (int) Median filter box size for the Panels when this option is set. A value less than 2 means no filtering. If greater than the minimum number of panels across an image, it will use the minimum.
Use SExtractor background estimation: (int) A value of 1 invokes the Sbkg background estimate based on SExtractor. Any other value gives the default Median estimate.
COMMAND LINE INPUT
&EXTRACT_MEDFILTER
Window_X = 45,
Window_Y = 45,
N_Outliers_Per_Window = 50,
Min_Good_Pixels_In_Window = 9,
Min_GoodNeighbors_Number = 4,
Max_Bad_Pixels_OutputImage = 100,
Sbkg_Filt_Size_for_Med = 1,
Use_Sbkg_for_Med = 1,
&END
Max_Bad_Pixels_OutputImage: (int; command line only) The maximum number of allowed bad (NaN) pixels in the output image.
OUTPUT
Generated FITS (*_Image_minback.fits in Multiframe modesor mosaic_minus_median_detect.fits in Single Frame modes): The output is the background subtracted mosaic image (or tiles). In Single Frame modes, the files are written in the main output directory, but in Multiframe pipelines, the tiles are stored in the Coadd-apex/ subdirectory.
DISCUSSION
The program computes an asymmetrically skewed median for each pixel in the input image using a rectangular window of Window X by Window Y pixels. It is achieved by omitting the Outliers / Window highest pixels from each median window.
There is a minimum required number of good (not-NaN and not flagged by any mask) pixels per median window Min Good Pixels In Window. If the number of good pixels is below this threshold then the corresponding pixel in the output image is marked as a "missing" pixel. When the median calculation is finished, the values of the marked pixels are interpolated from the neighboring pixels for which the median has been found. In order to do so the program scans around the pixel in question and accumulates values of good pixels. When the number of accumulated values reaches or exceeds the minimum number given by the input parameter Min Good Neighbors Number the program finds the average and stores this value as the median for the pixel in question.
This module is run earlier in the APEX flow as Detect MedFilter. The input parameters for Extract MedFilter should always be more aggressive than for Detect MedFilter (i.e. smaller window size and number of outliers).