A system for computing a depth map comprising depth values representing distances to a viewer for respective pixels of an image. The system comprises an optimization unit (902) for determining a minimal depth related cost value of a current pixel, among a plurality of candidate cost values, wherein at least one of the candidate cost values is based on a depth related cost value of at least one pixel in a local neighborhood of the current pixel and on a difference between a color attribute of the at least one pixel in the local neighborhood and a corresponding color attribute of the current pixel, and at least one of the candidate cost values is based on a depth related cost value relating to at least one pixel outside the local neighborhood and on a difference between a color attribute of the at least one pixel outside the local neighborhood and a corresponding color attribute of the current pixel.