I noticed that the dogs living among people understand well the situations and emotions of those involved.
They do not have such a tool as the articulte speech, that is why they seem to be stupid. But they compensate by looking at one's face and posture, and get the picture. Dogs living among people are about as clever as people themsleves.
So if one is irritated by the dog presence, it feels it and expresses its frustration. It sees that this man does not accept its presence and is angry at the owner for the dog being there.
It indeed should be humiliating for the understanding dog, that the very right of her existence is denied.
When I have to be in the vicinity of a dog, I try to look friendly at it. Not that I approve of the big dogs running loose around, but I, at least, show the dog that it is not its fault, that it, personally, is not to blame that it was brought into this environment.
I noticed that the dogs are not aggressive, when I show affable attitude. But in the past, when I had been disapproving, they sometimes got mad at me.