Changing webcam-pixels to "nearest" color from color palette array

As an alternative to blur, a combination of dilate followed by erode is a good simple way to fill small holes. Given your goals, I would guess that you could be fairly aggressive with how much you dilate – you just have to avoid completely filling empty bead slots before the dilate step restores them. I believe that there is some fairly good documentation of that with opencv.

You could also you blob detection to detect the holes, then patch them with a color taken from their edge. Or, since in your case the holes are also almost identical sizes, you could also use template matching to detect and patch. It is dead simple – although a potential downside is it might be more sensitive to the lighting conditions of your setup.

1 Like