How to find Waldo with R?
Asked Answered
F

1

35

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!

Firewood answered 19/12, 2011 at 15:35 Comment(6)
The EBImage package has counterparts of at least some of the functions used in the Mathematica answer. bioconductor.org/packages/release/bioc/html/EBImage.htmlKakemono
adimpro may also be useful. cran.r-project.org/web/packages/adimpro/index.htmlKakemono
Well, there's two things going on here. First, what image processing algorithms do you want to use? Previous commenters have suggested some; I've written Sobel and Hough transforms pretty easily, etc. The other question is what format image are you playing with? FITS and TIFFs have nice "raw" pixel data while other formats may be messier. Also, you might like using imageJ better (freeware from NIH)Chalkstone
why R ? Better grab octave for image-processing. More mature image processing libs and mostly matlab compatible.Decompress
second 0x69 and Carl Witthoft. ImageJ is Java-based, very powerful and very flexible. R is not built for image processing. It might be possible to do it, exactly like it is possible to eat lobster with a hammer.Orchidectomy
@Joris: You've never tried to open a 4-pounder, eh? :-)Chalkstone
D
12

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)
Derisive answered 30/12, 2011 at 18:58 Comment(1)
Please don't hesitate to un-accept this answer if a better one comes up. I was just hoping to start the flow of answers...Derisive

© 2022 - 2024 — McMap. All rights reserved.