EqapFilter (version 1.1, 14.10.2011)

The EqapFilter is a part of EqapPackage and is a functional component designed for smoothing of data arrays (double and integer types), with selectable smoothing algorithm type and editable smoothing parameters.


1. Appearance

The EqapFilter (Fig. 1) contains the controls for smoothing algorithm selection and smoothing settings.

Fig. 1. EqapFilter component

Combobox (a) has different smoothing algorithm types (9 in total: based on previous value, cubic spline approximation, Fourier series harmonics, Gaussian smoothing, 3-points linear smoothing, 5-points linear smoothing, moving average smoothing, moving median smoothing, 7-points non-linear smoothing). Fields (b) and (c) are the parameters for the selected smoothing algorithm. The field (c) is an "array expansion" parameter, which is used to prepare a source array for smoothing. The higher value of (c) results in more points to be inserted between any two neighbour points in the source array and thus lesser smoothing, whatever smoothing algorithm is used. The field (b) is the parameter which is ultimately dependent on the smoothing algorithm. In case of non-linear/linear smoothing or cubic spline approximation, the parameter (b) is used to specify how many times the source array should be splitted on subarrays in order to smooth each subarray prior to the final combining into the filtered array. Here, the higher this parameter, the stronger effect of the smoothing. In case of Fourier smoothing, the parameter (b) is a number of series harmonics used to reproduce the source array. Increasing the parameter results in decrease of smoothing effect while the filtered array resembles more the source array. In case of moving average or moving median smoothing, the parameter (b) is a number of points in the moving window. The higher this value, the stronger effect of the smoothing. Note that by default, the moving goes from leftmost point. In case of smoothing by previous value, the parameter (b) is a number of points used for previous value calculation. Again, the higher this value, the stronger effect of the smoothing, while filtered array is less resembled to the source array. In case of Gaussian smoothing, the parameter (b) is a frequency coefficient (increase of this value makes smoothing stronger).

In case of linear/non-linear smoothing or moving average/median smoothing, the checkbox (d) indicates whether cycled filtering should be used or not. If true, then smoothing will be performed cyclically with number of iterations set as parameter (b). This flag is disabled for all other algorithms.


2. Properties and events

The EqapFilter inherits properties and events of TGroupBox, and has own properties and events:

Properties

CycledFiltering: boolean - indicates whether cycled filtering is enabled or not (d). The default value is "false".

FirstParameter: integer - value of parameter (b). The default value is "7".

SecondParameter: integer - value of parameter (c). The default value is "1".

Events

OnChange: TNotifyEvent - event arises when the smoothing algorithm type or its parameters are changed.


3. Procedures and functions

The following public-declared procedures and functions are registered for the EqapFilter component:

procedure Filter(SourceArray: TDoubleArray; Discrete: double; var FilteredArray: TDoubleArray) - smoothing of SourceArray (as array of double) with specified discrete. If Discrete is "1" then whole SourceArray is used for smoothing. If Discrete is 2, the array for smoothing is each 2nd point of SourceArray, and so on. The variable FilteredArray is the destination (filtered) array.

procedure Filter(SourceArray: TIntegerArray; Discrete: double; var FilteredArray: TDoubleArray) - smoothing of SourceArray (as array of integer) with specified discrete. The variable FilteredArray is the destination (filtered) array.


4. The example of using

The program code with an example of use of EqapFilter is downloadable here. This example illustrates how you can smooth the numerical values when OnChange event of EqapFilter is occurred.

Figure 2 illustrates the form with Chart1 and EqapFilter1 components. Chart1 has two series created in Design-time. In the program code you have to declare global variables Values and Filtered (both are TDoubleArray); to do this you should also include EqapCommon unit, the part of EqapPackage. On the form creation (OnCreate event) the Values is filled with numerical values; these values are used to fill the first series on Chart1. The OnChange event of EqapFilter1 is assigned to make a smoothing the values of first series (this will occur on any change in controls of EqapFilter) and to transfer the smoothed values into the second series of Chart1.

Fig. 2. The example of using EqapFilter


All the software products are free for use. Any commercial using is not permitted without author's permission (o.lookin@iip.uran.ru).

 

Hosted by uCoz