Title: | A Pipe-Friendly Image Calculator |
---|---|
Description: | Provides a set of fast, chainable image-processing operations which are applicable to images of two, three or four dimensions, particularly medical images. |
Authors: | Jon Clayden [aut, cre] , Chris Rorden [aut] , John Muschelli [ctb] , Exstrom Laboratories LLC [cph] |
Maintainer: | Jon Clayden <[email protected]> |
License: | BSD_3_clause + file LICENCE |
Version: | 0.1.0 |
Built: | 2025-01-05 04:17:21 UTC |
Source: | https://github.com/jonclayden/imbibe |
Basic binary operations
add(image, arg) subtract(image, arg) multiply(image, arg) divide(image, arg) remainder(image, arg) mask(image, arg) maximum(image, arg) minimum(image, arg)
add(image, arg) subtract(image, arg) multiply(image, arg) divide(image, arg) remainder(image, arg) mask(image, arg) maximum(image, arg) minimum(image, arg)
image |
An image object or pipeline. |
arg |
Numeric or image argument. |
An updated pipeline.
Mathematical morphology and filtering operations
dilate(image, kernel = NULL, ..., max = FALSE, nonzero = TRUE) dilateall(image, kernel = NULL, ...) erode(image, kernel = NULL, ..., min = FALSE) filter_median(image, kernel = NULL, ...) filter_mean(image, kernel = NULL, ..., norm = TRUE) smooth_gauss(image, sigma) subsample(image, offset = FALSE)
dilate(image, kernel = NULL, ..., max = FALSE, nonzero = TRUE) dilateall(image, kernel = NULL, ...) erode(image, kernel = NULL, ..., min = FALSE) filter_median(image, kernel = NULL, ...) filter_mean(image, kernel = NULL, ..., norm = TRUE) smooth_gauss(image, sigma) subsample(image, offset = FALSE)
image |
An image object or pipeline. |
kernel |
A suitable kernel function (see |
... |
Additional arguments to the kernel function, if any. |
max |
Logical value: if |
nonzero |
Logical value: if |
min |
Logical value: if |
norm |
Logical value indicating whether the mean filter will be normalised or not. |
sigma |
Numeric value giving the standard deviation of the Gaussian smoothing kernel. |
offset |
Logical value indicating whether subsampled pixels should be offset from the original locations or not. |
An updated pipeline.
Dimensionality reduction operations
dim_mean(image, dim = 4L) dim_sd(image, dim = 4L) dim_max(image, dim = 4L) dim_whichmax(image, dim = 4L) dim_min(image, dim = 4L) dim_median(image, dim = 4L) dim_quantile(image, dim = 4L, prob) dim_AR1(image, dim = 4L)
dim_mean(image, dim = 4L) dim_sd(image, dim = 4L) dim_max(image, dim = 4L) dim_whichmax(image, dim = 4L) dim_min(image, dim = 4L) dim_median(image, dim = 4L) dim_quantile(image, dim = 4L, prob) dim_AR1(image, dim = 4L)
image |
An image object or pipeline. |
dim |
Integer value between 1 and 4, giving the dimension to apply the reduction along. |
prob |
For |
An updated pipeline.
This function provides an expectation for use with the "tinytest" package, which runs the pipeline specified in its first argument and compares the result to its second.
expect_pipeline_result(current, target, precision = "double", ...)
expect_pipeline_result(current, target, precision = "double", ...)
current |
The pipeline to run, which should have class |
target |
The target value to compare against, a numeric array of some
kind, which will be converted to a |
precision |
A string specifying the working precision. Passed to
|
... |
Further arguments to |
A "tinytest"
object.
Basic unary operations
exponent(image) logarithm(image) sine(image) cosine(image) tangent(image) arcsine(image) arccosine(image) arctangent(image) square(image) squareroot(image) reciprocal(image) absolute(image) binarise(image, invert = FALSE) binarize(image, invert = FALSE)
exponent(image) logarithm(image) sine(image) cosine(image) tangent(image) arcsine(image) arccosine(image) arctangent(image) square(image) squareroot(image) reciprocal(image) absolute(image) binarise(image, invert = FALSE) binarize(image, invert = FALSE)
image |
An image object or pipeline. |
invert |
Logical value: if |
An updated pipeline.
Create an operation pipeline
imbibe(image) ## S3 method for class 'imbibe' asNifti(x, ...) ## S3 method for class 'imbibe' as.array(x, ...) ## S3 method for class 'imbibe' print(x, ...)
imbibe(image) ## S3 method for class 'imbibe' asNifti(x, ...) ## S3 method for class 'imbibe' as.array(x, ...) ## S3 method for class 'imbibe' print(x, ...)
image |
An image object or existing pipeline. |
x |
An |
... |
Additional arguments to methods. |
Mathematical morphology kernels
kernel_3d(image) kernel_2d(image) kernel_box(image, width, voxels = FALSE) kernel_gauss(image, sigma) kernel_sphere(image, radius) kernel_file(image, file)
kernel_3d(image) kernel_2d(image) kernel_box(image, width, voxels = FALSE) kernel_gauss(image, sigma) kernel_sphere(image, radius) kernel_file(image, file)
image |
An image object or pipeline. |
width |
The width of the kernel in appropriate units. If |
voxels |
Logical value: if |
sigma |
Numeric value giving the standard deviation of a Gaussian kernel, in millimetres. |
radius |
Numeric value giving the radius of a sphere kernel, in millimetres. |
file |
Name of a NIfTI file containing the kernel. |
An updated pipeline.
Run a pipeline and return an image result
run(pipe, precision = getOption("imbibe.precision", "double"))
run(pipe, precision = getOption("imbibe.precision", "double"))
pipe |
An operation pipeline. |
precision |
The internal precision used for calculations. May be
|
An image
im <- RNifti::readNifti(system.file("extdata", "example.nii.gz", package="RNifti")) pipe <- im %>% threshold_below(500) %>% binarise() run(pipe)
im <- RNifti::readNifti(system.file("extdata", "example.nii.gz", package="RNifti")) pipe <- im %>% threshold_below(500) %>% binarise() run(pipe)
Image thresholding
threshold( image, value, reference = c("none", "image", "nonzero"), above = FALSE ) threshold_below(image, value, reference = c("none", "image", "nonzero")) threshold_above(image, value, reference = c("none", "image", "nonzero"))
threshold( image, value, reference = c("none", "image", "nonzero"), above = FALSE ) threshold_below(image, value, reference = c("none", "image", "nonzero")) threshold_above(image, value, reference = c("none", "image", "nonzero"))
image |
An image object or pipeline. |
value |
Numeric threshold value. |
reference |
String indicating what the |
above |
Logical value: if |
An updated pipeline.