The function AddParticlePixel adds the pixel at position [px,py] to particles of class ClassIdx. The pixel coordinates are zero-based (valid range 0..SizeX-1 and 0..SizeY-1), the class number is 1-based (valid range 1..NClasses).
The specified pixel is added to the particle list. Depending on the position of the pixel there are three kinds of outcomes:
- the specified pixel has no neighbors1) of the specified particle class: the pixel is regarded as a new (single-pixel) particle
- the specified pixel has one or more common edges with an existing particle of class ClassIdx: the pixel is added to the neighboring particle (the particle grows by one pixel)
- the pixel has common edges with more than one particle of the specified class: the neighboring particles and the pixel are united to a new joint particle
The function returns the following error codes:
>0 ... everything is OK, the returned number is the particle index of the particle the pixel is assigned to
-1 ... invalid ClassIdx
-2 ... invalid px and/or py
|