Vector.PixelDownSample Method

procedure PixelDownSample(Width: Integer; Y: TVec; X: TVec; NX: TVec; Equidistant: TEquidistantSample);

Downsample the vectors Y and (optionaly) X starting at position Index and for Len samples.

#NameTypeDescription
1WidthInteger
2YTVecsource TVec
3XTVecsource TVec
4NXTVecsource TVec
5EquidistantTEquidistantSample

Result: stored in self (calling object)

Remarks:

Store result for Y in the calling vector and the result for X in the NX vector. If X axis is equidistant, you can omit X and NX parameters. Set Width to the number of target pixels. An exception is reaised, if any of the vectors is complex or if array borders are overrun/underrun.

Indexed: procedure PixelDownSample(Width: Integer; Y: TVec; Index: Integer; Len: Integer; X: TVec; NX: TVec; Equidistant: TEquidistantSample);

Downsamples (reduces) the number of vector elements.

#NameTypeDescription
1WidthInteger
2YTVecsource TVec
3IndexIntegerstart index
4LenIntegerelement count
5XTVecsource TVec
6NXTVecsource TVec
7EquidistantTEquidistantSample

Result: stored in self (calling object)

Remarks:

This method speeds up drawing of huge amounts of data (>> 2000 samples). You should pass your data to the PixelDownSample method before you pass the values to the Charting routine. The X and Y vectors contain the values for X and Y axis, that you would normally pass to the charting procedure. The downsampled Y is stored in the calling vector and downsampled X is stored in the NX vector. If your data is equidistant on X axis, you can omit the X vector or, if you are in doubt, allow the routine to downsample the X vector also. If your data is not equidistant on the X axis, you must indicate that by specifying the Equidistant parameter as False and provide X and NX vectors, where X containes the step on the X axis and NX will contain the downsampled result for X axis.

With Width parameter you specify the width of the charting region in pixels. (Example: Chart.Width). The routine will reduce the number of samples in vectors Y and X in such a way that there will be no visual difference between the original and downsampled data.

That however will no longer be true, if you will zoom-in on the data. The performance gain can be as big as 100x depending on the charting tool that you use. You can easily draw data series from vectors with length of over 1.000.000 samples in real time.

Examples
var a,b: Vector;
begin
    a.SetIt(False,[0,0,0,1,2,3,1,2,3]);
    b.PixelDownSample(3,a);
end;
See Also: Vector.DownSample