Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import numpy as np
- import matplotlib.pyplot as plt
- import random
- import cv2
- sigma = 0.5
- kernel = np.ones((5, 5), np.uint8)
- for i in range(3,4):
- obraz = cv2.imread(str(i) + '.jpg')
- obraz2 = cv2.cvtColor(obraz,cv2.COLOR_BGR2GRAY)
- std = np.std(obraz2)
- #obraz2 = cv2.bilateralFilter(obraz2, -1, (1.0 + 0.7) * std, 50)
- v = np.median(obraz2)
- lower = int(max(0,(1.0-sigma)*v))
- upper = int(min(255,(1.0+sigma)*v))
- obraz2 = cv2.Canny(obraz2, 5*lower, 5*upper)
- minLineLength = 20
- maxLineGap = 0
- lines = cv2.HoughLinesP(obraz2, 1, np.pi/180, 20, minLineLength, maxLineGap)
- for x in range(0, len(lines)):
- for x1,y1,x2,y2 in lines[x]:
- cv2.line(obraz,(x1,y1),(x2,y2),(0,255,0),2)
- cv2.imwrite(str(i) + '_out.jpg', obraz)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement