Thanks for your reply, much appreciated. Maybe you could intruduce a color threshold parameter (in percent), to decide if the neighboring pixel is counted the same or not?
I was just thinking about this and even tested it, but the problem is that it can cause small artifacts that seem to take a little time to fix, but I would still like the result to be perfect and ready to work right away.