So, you know how to load PNG files, access their innards, and plot them as points in a scatter plot. But, is it possible to use R to do some of the awesome things you can do with Mathematica? Well, in this series of posts, I’ll introduce just a few of the things we can do with images in R — we can’t do everything that Mathematica does (at least not out of the box), and it’s not nearly as straightforward, or as fast, but if you are an R native like myself, there is still a lot you can do!

For example, the Gist below shows you how to load a .JPG file (from a URL), and convert it to a data.frame with pixel locations and colors. Then, there are a few examples of some of the very basic things you can do with that pixel data.frame, such as “make it look impressionistic” (above), filter colors in certain regions (below), and “snap” pixel colors to a rounded subset of the possible gamut (further below). Some of these are more interesting than others, but much cooler stuff is coming later in this series.

Note that the allImageURLs object is seeded with 21 URLs which are useful for the examples, but that you can easily pass your own URL to the imageLoader() function. Enjoy!

*Related*

To

**leave a comment** for the author, please follow the link and comment on their blog:

** is.R()**.

R-bloggers.com offers

**daily e-mail updates** about

R news and

tutorials on topics such as: visualization (

ggplot2,

Boxplots,

maps,

animation), programming (

RStudio,

Sweave,

LaTeX,

SQL,

Eclipse,

git,

hadoop,

Web Scraping) statistics (

regression,

PCA,

time series,

trading) and more...

If you got this far, why not

__subscribe for updates__ from the site? Choose your flavor:

e-mail,

twitter,

RSS, or

facebook...