1. A method of choosing an optimal candidate value to be used for matching a block from a first image ( 10 ) with an area from a second image ( 11 ), the method comprising: (a) making a set of candidate values for determining an area to be matched from the second image ( 11 ), (b) for each candidate value from the set, determining an area to be matched from the second image ( 11 ), based on said candidate value, matching the block from the first image ( 10 ) with this area and calculating a matching error, and (c) choosing the optimal candidate value from the set based on the calculated matching errors characterized in that the block is formed by pixels, a selection is made of pixels of the block from the first image which are visible in the area to be matched from the second image ( 11 ), and the calculation of a matching error is based on said selection.