A method is provided for computing a composite image representing a
focused image of an object in an application of machine vision in an
optical inspection system. An image tessellated into focus regions is
evaluated by region for fine feature sharpness. A sharpness image is
computed for each focused region using a fine feature sharpness
measurement. A focused composite image is computed by combining as a
weighted average, the images at several focus settings, using the
sharpness image at each focus setting as the weight. The focused
composite image can be further analyzed, inspected, or otherwise
processed.