Declaration: TParticles.AnalyseAndAppend (ImgData: TDouble2DArray; PixMask: TBool2DArray; Thresh1, Thresh2: double; MinSize: integer; var ClassIdx: integer; ClassName, ClassID: string): integer;
The function AnalyseAndAppend analyzes a given layer of an image and segments it in order to detect particles. The layer to be analyzed is contained in the array ImgData. You can exclude specific pixels from the analysis by setting the corresponding cells in the array PixMask to TRUE. In order to prevent any masking you can set PixMask to NIL.

The parameters Thresh1 and Thresh2 control the thresholds which are used to detect particles. All pixels having an intensity greater equal than Thresh1 and less equal than Thresh2 are considered to be part of a particles. The parameter MinSize determines the minimum required size of a contiguous region to be recognized as a particle (in pixels).

The function AnalyseAndAppend assigns the found particles to a new class number which is returned in the variable parameter ClassIdx. The parameters ClassName and ClassID contain the name of the new particle class and its unique class identifier.

The function returns the following error codes:

≥0 ... everything is OK, the function returns the number of found particles
-1 .... the size of ImgData does not match the existing particle matrix
-2 .... the size of PixMask does not match the size of ImgData
-3 .... Thresh1 must not be greater than Thresh2

Hint 1: In order to access the particles currently loaded in the particle editor you can use the pre-declared global variable PEData.

Hint 2: If you want to use only a single threshold, set the other threshold to uc_MaxDouble or -uc_MaxDouble. Thus you can create an interval which is either [Thresh1..uc_MaxDouble] (for intensities above Thresh1) or [-uc_maxDouble..Thresh2] (for intensities below Thresh2).