Simon Barthelmé (GIPSA-lab, CNRS)

R is a bit lacking in the area of image processing, where Matlab is still king. Imager aims to make image processing work in R easier. It is based on CImg, a C++ library by David Tschumperlé. CImg provides an easy-to-use and consistent API for image processing, which imager largely replicates. CImg supports images in up to four dimensions, which makes it suitable for basic video processing/hyperspectral imaging as well.

Features

At this stage imager contains over 100 functions, and covers all the classics:

imager aims to be fast (doing things in C++ as much as possible), but also R-friendly, and defines many convenience functions that make it easy to work with native R datatypes and functions.

Installing the package

Imager is now on CRAN, so

install.packages("imager")

should to the trick. If you prefer the latest development version, see our Github page.

Dependencies

OS X users need to install XQuartz: https://www.xquartz.org/. You’ll also need ImageMagick and ffmpeg if you want to work with videos, or import and save images in formats other than BMP, TIFF, PNG and JPEG. On Linux these should be available from standard repositories (ie. “sudo apt-get install ffmpeg” should work). On OS X they are available via brew: “brew install imagemagick ffmpeg”.

Getting started

There’s a tutorial included in the package: hit

vignette("gettingstarted",package="imager")

or click here.

The tutorial covers basic image manipulation, plotting use base graphics and ggplot2, getting image data in and out, and an example of multiscale blob detection.

The next step is to learn about pixsets, which are used to represent sets of pixels (e.g., the foreground in an image).

    vignette("pixsets",package="imager")

The vignette includes an example of image segmentation.

Documentation

General package documentation

Many functions are described in the general package documentation. The automatically generated docs are here, and come with examples.

You might find CImg’s doc useful as well.

FAQ

See here for Frequently Asked Questions.

Tutorials, case studies, etc.

Canny edge detector

how to write fast functional code: a loop-free Canny edge detector

gimp-toolbox-icons.png

Imager as an image editor

Where do I find the bucket tool in imager?

Quadtrees

Image splitting, simplification and recursive data structures.

Image unshredding

Shuffle the columns of an image, and put it back together by solving a TSP.

Parallelising

How to parallelise computations

Image statistics

An (incomplete) tutorial on image statistics

Image morphology

A tutorial on morphology and detrending

Other packages

Importing image data from other R packages

Foreground and background

Image segmentation using nearest-neighbour classifiers, watershed transform

Gradient fields

Plotting gradient fields using ggplot2

Using the C++ api

For better performance you can call CImg directly

ASCII art

How to render an image using only characters

Bugs, issues, etc.

Bugs and miscellaneous problems can be reported on the issues page on Github.