I could not manage to use floodfill function on my image that has several unconnected components. I would like all the holes to be filled with White. To do so, I could have used closing operation . However, since it merged close conductors , I would rather floodfill operation than morphological ones to retain the whole form of the image. https://i.stack.imgur.com/fYuvT.jpg
I am aware that since there are several components , I need to use mask and update it accordingly to get passed the next components. I tried to implement the explanations given below and documentation. OpenCV floodfill with mask
holes = blurred_defective.copy()
holes1 = blurred_golden.copy()
height, width = holes.shape[:2]
seed = (width/2,height/2)
mask = np.zeros((height+2, width+2), np.uint8)
fillvalue = 255
cv2.floodFill(holes, mask,(0,0),(10,)*3, (10,)*3 ,8 | cv2.FLOODFILL_MASK_ONLY | (fillvalue << 8))
cv2.floodFill(holes1,mask,(0,0),(10,)*3,(10,)*3 ,8 | cv2.FLOODFILL_MASK_ONLY | (fillvalue << 8))
holes = cv2.bitwise_not(holes)
holes1 = cv2.bitwise_not(holes1)
c_defective_ff = blurred_defective | holes
c_golden_ff = blurred_golden | holes1
As a result of it , I got totally white image.