Code:
Increase the various black selected zone by half a pixel and all your problems will disappear.
In the first step I (the user) decide which colors should appear in the result.
To these colors all pixels are mapped each.
With this new colored picture the application can decide what regions are the same color.
So the regions are detected _after_ color reducing.
Any more thoughts?