Search code examples
pythonhough-transform

About Hough transform and its plot(with 3 points to plot)


I have a 3 points:

(1,3) (2,4) (3,5)

which equation is :

y = x + 2

and its

slope = 1
intercept = 2

After Hough Transform and plot,

# Hough Transformin in my code
r_axis[i] = x_point * math.cos(th) + y_point * math.sin(th)

I got:

plot-hough

This plot tell me:

r = 1
theta = 135 deg (???)

But my equation y = x + 1 tell me

theta = 
arctan(slope) ( -pi < tan < +pi ) = 
45 deg

The answer should be 45 deg, not 135 deg.

I'm confused

following is my source code:

code


Solution

  • Ok, after I think hardly.

    The intersection of plot is theta = 135 deg, r=1.414 not theta = 135 deg, r=1

    We modify y = x + 2 to y - x = 2

    the answer:

    r = 1.414
    theta = 135 deg
    

    We substitute to

    1.414 = y*sin (135 deg) - x*cos(135 deg)
    => 2 = y - x
    => y = x + 2
    

    So, code and plot both not problem