View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum

Bug Report: Median

Mark Richardson wrote on Aug 04, 2010

I have been trying to rewrite a 2D-fits file with every pixel equal to the median of the image. The image has dimensions 59X61. I attempt this by:

> median(input="2dfile.fits", output="result.fits", xwindow=59, ywindow=61, boundary="wrap")

The resultant image is not uniformly set to the median of the original. Instead I get horizontal bands of two different values (one of which IS the median of the original, the other is obviously not).

My first instinct was that this was some result of the wrapping: that vertical wrapping wasn't always being done correctly. However I have had one case where the central pixel of the image (ie [30,31]) is set to the other (wrong) value. Since the central value requires no wrapping, the bug seems to lie elsewhere.

The unfortunate thing is that the value that is more abundant is not always the actual median.

Sometimes the difference in the second value from the actual median is quite small, whereas other times it is quite large (relatively).

Does anyone have any recommendations? Even knowing an efficient technique to find the median would suffice ('imstat' gives an approximation: I need the real deal - a non-trivial problem to do quickly).

Since 'imstat' does give me a rough idea of the median, I can start there and find the true median in roughly 10 seconds. This pales in comparison with how quick 'median' runs.

Cheers,
-Mark

Last post on Aug 04, 2010