Skip to content

Instantly share code, notes, and snippets.

@ES-Alexander
Last active October 1, 2021 06:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ES-Alexander/7d6738d27d909ccdd2e63788b5e73394 to your computer and use it in GitHub Desktop.
Save ES-Alexander/7d6738d27d909ccdd2e63788b5e73394 to your computer and use it in GitHub Desktop.
Inpaint black regions around stitched images with a blurred effect using the image edge colours.
import cv2
image = cv2.imread('combine.jpg')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
mask = (gray == 0).astype('uint8') * 255
blurred = cv2.GaussianBlur(mask, (15,15), 10)
result = cv2.inpaint(image, blurred, 3, cv2.INPAINT_TELEA)
cv2.imshow('result', result)
print('press any key to exit')
cv2.waitKey(0)
cv2.destroyWindow('result')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment