Monday, May 9, 2011

3 ADTrees!

1) Last time I ended talking about how 100,000 comparisons was too much. I dropped it down to 10,000 and it became much more manageable. I then did this three times, each with different randomly generated numbers to create three trees for detecting whether a square is an X or not.

Out of the 10,000 passed in comparisons they were reduced down to:

Tree 1) 48 comparisons
Tree 2) 52 comparisons
Tree 3) 58 comparisons

After I got these nice results, after some trial and error (off by 1 errors are lame) I extracted all the 'useful' numbers out of the random numbers into their own files, and manually altered the alternating decision trees to work with these. The result, fast extraction and comparison of pixels from a section of an image. Also because I was curious I mapped the comparisons to an image so I could see what it looked like. For parsing whether or not a section of an picture is an X or the endpoints of each line is compared.





Red is tree 1
Green is tree 2
Blue is tree 3

As we can see... one of the tress is much better than the other two. Random numbers are random.
And the results: Here

No comments:

Post a Comment