You can see the code running with more examples at the colab link below
pip3 install opencv-contrib-python numpy
- Crop image to location of the white ball.
- Detect Ball within cropped image using Circle Hough and get its dimensions.
- Convert cropped coordinates to lie within the full image.
- Get a Sample area of the image to cover the hole.
- Convert sample to HSV to measure Standard deviation.
- Check if sample is valid based on Standard deviation and whether it lies within the image.
- If sample is valid, blend sample in with background using inpainting.
- If not valid, use inpainting to fill in hole.
- Display before and after images.