## Error in Solution Ex1 houghtransform.m?

Moderator: Computer Vision

schwanal
Erstie
Beiträge: 20
Registriert: 5. Mai 2010 12:56

### Error in Solution Ex1 houghtransform.m?

Dear all,

In the solution of houghtransform.m Line 29 we map the continues Value rho into the predefined bins with

m = round((nBinsRho-1)*(rho+D)/(2*D))+1;

why do we use round and not floor here? e.g. for
nBinsRho = 10
D = 1000
So Intervall is: 1: -1000 -> -801, 2: -800 -> -601, 3: -600 -> -401, 4: -400 -> -201, 5: -200 -> -1, 6: 0 -> 199, 7: 200 -> 399, 8: 400 -> 599, 9: 600 -> 799, 10: 800 -> 1000

If i try with matlab:

>> nBinsRho = 10

nBinsRho =

10

>> D = 1000

D =

1000

>> rho = -850

rho =

-850

>> m = round((nBinsRho-1)*(rho+D)/(2*D))+1;
>> m

m =

2

>>
This seems to produce wrong values due to not using floor or am i incorrect?

Thank u in advance and best regards,

alex

schwanal
Erstie
Beiträge: 20
Registriert: 5. Mai 2010 12:56

### Re: Error in Solution Ex1 houghtransform.m?

Another Problem seems to be in line 50 and 51:

Code: Alles auswählen

                vRho = [vRho, (-D + 2*D * (m-1)/(nBinsRho-1))];
vTheta = [vTheta, (-pi/2 + pi * (n-1)/(nBinsTheta-1))];

mustnt it be (m-0.5) respective (n-0.5) if I refeer to silde 7/8 in slides_ex1.pdf?

diane
Windoof-User
Beiträge: 25
Registriert: 21. Jun 2009 17:33

### Re: Error in Solution Ex1 houghtransform.m?

About the first question:
You are right, the current proposed solution is not fully satisfactory as it does not distribute the values between -D and D equally, ie some bins are more populated than others. But it does use the correct range of values.
The solution you mention, ie replacing round by floor, have a strong artifact, it is almost not using the last bin.
A good compromise would be to use the solution proposed in the slides.
b = floor((nBinsRho)*(rho+D)/(2*D))+1;
It distributes equally the values, and has only an issue with the rho=D, which can be treated independently.

Then, whatever solution you use the whole code should be consistent.
If you use the slide formula for the point mentioned in your first question, the corresponding slide formula should be used for what constitute your second question. So the answer to your second question depends on what you pick for the first one.
Also, you should be careful to adapt the houghtransform_backproject function accordingly, ie to have consistent formulas between these two functions.

More importantly, that's the general principle of the houghtransform you should make sure you have understood for the exam.
What is a voting space, what are we using it for in the exercise, and what other problem could such a technique be used for.