Background-matching camouflage is a well-established strategy to reduce detection, but implementing this on heterogeneous backgrounds is challenging. For prey with fixed color patterns, solutions include specializing on a particular visual microhabitat, or adopting a compromise or generalist appearance, matching multiple backgrounds less well. Existing studies suggest both approaches can succeed, but most consider relatively simple scenarios, where artificial prey appear against two backgrounds differing in a single visual characteristic. Here, we used computer-based search tasks with human participants to test the relative benefits of specializing and generalizing for complex targets, displayed on either two or four types of naturalistic backgrounds. Across two background types, specialization was beneficial on average. However, the success of this strategy varied with search duration, such that generalist targets could outperform specialists over short search durations due to the presence of poorly matched specialists. Over longer searches, the remaining well-matched specialists had greater success than generalists, leading to an overall benefit of specialization at longer search durations. Against four different backgrounds, the initial cost to specialization was greater, so specialists and generalists ultimately experienced similar survival. Generalists performed better when their patterning was a compromise between backgrounds that were more similar to each other than when backgrounds were more different, with similarity in luminance more relevant than pattern differences. Time dependence in the relative success of these strategies suggests that predator search behavior may affect optimal camouflage in real-world situations.