This is part 2 of my Where’s Waldo algorithm. Here’s part 1.
So after numerous tweaks to my Where’s Waldo algorithm, I finally settled on one that takes threshold values in order to locate the elusive striped character of Waldo.
This is essentially the same idea as what I did in my last post, with the added parameter of threshold values and a revised algorithm.
With this function, I tested out various Waldo puzzles. For example,
Let’s try applying the findWaldo function to this image. Since the threshold values will most likely be different, we can map a range of threshold values over the image to get to a point where we can eliminate a majority of the regions on the image.
We see in the example above that we have, once again, exactly picked out where Waldo is (comparison with the original, unblurred image confirms this belief). In this case, we got only one false positive, which interestingly enough was the front half of a horse.
Let’s take this algorithm for a spin on a more complex Waldo puzzle.
This image has a generally high amount of regions with morphological components and colors similar to Waldo’s appearance. With a little input threshold checking, the best output I could get from this one was:
In this case, I found Waldo at square (11,6) – if you click on the picture, you can see in the closeup that Waldo is indeed at that location. However, this image produced a large number of false positives, mainly because of how complex the non-Waldo regions and how many instances of the Waldo-striped red occur in many of the regions of the image.
My next ambition with this is to implement a depth-first search components that locates Waldo exactly. It shouldn’t be too hard if combined with the parser- the parser locates likely regions, then passes the region to a DFS mechanism that looks for the red striped pattern.
I feel like the morals of this experiment are
- with great computational abilities comes great ideas
- with great ideas comes great computation