Standard Forth versus Python: a case study
John Doty
jpd at whispertel.LoseTheH.net
Wed Oct 11 17:08:52 EDT 2006
Paul Rubin wrote:
> John Doty <jpd at whispertel.LoseTheH.net> writes:
>> I have a bunch of image files in FITS format. For each raster row in
>> each file, I need to determine the median pixel value and subtract it
>> from all of the pixels in that row, and then write out the results as
>> new FITS files.
>
> I dunno what FITS is, but if you have a list of pixel values, that
> calculation sounds like two lines:
>
> median = sorted(pixels)[len(pixels)//2]
> new_pixels = [p-median for p in pixels]
Yes. The efficient exact algorithms for this problem use *partial*
sorts. The Forth one from the FSL is of this class (although I know of
two better ones for big arrays). But it's tough to beat the efficiency
of the approximate histogram-based method the Python stats module
implements.
--
John Doty, Noqsi Aerospace, Ltd.
--
Specialization is for robots.
More information about the Python-list
mailing list