Created
December 4, 2015 15:38
-
-
Save di/5dcb1c0e555c35ecc887 to your computer and use it in GitHub Desktop.
consolidated coins script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
img = cv2.imread("coins.png", cv2.IMREAD_GRAYSCALE) | |
circles = cv2.HoughCircles( | |
img, | |
cv2.cv.CV_HOUGH_GRADIENT, | |
dp=1.5, | |
minDist=30, | |
minRadius=15, | |
maxRadius=60, | |
) | |
black = np.zeros(img.shape) | |
for x, y, r in circles[0]: | |
# -1 to draw filled circles | |
cv2.circle(black, (x,y), int(r+15), 255, -1) | |
bytemask = np.asarray(black, dtype=np.uint8) | |
inpainted = cv2.inpaint(img, bytemask, inpaintRadius=5, flags=cv2.INPAINT_TELEA) | |
cv2.imshow('image',inpainted) | |
cv2.waitKey(0) | |
cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment