Advertisement
Guest User

Bridge light edges

a guest
Dec 2nd, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. import cv2
  2. import matplotlib as plt
  3. import numpy as np
  4.  
  5. pic = plt.imread("Unknown.jpg")
  6. sobelx = cv2.Sobel(cv2.cvtColor(pic, cv2.COLOR_RGB2GRAY),cv2.CV_64F,1,0,ksize=11)
  7. sobely = cv2.Sobel(cv2.cvtColor(pic, cv2.COLOR_RGB2GRAY),cv2.CV_64F,0,1,ksize=11)
  8. edges = np.sqrt(sobelx ** 2 + sobely ** 2) > 5000000
  9.  
  10. pic2 = pic.astype(np.float)
  11. pic2[edges] /= 255
  12. pic2[edges] **= 1/3
  13. pic2[edges] *= 255
  14. pic2 = pic2.astype(np.uint8)
  15.  
  16. plt.imsave("bridge_light.png", pic2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement