# Finding Waldo with Mathematica

For those of you who are fans of Finding Waldo and have a bit of a nerdy side to you, you’ll appreciate that someone figured out how to find Waldo using Mathematica:

Finding Waldo with the help of Mathematica.

The author describes his technique and provides the relevant code:

First, I’m filtering out all colours that aren’t red

````waldo = Import["http://www.findwaldo.com/fankit/graphics/IntlManOfLiterature/Scenes/DepartmentStore.jpg"]; `
`red = Fold[ImageSubtract, #[[1]], Rest[#]] &@ColorSeparate[waldo]; ````

Next, I’m calculating the correlation of this image with a simple black and white pattern to find the red and white transitions in the shirt.

````corr = ImageCorrelate[red,    Image@Join[ConstantArray[1, {2, 4}], `
`ConstantArray[0, {2, 4}]],    NormalizedSquaredEuclideanDistance]; ````

I use `Binarize` to pick out the pixels in the image with a sufficiently high correlation

and draw white circle around them to emphasize them using `Dilation`

``pos = Dilation[ColorNegate[Binarize[corr, .12]], DiskMatrix[30]]; ``

I had to play around a little with the level. If the level is too high, too many false positives are picked out.

Finally I’m combining this result with the original image to get the result above

``found = ImageMultiply[waldo, ImageAdd[ColorConvert[pos, "GrayLevel"], .5]]``

Amazing.

###

(via Kottke)