MATLAB: Hello, I am having problem in the detection of holes on the bottom surface of PET bottles. i have tried edge detection and counting of circular shaped objects, but i am not getting correct answers. i will appreciate if you kindly help me. pics attc

color detectionImage Processing Toolbox

Best Answer

I'd use a profilometer instead of a camera if you can so you can get range data. For example a kinect camera. Or at least a stereo pair so that you can detect big anomalies in the range. If you use visible light cameras you'd need to correct your horrible lighting situation. You can get rid of the small specular reflections (glints) by using crossed polarizers. This is a very common technique where you have a polarizing sheet in front of your lamp, and another rotatable one in front of the lens. Rotate the lens polarizer until the glints disappear. It could also be good to have a baffle around the top of the bottle end so that you can separate the lighting into two zones, one for the end, and one for the main part of the bottle. The overhead lighting should be flood illumination to get rid of any shadows that could be caused by little variances in the bottle shape (logos, etc.). The light below the baffle board should be coming in from all sides, like a circline circular fluorescent light or at least 4 or more LED light bars arranged around the perimeter. This light should be very bright so that holes in the end will be lighter. Splitting the light up this way will make the true holes easier to see and find.
Alternatively I think a better test for holes would be an air pressure test. Blow air into a sealed bottle. Low pressure indicates a leak. It has the advantage that it will detect leaks anywhere not just on the end. I think air pressure testers are fairly available in industry.
If you want to visualize the airflow you can use Schlieren Flow Imaging which lets you see invisible things like air currents. Also see this link.
Anyway, the main point is your images are too complicated to find the holes, especially the really small ones. Improvements in your image capture situation will pay off a great deal. It's always better to start with a good image than to try to fix up a bad image, which may not even be possible, or only partially possible but lead to spurious/incorrect results.