How to Remove a Glare / Clipped Brightness from an Image?
Let's assume glare portions are the only saturated areas in the image. 
Detection can be performed by thresholding the intensity (code in Mathematica):

saturated = Binarize[ColorConvert[img, "Grayscale"], .9]




Then we need only to replace the portions of the image around the saturation mask (enlarging the mask is done by the morphological function Dilation). Inpainting using texture synthesis (using the function Inpaint) seems to work well in this example, though I can not test it as input to your defect-detection algorithm:

Inpaint[img, Dilation[saturated, DiskMatrix[20]]]