Learn R Programming

⚠️There's a newer version (2.1.2) of this package.Take me there.

imagine

Provides fast application of image filters to data matrices

This package uses C++ algorithms called 'engines'. More details are shown in vignette.

Installation

Get the development version from github:

# install.packages("devtools")
devtools::install_github("LuisLauM/imagine")

Or install the CRAN version

install.packages("imagine")

Input data

For all functions, the main input data must be a numeric matrix object. Depending on each funtion, user must indicate some extra arguments for the filter.

Examples

Next, we show the utility of quantileFilter, one of the six functions that imagine performs.

# Load imagine
library(imagine)

# Build an example matrix
n <- 1e3
origMatrix <- matrix(seq(n^2), nrow = n)

# Add some NAs
origMatrix_withNA <- origMatrix
origMatrix_withNA[sample(seq(n^2), 0.7*n^2, replace = FALSE)] <- NA

# Apply filter
newMatrix <- quantileFilter(dataMatrix = origMatrix_withNA, radius = 3, x = 0.1, times = 1)

# Plot matrices for compare
cols <- colorRampPalette(c("green3", "red4"))(n)

par(mar = c(0, 2, 0, 0), mfrow = c(3, 1))

image(origMatrix, col = cols, axes = FALSE)
mtext(text = "Original", side = 2, line = 0.5, font = 2)

image(origMatrix_withNA, col = cols, axes = FALSE)
mtext(text = "Original with NAs", side = 2, line = 0.5, font = 2)

image(newMatrix, col = cols, axes = FALSE)
mtext(text = "Filtered", side = 2, line = 0.5, font = 2)

Copy Link

Version

Install

install.packages('imagine')

Monthly Downloads

270

Version

1.3.1

License

GPL (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Wencheng LauMedrano

Last Published

July 7th, 2017

Functions in imagine (1.3.1)

image-package

IMAGing engINE, Tools for application of image filters to data matrices
wbImage

Data matrix to be used as example image.
meanFilter

Make a 2D filter calculations from numeric matrix
convolution2D

Make convolution calculations from numeric matrix