Patent ID: 7634188

Claim:
A method comprising: receiving a focusing image; shifting the focusing image along a direction parallel to a plane along which the focusing image extends to obtain a shifted focusing image; and calculating a focus metric (FM) of the focusing image from the focusing image having M rows and N columns according to: F ⁢ ⁢ M = ∑ i ⁢ ∑ j ⁢ Gy i , j · Gy i + m ⁢ ⁢ 1 , j + k ⁢ ⁢ 1 + ∑ i ⁢ ∑ j ⁢ Gx i , j · Gx i + m ⁢ ⁢ 2 , j + k ⁢ ⁢ 2 f _ 2 , wherein Gx and Gy represent images that are linear functions of the focusing image, both in signal and noise, and m 1 , m 2 , k 1 and k 2 are shifts of the images selected to make the products of Gx and Gy not contain elements of the form N ij 2 , where N ij is the noise in the ij'th pixel in the image, and f represents a normalizing scalar.