Does anybody else here get the uncanny valley effect when they see a mix of races that you are not used to seeing?
This almost answers its own question - the very fact that we recognise that there is "the uncanny valley effect" indicates that, as Plato suggested, humans have an image in their mind of what things should look like. It is part of our "recognise the pattern" evolutionary advantage.
There's our caveman collecting berries and he sees a bush with berries that are very slightly different... does he try one? It is different after all... it could be poisonous or it could be the best thing since sliced dinosaur... A natural caution enters his mind.
And so it is with anything (including people) when your image of the world is challenged, you become naturally cautious. So it is with people, "I know what my tribe looks like, but this man is strangely different from my tribe... is he friendly, neutral, or will he kill me?" - You're playing a high-stakes game here - erring on the side of caution is natural and wise.
Is this how the racism works?, your empathy is impeded by the alienness of foreign looking people and you irrationally & subconsciously create a contrive reason to discriminate?
It's certainly subconscious and the more different the stranger or berry is, the more cautious you become but whether it is irrational, I'm not sure.
"Racism" also has a lot of baggage with it; whereas with a berry, the berry isn't going to be offended if you don't eat it, but the different stranger may become offended if you spurn them. This offence in the stranger now is perceived by the first person, and there is an enmity that develops between the people - and we have the beginnings of what we now say is "Racism" (or, more broadly, discrimination.) But the same thing happens all over the world, and the more homogeneous the society, the more they discriminate.