How to check if a lens is clean by taking some images
<p>I have several lenses that I need to make sure they are clean.</p>
<p>I need to write  software to do this as I want to have a quick and subjective free way of doing this.</p>
<p>I know that when the lens is not clean, there is always a very faint pattern on the lens, so I am wondering how I can detect this faint pattern.</p>
<p>What I am thinking of doing is to take several images by lens when mounted on a camera and compare the images, but I am not sure how I can process the images to find if lens is clean.</p>
<p>I tried to take an image from a say white box and look for pattern, but it was not successful, as the pattern is very faint and when I replace the lens, the change in image is bigger than the pattern to look for, so I am not getting correct result.</p>
<p>Any idea of what kind of image processing I can use to find if a lens is clean?</p>
<p>I want to write the software in c++ using openCV.</p>
<h1>Edit 1</h1>
<p>The application is to test a camera with lens mounted on it. We are building camera modules with lens on them and we noted that sometimes there are some derbies on lens (or sensor) and we can not detect them easily.
so the workflow is:
We put a lens over our sensor and then we need to check if there is any derbies or dust on sensor or lens before we can ship it. We can test for dust before or after focusing, which ever is simpler (preferably before focusing as cleaning means we need to remove lens and clean it and put it back which requires a new focusing.)
We are doing it manually now by looking at the image generated by sensor on a computer and move the camera against a white paper and look for static patterns. Now we are looking for a way to do this using software.</p>