Declaration: ApplyRFModel (ModelFName, Pwd: string; MaskIx: integer; var ClassifiedImg: TDouble3DArray; Feedback: boolean): integer;
The function ApplyRFModel applies a random forest model which has been trained and stored by the RF training tool to the currently loaded data cube. The parameter ModelFName specifies the full path of the stored model, the parameter Pwd defines the password to decrypt1 the classifier. The results of the classification are stored in the 3D array ClassifiedImg which is automatically adjusted to match the size of data cube and the number of classes created by the random forest classifier. The parameter MaskIx specifies the index of the mask which is to be used during the classification.

The Feedback parameter controls whether a visual feedback is provided during the classification. Please note that unless the script progress bar is already visible you have to make it visible before calling ApplyRFModel, 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 ... invalid filename of random forest model
-2 ... the spectral descriptors of the model do not match the available spectral types
-3 ... invalid MaskIx
-4 ... (warning only) the spectral range required to correcly calculate the spectral descriptors is not sufficient
-5 ... minimum size of Data (2x2) is not given
-8 ... metadata and cube are not compatible

1 Binary classifier files are encrypted, text classifier files are not. When loading a text classifier you can ignore the Pwd parameter.