The function RemoveParticlePixel removes the pixel at position [px,py] from 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 removed from a particle. Depending on the position of the pixel there are three kinds of outcomes:
- the specified pixel has no neighbors1) belonging to the specified particle class: the pixel is regarded to be a single-pixel particle, the particle is therefore removed
- the specified pixel has one common edge with an existing particle of class ClassIdx: the pixel is removed from the particle (the particle shrinks by one pixel)
- the pixel has two or more common edges: the pixel is removed and the remaining pixels are split in separate particles if required
The function returns the following error codes:
>0 ... everything is OK, the returned number is the particle index of the particle the pixel has been removed from
0 ... the particle has been removed because it was a single-pixel particle
-1 ... invalid ClassIdx
-2 ... invalid px and/or py
-3 ... the pixel is not part of a particle, nothing has been changed
|