Animals use the sense of vision to scan their environment, respond to threats, and locate food sources. The neural computations underlying the selection of a particular behavior, such as escape or approach, require flexibility to balance potential costs and benefits for survival. For example, avoiding novel visual objects reduces predation risk but negatively affects foraging success. Zebrafish larvae approach small, moving objects ("prey") and avoid large, looming objects ("predators"). We found that this binary classification of objects by size is strongly influenced by feeding state. Hunger shifts behavioral decisions from avoidance to approach and recruits additional prey-responsive neurons in the tectum, the main visual processing center. Both behavior and tectal function are modulated by signals from the hypothalamic-pituitary-interrenal axis and the serotonergic system. Our study has revealed a neuroendocrine mechanism that modulates the perception of food and the willingness to take risks in foraging decisions.