Guest User

Untitled

a guest
Jul 23rd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. import numpy as np
  2. import cv2
  3.  
  4. img = cv2.imread('map.jpg')
  5. img = cv2.bitwise_not(img)
  6.  
  7. img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
  8. img_blur = cv2.medianBlur(img_gray, 9)
  9.  
  10. kernel = np.ones((5, 5), np.uint8)
  11.  
  12. img_thr = np.byte(img_blur > 127) * 255
  13.  
  14. img_opening = cv2.morphologyEx(img_thr, cv2.MORPH_OPEN, kernel)
  15. img_closing = cv2.morphologyEx(img_opening, cv2.MORPH_CLOSE, kernel)
  16.  
  17. result = img_gray * 0.5 + img_closing * 0.5
  18.  
  19. cv2.imwrite('result.jpg', result)
Add Comment
Please, Sign In to add comment