Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find Waldo with R?

Inspired by this thread How do I find Waldo with Mathematica?

I have never done image processing in R but maybe other people who have want to share...

thanks!

like image 622
Adam SO Avatar asked Dec 19 '11 15:12

Adam SO


1 Answers

Here is a start, using the raster package. I don't know if I will have the time to work on the cross-correlation method used in the Mathematica version of the question, but a local standard deviation on the red parts of the image seems to spot Waldo in this case...

library(raster)
waldo = stack("/Users/Benjamin/Desktop/DepartmentStore.jpg")

r = waldo[[1]] - waldo[[2]] - waldo[[3]]
r[is.na(r)] = 0
r_mask = Which(r > 0)
r_masked = r * r_mask

focalsd = focal(r_masked, w=3, fun=sd)
plot(focalsd)
like image 137
Benjamin Avatar answered Nov 15 '22 04:11

Benjamin