Learn R Programming

imager (version 1.0.5)

Image Processing Library Based on 'CImg'

Description

Fast image processing for images in up to 4 dimensions (two spatial dimensions, one time/depth dimension, one colour dimension). Provides most traditional image processing tools (filtering, morphology, transformations, etc.) as well as various functions for easily analysing image data using R. The package wraps 'CImg', , a simple, modern C++ library for image processing.

Copy Link

Version

Install

install.packages('imager')

Monthly Downloads

6,643

Version

1.0.5

License

LGPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Aaron Robotham

Last Published

August 2nd, 2025

Functions in imager (1.0.5)

as.data.frame.pixset

Methods to convert pixsets to various objects
boundary

Find the boundary of a shape in a pixel set
boats

Photograph of sailing boats from Kodak set
blur_anisotropic

Blur image anisotropically, in an edge-preserving way.
boxblur

Blur image with a box filter (square window)
cimg.openmp

Control CImg's parallelisation
cimg2im

Convert cimg to spatstat im object
circles

Add circles to plot
capture.plot

Capture the current R plot device as a cimg image
cannyEdges

Canny edge detector
clean

Clean up and fill in pixel sets (morphological opening and closing)
colorise

Fill in a colour in an area given by a pixset
common_pixsets

Various useful pixsets
boxblur_xy

Blur image with a box filter.
bucketfill

Bucket fill
display.cimg

Display image using CImg library
cimg.dimensions

Image dimensions
cimg.extract

Various shortcuts for extracting colour channels, frames, etc
display.list

Display image list using CImg library
contours

Return contours of image/pixset
frames

Split a video into separate frames
get.stencil

Return pixel values in a neighbourhood defined by a stencil
coord.index

Coordinates from pixel index
get.locations

Return coordinates of subset of pixels
flatten.alpha

Flatten alpha channel
erode

Erode/dilate image by a structuring element.
get_gradient

Compute image gradient.
crop.borders

Crop the outer margins of an image
ci

Concatenation for image lists
correlate

Correlation/convolution of image by filter
cimg

Create a cimg object
center.stencil

Center stencil at a location
channels

Split a colour image into a list of separate channels
distance_transform

Compute Euclidean distance function to a specified value.
hough_circle

Circle detection using Hough transform
highlight

Highlight pixel set on image
gsdim

Grayscale dimensions of image
haar

Compute Haar multiscale wavelet transform.
deriche

Apply recursive Deriche filter.
get_hessian

Return image hessian.
extract_patches

Extract image patches and return a list
display

Display object using CImg library
ilply

Split an image along axis, apply function, return a list
draw_rect

Draw rectangle on image
iiply

Split an image, apply function, recombine the results as an image
displacement

Estimate displacement field between two images.
diffusion_tensors

Compute field of diffusion tensors for edge-preserving smoothing.
imeval

Evaluation in an image context
draw_circle

Draw circle on image
imdraw

Draw image on another image
imcoord

Coordinates as images
idply

Split an image along axis, map function, return a data.frame
imager

imager: an R library for image processing, based on CImg
%inr%

Check that value is in a range
hough_line

Hough transform for lines
im_split

Split an image along a certain axis (producing a list)
grab

Select image regions interactively
draw_text

Draw text on an image
RGBtoHSL

Colour space conversions in imager
grow

Grow/shrink a pixel set
imager.combine

Combining images
imfill

Create an image of custom size by filling in repeated values
grayscale

Convert an RGB image to grayscale
imdirac

Generates a "dirac" image, i.e. with all values set to 0 except one.
imshift

Shift image content.
imsharpen

Sharpen image.
imwarp

Image warping
imnoise

Generate (Gaussian) white-noise image
imappend

Combine a list of images into a single image
imchange

Modify parts of an image
imager.replace

Replace part of an image with another
imager.subset

Array subset operator for cimg objects
index.coord

Linear index in internal vector from pixel coordinates
mirror

Mirror image content along specified axis
medianblur

Blur image with the median filter. In a window of size n x n centered at pixel (x,y), compute median pixel value over the window. Optionally, ignore values that are too far from the value at current pixel.
%>%

Pipe operator
permute_axes

Permute image axes
imsub

Select part of an image
patchstat

Return image patch summary
imsplit

Split an image along a certain axis (producing a list)
imgradient

Compute image gradient
periodic.part

Compute the periodic part of an image, using the periodic/smooth decomposition of Moisan (2011)
is.pixset

Check that an object is a pixset object
implot

Plot objects on image using base graphics
pixset

Pixel sets (pixsets)
load.image

Load image from file or URL
imrep

Replicate images
load.example

Load example image
imrotate

Rotate an image along the XY plane.
is.imlist

Check that an object is an imlist object
pixel.grid

Return the pixel grid for an image
is.cimg

Checks that an object is a cimg object
interp

Interpolate image values
inpaint

Fill-in NA values in an image
magick

Convert a magick image to a cimg image or image list and vice versa
load.video

Load a video using ffmpeg
resize

Resize image
renorm

Renormalise image
map_il

Type-stable map for use with the purrr package
make.video

Make/save a video using ffmpeg
interact

Build simple interactive interfaces using imager
squeeze

Remove empty dimensions from an array
split_connected

Split pixset into connected components
label

Label connected components.
iminfo

Return information on image file
liply

Apply function to each element of a list, then combine the result as an image by appending along specified axis
isoblur

Blur image isotropically.
imhessian

Compute image hessian.
imlap

Compute image Laplacian
imlist

Image list
plot.cimg

Display an image using base graphics
play

Play a video
pad

Pad image with n pixels along specified axis
mutate_plyr

Mutate a data frame by adding new or replacing existing columns.
rotate_xy

Rotate image by an arbitrary angle, around a center point.
patch_summary_cimg

Extract a numerical summary from image patches, using CImg's mini-language Experimental feature.
resize_doubleXY

Resize image uniformly
nfline

Plot a line, Hesse normal form parameterisation
save.image

Save image
plot.imlist

Plot an image list
px.flood

Select a region of homogeneous colour
load.dir

Load all images in a directory
threshold

Threshold grayscale image
px.na

A pixset for NA values
px.remove_outer

Remove all connected regions that touch image boundaries
stencil.cross

A cross-shaped stencil
vanvliet

Young-Van Vliet recursive Gaussian filter.
warp

Warp image
rm.alpha

Remove alpha channel and store as attribute
watershed

Compute watershed transform.
where

Return locations in pixel set
as.data.frame.cimg

Convert a pixel image to a data.frame
as.cimg.array

Turn an numeric array into a cimg object
add.colour

Add colour channels to a grayscale image or pixel set
FFT

Compute the Discrete Fourier Transform of an image
as.cimg.data.frame

Create an image from a data.frame
as.cimg.raster

Convert a raster object to a cimg object
as.cimg.function

Create an image by sampling a function
RasterPackage

Convert a RasterLayer/RasterBrick to a cimg image/image list
as.cimg

Convert to cimg object
as.cimg.im

Convert an image in spatstat format to an image in cimg format
bbox

Compute the bounding box of a pixset
as.raster.cimg

Convert a cimg object to a raster object for plotting
as.imlist.list

Convert various objects to image lists
at

Return or set pixel value at coordinates
as.pixset

Methods to convert various objects to pixsets
as.data.frame.imlist

Convert image list to data.frame
autocrop

Autocrop image region
as.igraph.pixset

Form an adjacency graph from a pixset
as.igraph.cimg

Form a graph from an image