Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def getSpacing(im):
- l = im.shape[0]
- vote = np.zeros((l, l // 5 + 1))
- th = im.shape[1]
- result = list()
- for i in range(im.shape[0]):
- for j in range(im.shape[1]):
- if im[i][j] == 1:
- for spacing in range(1, l // 5 + 1):
- for mul in range(5):
- startLine = i - mul * spacing
- if startLine >= 0:
- vote[startLine][spacing] += 1
- startLine = -1
- tmpV = 0
- for i in range(vote.shape[0]):
- if np.sum(vote[i]) > tmpV:
- startLine = i
- tmpV = np.sum(vote[i])
- # print("StartLine = ", startLine)
- for i in range(vote.shape[0]):
- if np.sum(vote[1]) > tmpV + th:
- result.append(i)
- spacing = -1
- tmpV = 0
- for j in result:
- for i in range(vote.shape[1]):
- if vote[j][i] > tmpV:
- spacing = i
- tmpV = vote[j][i]
- result.append(spacing)
- return vote
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement