• crypsis;
  • camouflage;
  • microhabitat;
  • habitat choice

We present a theoretical approach to the optimization of crypsis in heterogeneous habitats. Our model habitat consists of two different microhabitats, and the optimal combination of crypsis in the microhabitats is supposed to maximize the probability of escaping detection by a predator. The probability of escaping detection for a prey is a function of: (i)degree of crypsis, (ii) probability of occurrence in the microhabitats and (iii) probability of encountering a predator in the microhabitats. Because crypsis is background-specific there is a trade-off between crypsis in two visually different microhabitats. Depending on the nature of the trade-off, the optimal coloration is either a compromise between the requirements of the differing microhabitats or entirely adapted to only one of them. An increased risk of predation in one of the microhabitats favours increased crypsis in that microhabitat. Because the trade-off constrains possible optimal solutions, it is not possible to predict the optimal coloration only from factors (i)-(iii). However, habitat choice may fundamentally change the situation. If minimizing predation risk does not incur any costs, the prey should exclusively prefer the microhabitat where it has a lower probability of encountering a predator and better crypsis. The implications of these results for variation in cryptic coloration and polymorphism are discussed.