Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import cv2
- img = cv2.imread('map.jpg')
- img = cv2.bitwise_not(img)
- img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
- img_blur = cv2.medianBlur(img_gray, 9)
- kernel = np.ones((5, 5), np.uint8)
- img_thr = np.byte(img_blur > 127) * 255
- img_opening = cv2.morphologyEx(img_thr, cv2.MORPH_OPEN, kernel)
- img_closing = cv2.morphologyEx(img_opening, cv2.MORPH_CLOSE, kernel)
- result = img_gray * 0.5 + img_closing * 0.5
- cv2.imwrite('result.jpg', result)
Add Comment
Please, Sign In to add comment