1. A method of generating a depth map ( 122 ) comprising depth values representing distances to a viewer, for respective pixels of an image ( 100 ), the method comprising: computing a cost value for a first one of the pixels ( 108 ) of the image by combining differences between values of pixels which are disposed on a path ( 112 ) from the first one of the pixels ( 108 ) to a second one of the pixels ( 110 ) which belongs to a predetermined subset of the pixels of the image; and assigning a first one of the depth values corresponding to the first one of the pixels ( 108 ) on basis of the cost value.