# SwisTrack/Components/BlobDetectionTwoColors

## DescriptionEdit

This component detects markers consisting of two blobs (of different color) on a color image. The particle position is the point between the two blob centers, while the particle orientation is pointing towards color 1.

For both colors, the algorithm first selects all pixels falling in to the following cube in RGB color space:

${\displaystyle |r-c_{r}|
${\displaystyle |g-c_{g}|
${\displaystyle |b-c_{b}|

where ${\displaystyle (c_{r},c_{g},c_{b})}$  denotes the reference color, and ${\displaystyle t_{r}}$ , ${\displaystyle t_{g}}$  and ${\displaystyle t_{b}}$  the thresholds for the respective channels. In a second step, the algorithm applies blob detection on the thresholded image. Both the color subtracted image and the thresholded image can be visualized.

Once the blobs of both colors have been extracted, close lying blobs of different color are combined to particles.

## InputEdit

File:SwisTrack TwoColorBlobs.png

A color image with markers consisting of two blobs of different color. Both colors need to be sufficiently different from any color appearing in the background. (A background subtraction component or a mask component may be useful to get rid of unwanted areas.)

## OutputEdit

File:SwisTrack TwoColorParticles.png

Particles, with the center being between the two blobs, and the orientation pointing towards the blob of color 1.

## ParametersEdit

### Max. particlesEdit

Maximum number of particles to detect. Note that the algorithm first detects this many red and green blobs, and then matches them. Hence, if there are stray red or green areas in your image (not part of a marker), you should choose a number of particles that is slightly higher than the number of markers you deploy.

### Max. distanceEdit

The maximum distance between the center of the red blob and the center of the green blob. Blobs that are farther away from each other are considered not being part of the same marker.

This distance is also used to eliminate stray blobs in the neighborhood of red or green blobs. More precisely, within any disk of this diameter (not radius), only the biggest red (resp. green) blob is detected.

### Output ParametersEdit

The parameters of the output blobs can be choosen as the parameters of the first colored blob, the second one, or the combination of those (i.e. area added, centers averaged etc.)

### Color 1 and 2Edit

The reference color (${\displaystyle c_{r},c_{g},c_{b}}$ , see description above).

### Threshold R, G and B (for color 1 and 2)Edit

The thresholds ${\displaystyle t_{r}}$ , ${\displaystyle t_{g}}$  and ${\displaystyle t_{b}}$  (see description above).

### Selection by area (for color 1 and 2)Edit

Check this to base blob selection on the blob area.

### Min. blob size (for color 1 and 2)Edit

Minimum area in pixels of a blob to select.

### Max. blob size (for color 1 and 2)Edit

Maximum area in pixels of a blob to select.

### Selection by compactness (for color 1 and 2)Edit

Check this to base blobs section on the compactness of the blob.

### Min. compactness (for color 1 and 2)Edit

Minimum compactness (0..1) of a blob to select.

### Max. compactness (for color 1 and 2)Edit

Maximum compactness (0..1) of a blob to select.