A non-transitory computer readable medium including processor executable instructions which, when executed by a processor, control the processor to perform the steps of:
- i) determining, for the disparity d, a corresponding pixel location (q) in a second image corresponding to a pixel location (p) in a reference image;
- ii) determining filter coefficients for filtering a candidate patch, for the disparity d, of said second image that includes said determined corresponding pixel location (q);
- iii) filtering the candidate patch for the disparity d using a filter implemented using the determined filter coefficients to generate a filtered candidate patch for the disparity d;
- iv) computing a matching cost value based on how well the filtered candidate patch for the disparity d matches a reference patch;
- v) storing in memory the generated matching cost value for pixel location p and disparity d;
- repeating steps i), ii), iii), iv) and v) for at least one other disparity d;
- and
- determining a depth for pixel p based on the computed matching cost values corresponding to pixel p.