CalibrateFromData

Declaration: TMetaData.CalibrateFromData (Dim: TDims; FirstIx, LastIx: integer; POrderFw, POrderBw: integer; Data: TDoubleArray): integer;
Calculates the calibration coefficients for a particular axis specified by the parameter Dim. The calibration parameters (offset, polynomial coefficients, shift and scaling factor) are calculated using the calibration vector Data which contains the real-world values for each index of the specified axis. The calibration is calculated in the range between FirstIx and LastIx (valid range: 1..CubeSize[Dim]) which are the (pixel) indices along the specified axis.

The parameters POrderFw and POrderBw determine the order of the polynomial to be used for the calibration (valid range: 1..MAXCALIBPOLYORDER). Please note that the size of the Data vector has to be greater than MAXCALIBPOLYORDER in order to be able to calculate a polynomial calibration. If the Data vector is too small the calibration defaults to a linear regression. Further, the backward polynomial should always be of high order unless you know a lower order is sufficient, i.e. if POrderFw is greater than 1 POrderBw should be set to MAXCALIBPOLYORDER, if POrderFw is 1 then POrderBw should also be set to 1.

The function CalibrateFromData allows you to establish piecewise calibration by calling it several times using different ranges (as specified by FirstIx and LastIx).

The function returns the following error codes:

 0 ... everything is OK
-1 ... invalid POrderFw/Bw
-2 ... invalid FirstIx, LastIx - must be in range 1 ≤ (FirstIx,LastIx) ≤ length(Data)
-3 ... FirstIx must not be greater than or equal to LastIx
-4 ... LastIx is greater than the specfied size of the dimension

Hint 1: Please note that the Data array has to have the same length as the calibration vector of the corresponding axis. You should use ResizeContainers to ensure that the sizes match.

Hint 2: ATTENTION: The function CalibrateFromData does not adjust the table of calibration pieces. Thus you have to call RecalcCalibPieces after the last call of CalibrateFromData. If you fail to recalculate the calibration pieces, parts of ImageLab might behave unpredictably.

Hint 3: In order to directly access the metadata of the currently loaded dataset you can use the pre-declared global variable MData.


Last Update: 2018-Apr-11