don’t use edge detection. a blurry smudge has no edges.
- take a picture of a reference background (flat white or color) with clean optics and exposure set such that it’s not overexposed. your picture’s white background is overexposed and the smudge can’t be seen there.
- compare (pixel-wise) against picture with smudged optics.