1. A method to generate a focus signal from a plurality of edge widths to indicate a degree of image sharpness in an image, each edge width belonging to one among a plurality of edges in the image, comprising: determining that a gradient profile across an edge in the image has a first value for a first parameter measured at a first gradient level and a second value for a second parameter measured at a second gradient level, the first and second gradient levels being different gradient values defined as a first fraction and a second fraction, respectively, of a peak gradient value of the edge, both the first and second parameters being determined based on the gradient profile to both sides of a peak of the gradient profile; determining whether the first value meets a predetermined criterion that depends on the second value; and, rejecting or attenuating a contribution of an edge width of the edge in generating the focus signal where the edge does not meet the predetermined criterion.