We provide a theoretical study of ambiguities arising in two-image photometric stereo. Disambiguation is formulated as a binary labeling problem, using integrability and a nonstationary Ising model. Resolution is achieved efficiently by resorting to the graph cut algorithm. An application to three-image photometric stereo with shadows is presented.