KFilterSpectraEdgeSpecial

Declaration: KFilterSpectraEdgeSpecial(FirstLayer, LastLayer, llx, lly, urx, ury, TSlot, ExtPolOrder: integer; FilterKernel: TDoubleArray; FeedBack: boolean): integer;
Kernel based filters as implemented by the function KFilterSpectra exhibit the drawback of creating edge effects at the end of the filtering range (due to a decreasing number of data points when the moving kernel approaches the edge). The function KFilterSpectraEdgeSpecial tries to minimize this effect by extrapolating the data at the edges using a polynomial of order ExtPolOrder (valid range: 1 to 4).

The spectral filter is applied to all pixels of a rectangular region specified by the parameters llx, lly, urx and ury (lower left to upper right corner in pixel coordinates). The range of spectral data points to be filtered is controlled by the parameters FirstLayer and LastLayer. The parameter TSlot specifies the time slot to be processed.

The filter function is controlled by the coefficients stored in the array parameter FilterKernel. The filter coefficients for a weighted sinc lowpass/highpass filter can be calculated by means of the functions CalcSincLPKernel and CalcSincHPKernel.

If the parameter Feedback is TRUE a visual feedback of the progress of the filtering is provided. Please note that unless the script progress bar is already visible you have to make it visible before calling KFilterSpectraEdgeSpecial, otherwise the feedback will not be displayed. You can activate the script progress bar by calling the function ScriptBar(0).

The function returns the following error codes:

 0 ... everything is OK
-1 ... FirstLayer or LastLayer out of range
-2 ... llx..ury are out of range
-3 ... TSlot out of range
-4 ... invalid PolyOrder (1..4 are valid)
-5 ... FilterKernel is larger than the spectral range
-6 ... process aborted by user

Hint: Although this type of filter can be used with any number of filter kernel coefficients, it is strongly recommended to use only filter kernels with an odd number of coefficients in order to avoid minute shifts of the filtered spectral signal.