Summary
Downsamples (reduces) the number of vector elements.
Class
TVec
Declaration
Procedure PixelDownSample(Width: integer; Y: TVec; X: TVec = nil; NX: TVec = nil; Equidistant: boolean = True);
Description
Downsample the vectors Y and (optionaly) X starting at position Index and for Len samples. 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.
Declaration
Procedure PixelDownSample(Width: integer; Y: TVec; Index, Len: integer; X: TVec = nil; NX: TVec = nil; Equidistant: boolean = True);
Description
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.
Example 1
var a,b: TVec;
begin
CreateIt(a,b);
try
a.SetIt(False,[0,0,0,1,2,3,1,2,3]);
b.PixelDownSample(3,a);
finally
FreeIt(a,b);
end;
end;
| Copyright 2008 Dew Research |
http://www.dewresearch.com