Defect detection on metal Object
Hello, As a part of a project, I have to decide if a metal object has acceptable quality or not.
So based on a reference image like this one (acceptable object quality) I need to be able to detect possible defects on other images. These may be some big bumps on the flat surface, or broken rims/edges on the circular parts or ''teeth''. For example, injured rim at the picture below
Or missing parts like this
Since I know what an acceptable state is, my first attemt was to combine edge detection and template matching on specific ROIs and not on the whole image. Though I haven't tested Haussdorf distance as mentioned on another post link text, using opencv's matchTemplate isn't giving so good results.
To sum up, for a 'generic' approach to such a problem, Haussdorf distance is my only hope? If this doesn't work, the next step is to examine every 'feature'(ROI, cicles or teeth) individually with something like shape signature methods, that i have read in bibliography?
Sorry for being so general but don't know how to tackle such a problem
please try again with your image, it's probably much helpful
(there's an "upload image" button, if you edit your question)
(also, what you "want to achieve" , is kinda missing)
hausdorff distance helps to compare contours of different size for similarity. is that your problem, even ?
Well, my goal is having two images, one of reference part and one of to be tested, in one way to determine if they match(no defects detected). My thought so far, was to crop ROIs, extract the edges and use Template matching with no particular success
so we need another image of something defective ?
yes, let's say a misformed(or missing) tooth from the row on the right or not a good rim because of a hit or something
no, it might just need adding an image of a defective part above.
(it is still about understanding your problem)
Can you guarantee that the image will always consist of the same distance and orientation of the metal part? Can you guarantee that there will always be the same lighting? Can you guarantee that the metal will always be the same colour?
If so, you could call
absdiff()
to do a comparison between the master image (the one without flaws) and the current image (the one that might have flaws). Any difference between the two images will be detected and shown in grey. It's super simple, if only you make some guarantees that make life simple for the computer. The more guarantees that you make, the better.Here's some code that calls
absdiff()
:Here's the code in Python:
Thank you very much for your answer. Yes, the distance and orientation of the part is supposed to be the same for each part and so is the lighting as much as possible.The colour of the metal will be the same, but we cannot say the same thing for the surface quality which possible differences between two parts may be due to real defects or lighting conditions.