Skip to content

Instantly share code, notes, and snippets.

@pepijn-devries
Last active August 29, 2015 14:27
Show Gist options
  • Save pepijn-devries/695d89911dd1dfa26f44 to your computer and use it in GitHub Desktop.
Save pepijn-devries/695d89911dd1dfa26f44 to your computer and use it in GitHub Desktop.
#required packages:
require(jpeg)
#Read a jpeg from a website and store as matrix "mat_clown"
con <- file("http://4.bp.blogspot.com/-uObQLjPG8Xg/VceaZNyI-NI/AAAAAAAAx0o/ZlcTTB1pomU/s1600/fourier_efteling.jpg", "rb")
#make sure 'n' is big enough to hold your entire file:
jpg_clown <- readBin(con, "raw", n = 3e4)
close(con)
rm(con)
mat_clown <- readJPEG(jpg_clown)
rm(jpg_clown)
#rotate the matrix to its intended position
rotate <- function(x) t(apply(x, 2, rev))
mat_clown <- rotate(mat_clown)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment