Help for MEDFILL
PURPOSE:
MEDFILL fills holes in an image using a median filter of surrounding
pixels.
EXECUTION:
The pixels to fill are controlled by MIN, MAX, ZERO, and NONAN. Normally
any pixels with a "NAN" value (for REAL images only) are filled; -nonan
turns this off. -zero says to fill any pixels with a zero value. MIN and
MAX specify the DN limits; anything outside this range ( <MIN or >MAX) will
be filled. Note that neighboring pixels in the window are ignored if they
meet the fill criteria. If there are no neighboring pixels with values, the
pixel is replaced by the value in NODATA if that parameter is specified, or
left alone if NODATA is not specifed.
The fill window is set by NLW, NSW. The default is 5x5, which means a 5x5
box centered on the pixel. The window sizes must be odd.
If -BAYER is set, then it assumes the input image is a Bayer-pattern image,
so it looks only at pixels with the same Bayer filter. Practically speaking,
this means the image index increments by 2 instead of 1 when filling the window.
Note that the window size is unaffected, so a 5x5 window will actually look at
just 8 pixels, indicated by X's below.
X - X - X
- - - - -
X - O - X
- - - - -
X - X - X
This means that a 3x3 window is essentially a no-op, as only the central pixel
is considered. A 7x7 window will be the same as 5x5, but 9x9 will add another
set of pixels. To avoid having to worry about Bayer cell orientation, the two
Gren pixels are considered separately.
If the window goes off the edge of the image, only the pixels in the image will
be used - no reflection or extension is done. If the image has a gradient, this
could cause a bias on the edges.
In order to accommodate floating-point pixels, the actual pixel values are
gathered and sorted, rather than trying to use a histogram.
Little consideration has been given to performance.
HISTORY:
2021-03-18 rgd Initial version
COGNIZANT PROGRAMMER: Bob Deen
PARAMETERS:
INP
Input image
OUT
Output image
NLW
Window height
NSW
Window width
BAYER
Turns on Bayer mode
NODATA
DN to replace with if no
data in window
ZERO
Flag to replace zeros
NONAN
Flag to disable NAN replacement
MIN
Min value for good data
MAX
Max value for good data
See Examples:
Cognizant Programmer: