How do I exclude the background from the defects?

30 Views Asked by At

Currently I am trying to use image processing to detect some wood defects like holes or cracks. After using some thresholding methods I get decent results where cracks are visible enough. I want to draw a bounding box around each of the defects and also crop them out. I try getting the defects by using cv2.findContours() function, however the problem is that a lot of the defects are on the edge of the plank and so they touch with the background. So, when I try to use cv2.findContours() function it takes in the whole big contour and so draws the bounding box around the whole image. How do I exclude that? Image after thresholding

One of my approaches were to find the boundaries of the plank and then loop over the contours and leave only points that are inside the boundaries of the plank, however that doesn't seem to work.

0

There are 0 best solutions below