http://qs1969.pair.com?node_id=11120523

Xilman has asked for the wisdom of the Perl Monks concerning the following question:

Greetings Fellow Monks.

The background (pun intended) to my request is that I have some astronomical images in FITS format and I would like to remove a spatially varying background as the first stage of image enhancement. It seems clear to me that PDL is the way to go, though I am quite prepared to be convinced otherwise

CPAN contains some PDL modules which perform least squares fitting to one-dimensional data. I realise that surface fitting can be performed by re-arranging the data so that it appears to be linear (by storing it by rows or by columns) and that the independent variables can be munged to suit. However, that would appear to be inelegant and potentially costly for surface fitting to large image patches.

Surely someone must have encountered this situation before and has written code to deal with it?

I undoubtedly can write my own code but I am lazy. If I do need to write a function I will endeavour to make it publicly available.