Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-069

Hough Line Count

Problem

Count line votes for a simple Hough accumulator.

For each slope m in slopes, compute the intercept b = round(y - m * x, 4) for every point [x, y] and return the maximum number of points sharing one intercept. The result has one integer per slope; an empty point list gives 0.

Hint

Points on the same line share the same intercept b = y - m * x.

Test cases

case 1
in: [[[0,0],[1,1],[2,2],[0,1]],[1,0]]
expected: [3,2]
case 2
in: [[[0,0],[1,2],[2,4]],[2,1]]
expected: [3,1]
case 3
in: [[[1,1],[2,2],[3,4]],[1]]
expected: [2]
case 4
in: [[],[1]]
expected: [0]
Starter codePython
def hough_line_count(points, slopes):
    # Your code here
    pass

4 test cases · run your code against them in the editor