Diurnal biting flies are strongly attracted to blue objects. This behaviour is widely exploited for fly control, but its functional significance is debated. It is hypothesised that: blue objects resemble animal hosts; blue surfaces resemble shaded resting places; and blue attraction is a by-product of attraction to polarised light. We computed the fly photoreceptor signals elicited by a large sample of leaf and animal integument reflectance spectra, viewed under open/cloudy illumination and under woodland shade. We then trained artificial neural networks (ANNs) to distinguish animals from leaf backgrounds, and shaded from unshaded surfaces, in order to find the optimal means of doing so based upon the sensory information available to a fly. After training, we challenged ANNs to classify blue objects used in fly control. Trained ANNs could make both discriminations with high accuracy. They discriminated animals from leaves based upon blue-green photoreceptor opponency, and commonly misclassified blue objects as animals. Meanwhile, they discriminated shaded from unshaded stimuli using achromatic cues and never misclassified blue objects as shaded. We conclude that blue-green opponency is the most effective means of discriminating animals from leaf backgrounds using a fly's sensory information and that blue objects resemble animal hosts through such mechanisms.