11-30-2013 04:07 PM
Hello everyone,
I'm making my own Face Recognition system and I'm at the phase of making a Hough Transform of my captured CAM-image.
So if a pixel is not zero; I generate its sinusoidal with -90° to 90° and calculate the corresponding value with the general Hough formula. Then for the voting process I increase the value of every pixel by 1.
Now the output is just a bit darker but there is no transformation at all.
I think I interpreted the algorithm wrong or I missed a detail in my coding..
Thanks in advance
Solved! Go to Solution.
11-30-2013 06:22 PM
I looked at your code and have some comments.
I looked at the Wikipedia article on the Hough transform. It appears that the definition in that article is somewhat different from your code.
from Wikipedia
for(i=-90;i<=90;i++)
{ Hough_Space[x][y] = Array[x][y]*cos(i)+Array[x][y]*sin(i);
Hough_Space[x][y]+=1;
} From your VI.
Note that the factors multiplying the sine and cosine terms are different.
The sine and cosine functions in the Formula Node take arguments in radians. The -90 to +90 in your code suggests degrees.
You may want to use a different threshold for creating the Hough Space array. The data is unsigned integer and the minimum value in your image is 25. So no pixels in your image are excluded and very few in most images will have pixels exactly equal to zero.
Is there a reason you prefer to use the formula node rather than the usual LV functions?
Lynn
11-30-2013 07:30 PM
When I replace the formula node with approximately equivalent LV VIs and functions, the time to execute goes from 5.5 s to 60 ms and memory usage drops from 115 MB to 28 MB.
Lynn
12-01-2013 04:54 AM
Thanks for the quick reply.
It seems I misinterpreted the formula. And I had no idea that there was so much difference between the formula node and LV VI's.
The reason why I use Formula Node that much is because I still have some trouble with all those different blocks in LV and I'm a C-programmer so the Formula Node is quite handy for me.
I'll firstly solve the error in my FN and when it'll work I'll implement it in LV VI.
Can you please show me how you implemented your Hough Transform?
Thanks in advance
12-01-2013 06:37 AM
So I changed the code, still using formula node.
Now the output is just plain black, I'm struggling with for 4.5h straight.
Can you give me a push to the right direction please?
Sincerely yours
12-01-2013 10:58 AM
@Sailiman wrote:
So I changed the code, still using formula node.
Now the output is just plain black, I'm struggling with for 4.5h straight.
Can you give me a push to the right direction please?
Unless you show us your new code, we cannot really tell what you are doing wrong. (... and why exactly are you still using the formula node?)
12-01-2013 12:16 PM
My bad, I forgot to upload the code.
And as said earlier, because I'm a C-programmer the transition is easier.
But I promise, I'm working on it and I'm really trying to improve my LV skills 🙂
12-01-2013 01:07 PM
1. You appear to be trying to work in degrees but the formula node uses radians for trigonometric functions. Cos(180) is not equal to cos(pi)!
2. I have not programmed in a text-based language for 30 years and never in C, but it looks like you assign Hough_Space[x][y] = Array[x][0]*cos(i)... for 361 values of i but only use the last one?
Lynn
12-02-2013 02:18 PM
Thanks for the response Lynn,
1. I converted the degrees into radian and indeed I have an image. But I suspect it's not 100% correct.
2. I don't think so, as I see it: The 2 for loops will loop for each element in the 2D-array. And for every element in the 2D-array I loop again with radials.
for(x=0; x<X;x++) { for(y=0; y<Y;y++) { for(i=-180;i<=180;i++) { Hough_Space[x][y] = Array[x][0]*cos((i*3,14)/180)+Array[0][y]*sin((i*3,14)/180); } Acc[j]=Hough_Space[x][y]; if(Acc[j]<Threshold) { Acc[i]=0; } j++; } }
I tried to implement a Hough Transform with the LV VI's as you sugested but still no succes. I'm stuck for getting the x-part for my cos and y-part for my sine. How did you implement it with LV VI?
Sincerely yours
12-02-2013 02:39 PM
Sailiman wrote:1. I converted the degrees into radian and indeed I have an image.
How does the output look like? It should look like a transform, not similar to the original image as in your first attempt.