arr.mask: Transform array data upon masking

View source: R/arr.mask.R

arr.maskR Documentation

Transform array data upon masking

Description

Transform a rank-3 array called arr, represented by, \mathbb{T} = T_{m,n,p}, using a matrix called mask, represented by \mathbb{M}=(m_{ij})_{m \times n}.
Masks each matrix T_{m,n,p}\,\forall\, p \in \{1, 2, 3, \dots , N\} using the same mask \mathbb{M}=(m_{ij})_{m \times n}.
Any matrix slice T_{m,n,k} and the mask have the same dimensionality, i.e. m \times n. See mat.mask for details.

Usage

arr.mask(arr, mask, drop.dat = F)
arr.mask(arr, mask, drop.dat = T)
arr.mask(arr, mask)

Arguments

arr

The rank-3 array, T_{m,n,p} that you want to mask.

mask

The masking matrix, \mathbb{M}=(m_{ij})_{m \times n}, that you need to use as a mask.
Should be a boolean matrix.
Should have the same dimesions, m \times n, as any slice T_{m,n,k} of the array arr.

drop.dat

Boolean bit, defaults to FALSE.
When set to FALSE, the output array will have the same dimesnionality as arr, i.e. m \times n \times p
When set to TRUE, the output array dimesnionality might be different. Please see mat.mask for more details.

Value

The returned value is always a rank-3 array.
Whether the dimensions of the output and arr are same or not, depends on drop.dat.
Please see mat.mask for more details.

Author(s)

Chitran Ghosal

Examples

###plot the original image and convert it to an array
dat <- system.file("extdata", "STM.png", package = "StatsChitran")
tens <- img_2_arr(source.png = dat, x.lim = c(0, 6.115*10^-9), y.lim = c(0, 6.115*10^-9))
plot2D.arr(arr = tens)

###create the mask
mask_x <- tens[,,2] >= 2*10^-9 & tens[,,2] <=4*10^-9
mask_y <- tens[,,3] >= 2.5*10^-9 & tens[,,3] <= 5.5*10^-9
mask <- mask_x & mask_y

####points not dropped
arr.res <- arr.mask(arr = tens, mask = mask, drop.dat = F)
plot2D.arr(arr.res)

####points dropped
arr.res <- arr.mask(arr = tens, mask = mask, drop.dat = T)
plot2D.arr(arr.res)

Chitran1987/StatsChitran documentation built on Feb. 23, 2025, 8:30 p.m.