A method for determining a phase for a captured image, the method comprising forming a demodulated image defining wrapped phase values and modulation values, each being associated with at least one region in the captured image; identifying a position of an edge in the captured image dependent upon the modulation values; determining a position of substantial change in the wrapped phase values in the captured image dependent upon the identified position of the edge, and determining at least one unwrapped phase value based on the position of the edge and the position of the substantial change in the wrapped phase values by shifting a position of the substantial change in the wrapped phase values to the identified position of the edge, so that said unwrapped phase value is adjusted by at least one cycle.