CreateMixedSpec3DArray

Declaration: CreateMixedSpec3DArray (Spec1, Spec2: TDoubleArray; Noise: double; NegNoiseMode: integer; var Target: TDouble3DArray): integer;
The function CreateMixedSpec3DArray fills the three dimensional array Target with a linear mixture of the two spectra Spec1 and Spec2. The target matrix is automatically resized to have 101 x 101 spatial resolution (x and y axes). The number of layers is set to the length of the spectral vectors.

The mixture of the two spectra occurs along the x axis, along the y axis the spectra contain an increasing amount of noise. Thus the spectrum at the position [0,0] contains, as an example, 100% of spectrum Spec1, 0% of spectrum Spec2 and no noise. The spectrum at position [71,11] consists of 70% of Spec1, 30% of Spec2 and 10% noise.

The added noise is normally distributed with a zero mean and a standard deviation which is proportional to the Noise parameter and the y coordinate (0..100%). Further, the parameter NegNoiseMode controls the handling of possible negative intensities:

NegNoiseMode Explanation
0 add noise without restriction
1 cut noise if the intensity becomes negative (the entire spectrum will be cut at the zero line)
2 delimit negative noise by logarithmic compression (negative values of the spectrum will be compressed to ln(abs(intensity))).

The function returns the following error codes:

 0 ... everything is OK
-1 ... Spec1 and Spec2 are of different length
-2 ... Noise must not be negative
-3 ... invalid NegNoiseMode


Last Update: 2017-Jun-20