Stony Brook University
CSE 527
midterm_hough_transform
September 26, 2019
In [1]: import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
0.1 Problem Setup
In [2]: angles = np.arange(-90, 91, 15, dtype=np.float32) # * np.pi / 180
intercepts = np.arange(-1, 8)
points = [(0,0), (1,6), (2,4), (3,6), (4,8)]
print "angles: ", angles
pri
...[Show More]
midterm_hough_transform
September 26, 2019
In [1]: import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
0.1 Problem Setup
In [2]: angles = np.arange(-90, 91, 15, dtype=np.float32) # * np.pi / 180
intercepts = np.arange(-1, 8)
points = [(0,0), (1,6), (2,4), (3,6), (4,8)]
print "angles: ", angles
print "intercepts: ", intercepts
print "points: ", points
angles: [-90. -75. -60. -45. -30. -15. 0. 15. 30. 45. 60. 75. 90.]
intercepts: [-1 0 1 2 3 4 5 6 7]
points: [(0, 0), (1, 6), (2, 4), (3, 6), (4, 8)]
0.2 Question b
In [3]: vote_table = np.zeros((len(angles), len(intercepts)), dtype=int)
eps = 0.5
angles_pi = angles * np.pi / 180
# hough transform
for i in xrange(len(angles_pi)):
ang = angles_pi[i]
for j in xrange(len(intercepts)):
intercept = intercepts[j]
for pt in points:
if abs(pt[0] * np.tan(ang) + intercept - pt[1]) < eps:
vote_table[i,j] = vote_table[i,j] + 1
vote_table_df = pd.DataFrame(vote_table, index=angles, columns=intercepts)
display(vote_table_df)
1
-1 0 1 2 3 4 5 6 7
-90.0 0 1 0 0 0 0 0 0 0
-75.0 0 1 0 0 0 0 0 0 0
-60.0 0 1 0 0 0 0 0 0 1
-45.0 0 1 0 0 0 0 0 1 1
-30.0 0 1 0 0 0 0 1 0 1
-15.0 0 1 0 0 0 0 1 1 1
0.0 0 1 0 0 0 1 0 2 0
15.0 0 1 0 0 1 0 1 1 1
30.0 0 1 0 0 1 1 1 1 0
45.0 0 1 0 1 1 1 1 0 0
60.0 0 1 3 0 0 1 0 0 0
75.0 0 1 0 1 0 0 0 0 0
90.0 0 1 0 0 0 0 0 0 0
[Show Less]
Access Full Document
Instant download after payment
Card Payments
₿
Crypto Accepted