Andna
Andna

Reputation: 6689

Opencv - cvHoughLines2

I am reading Learning openCV and I came across description of cvHoughLines2 in this book. But I can't understand one thing.

I read about Hough transform and I think I understand it, so the parameters rho and theta are bit puzzling to me. When we have equation rho=xcos(theta)+ycos(theta) when we decide on some set of discrete values of theta, values of rho should be automatically known.

In this book it is said that opencv creates rhoxtheta accumlator array.

Does opencv just discretize angle as multiplies of 360/theta? But how does the rho parameter fits? How are the values of rho discretized?

Upvotes: 2

Views: 3178

Answers (2)

user3452134
user3452134

Reputation: 380

in beginning you decide vector of theta lets say 10 numbers , you need to round the result to fall in pixel of matrix which row represent radius and columns the angle so if some line is in same angle and radius it will add the accumulator a value. [0 36 .. 360] also radius vector [1 2 3 .. 10] then you create image M*N all zeros lets say for example only [ 0 0 0 0 0 0 0 0 0] then you perform formula you write at some radius and angleyour matrix become [ 1 0 0 0 0 0 0 0 0]

then [ 1 0 0 0 0 1 0 0 0] then [ 2 0 0 0 0 1 0 1 0] ans so on then you can threshold and find only some lines or at some angles.

Upvotes: 0

fireant
fireant

Reputation: 14538

Your question isn't clear, it seems you are confused. Have a look at this page. Given a set of points (the x's and y's) belonging to a line you can describe the same line by just two parameters r and theta. These are two independent parameters we want to find that best describe the line that we have the points on.

Upvotes: 5

Related Questions