Advertisement
Guest User

Untitled

a guest
Dec 11th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. import numpy as np
  3. import matplotlib.pyplot as plt
  4. import random
  5. import cv2
  6. sigma = 0.5
  7. kernel = np.ones((5, 5), np.uint8)
  8. for i in range(3,4):
  9. obraz = cv2.imread(str(i) + '.jpg')
  10. obraz2 = cv2.cvtColor(obraz,cv2.COLOR_BGR2GRAY)
  11. std = np.std(obraz2)
  12. #obraz2 = cv2.bilateralFilter(obraz2, -1, (1.0 + 0.7) * std, 50)
  13. v = np.median(obraz2)
  14. lower = int(max(0,(1.0-sigma)*v))
  15. upper = int(min(255,(1.0+sigma)*v))
  16.  
  17.  
  18. obraz2 = cv2.Canny(obraz2, 5*lower, 5*upper)
  19. minLineLength = 20
  20. maxLineGap = 0
  21. lines = cv2.HoughLinesP(obraz2, 1, np.pi/180, 20, minLineLength, maxLineGap)
  22.  
  23. for x in range(0, len(lines)):
  24. for x1,y1,x2,y2 in lines[x]:
  25. cv2.line(obraz,(x1,y1),(x2,y2),(0,255,0),2)
  26. cv2.imwrite(str(i) + '_out.jpg', obraz)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement