minmax_img-methods: Normalize Image using Range

minmax_img-methodsR Documentation

Normalize Image using Range

Description

Calculates the range of values in an image, then scales the image minimum to 0 and maximum to 1

Usage

minmax_img(img)

## S4 method for signature 'nifti'
minmax_img(img)

## S4 method for signature 'array'
minmax_img(img)

## S4 method for signature 'ANY'
minmax_img(img)

## S4 method for signature 'character'
minmax_img(img)

## S4 method for signature 'factor'
minmax_img(img)

## S4 method for signature 'list'
minmax_img(img)

Arguments

img

character path of image or an object of class nifti, or list of images

Value

A nifti object (or list of them) or class of object passed in if not specified

Examples

set.seed(5)
dims = rep(10, 4)
arr = array(rpois(prod(dims), lambda = 2), dim = dims)
nim = oro.nifti::nifti(arr)
mimg = minmax_img(nim)
marr = minmax_img(arr)
testthat::expect_equal(array(mimg, dim = dim(mimg)), marr)

set.seed(5)
dims = rep(10, 3)
arr = array(rnorm(prod(dims)), dim = dims)
arr[,,10] = 0
nim = oro.nifti::nifti(arr)
rnifti = RNifti::asNifti(nim)
timg = tempimg(nim)
limg = list(factor(timg), factor(timg))
func = minmax_img
func(arr)
func(nim)
func(rnifti)
func(timg)
func(limg)

neurobase documentation built on May 29, 2024, 2:17 a.m.