SPLINE: Replace Image or Spectrum by a Cubic Spline Fit

Form: SPLINE source [R=r1,r2,...] [C=c1,c2...] [W=w1,w2,...]
 $$
[AVG=a] [SUB] [DIV]
source
is the image or spectrum SPLINE works on
R=r1,r2,...
replaces each column in the image 'source' with the best spline through the knot points at rows r1,r2,...
C=c1,c2,...
replaces each row in the image (or uncalibrated spectrum) 'source' with the best spline through the knot points at columns c1,c2,...
W=w1,w2,...
replaces a wavelength calibrated spectrum 'source' by the best-fitting spline with knot points at wavelengths w1,w2,...
AVG=a
averages a pixels or Angstroms around the knots.
SUB
subtracts the best fitting spline(s) from the rows or columns, instead of replacing by the spline.
DIV
divides each row/column by the best fitting spline, instead of replacing by the spline.

SPLINE is used to fit splines to images or spectra. When used with images, it replaces each row (or column) with splines fitted with designated columns (or rows) as knot points. When used with (wavelength calibrated) spectra, it replaces the spectrum with the best fitting spline with designated columns (Angstroms) as knot points.

Examples:

SPLINE 11 W=5000,5500,6000,7000
replaces spectrum 11 with the best-fitting spline. Knot points are at 5000, 5500, 6000, 7000 Angstroms.

SPLINE 11 W=5000,5500,6000,7000 AVG=40
does the same as example 1, but takes the average in 40 Angstrom bins around the designated knot points. The averages are used in the spline fit.

SPLINE 11 W=5000,5500,6000,7000 DIV
does the same ax example 1, but divides the spectrum by the best fitting spline instead of replacing by the spline.

SPLINE 11 C=20,40,100,300,500 AVG=10
this form is used for spectra that are not wavelength calibrated. It averages the spectrum in 10 channel bins around columns 20, 40, ..., and replaces the spectrum by the best fitting spline.

Example using images:

SPLINE 11 C=20,40,100,300,500 AVG=10
this command is the same as example 4 above. When applied to an image, it replaces each row in the image by the spline which best fits that row. The knot points are taken to be averages of the image intensity in 10 channel bins around columns 20, 40,...