Skip to content

Instantly share code, notes, and snippets.

@codingforpleasure
Created September 12, 2018 07:38
Show Gist options
  • Save codingforpleasure/4cb308e7804b83c263d828ba6c34c2c5 to your computer and use it in GitHub Desktop.
Save codingforpleasure/4cb308e7804b83c263d828ba6c34c2c5 to your computer and use it in GitHub Desktop.
# here is my python code:
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
gray = cv2.bitwise_not(gray)
top = int(0.25 * gray.shape[0])
bottom = int(0.25 * gray.shape[0])
left = int(0.25 * gray.shape[1])
right = int(0.25 * gray.shape[1])
gray = cv2.copyMakeBorder(gray, top, bottom, left, right, cv2.BORDER_CONSTANT, value=255)
kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (2 * 5 + 1, 2 * 5 + 1), (5, 5))
res = cv2.dilate(gray, kernel)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment