I know that the easiest way to identify the gender of a dog is to look between the hind legs, but that doesn't always clarify the gender of a dog, and sometimes (like on the below picture) it's not immediately obvious to the untrained eye. I can't tell whether that black spot between the hind legs is just dirt or is indeed part of the dog's genitals.
And this dog is sitting in a position where you can actually see between the hind legs, but that's not always the case. Sometimes the dog is walking towards you or away from you and you can't look between the legs at all.
What are the most reliable ways to identify a dog's gender?