1. A method for operating a processor-controlled machine to determine, for a given input color, an optimal direction in color space that includes the given input color and that satisfies a set of constraints; the machine including an output device, a processor, and a memory device for storing data; the data stored in the memory device including instruction data the processor executes to operate the machine; the processor being connected to the memory device for accessing and executing the instruction data stored therein; the method comprising: obtaining an input color defined in coordinates of a multi-dimensional color space; specifying an objective function that balances measurements of a human perceptual response and a digital image capture device response to a color change; the color change being defined by a color space direction away from the input color; the objective function simultaneously minimizing the human perceptual response measurement and maximizing the digital image capture device response measurement to the color change; determining an output color defined as an optimal color space direction in the multi-dimensional color space away from the input color using the objective function; encoding data as a pattern comprising one or more picture elements in an output color and one or more picture elements in the input color; and outputting, on the output device, the encoded data such that the pattern is minimally visually perceptible to humans while, at the same time is maximally detectable by the digital image capture device.