dataPrep: Neighborhood Data Preparation

Description Usage Arguments Value Note Author(s) References See Also Examples

View source: R/dataPrep.R

Description

Prepares a neighborhood data from a given image, using the left-to-right then top-to-bottom raster scan order (see Bui and Apley 2017a).

Usage

1
dataPrep(img, nb, vars = NULL, subsample = 1)

Arguments

img

the given image in the matrix format.

nb

the size of the neighborhood. It must be a 1-length or 3-length vector of positive integer(s). If the former, it is the same with a 3-length vector with the same elements.

vars

names of variables to be selected in the neighborhood data.

subsample

the portion of data rows be returned. It takes values in (0, 1]. If subsample = 1, all data rows will be returned, and if subsample = .5, only roughly a half will be returned.

Value

A dataframe with column names "V1", "V2", "V3", ... The first column "V1" contains the response pixel, whereas the other columns contain pixels in the neighborhood (with size nb) of the response pixel.

Note

Only rows without missing values (corresponding to pixels with full neighborhood) are returned.

Author(s)

Anh Bui

References

Bui, A.T. and Apley., D.W. (2018a) "A Monitoring and Diagnostic Approach for Stochastic Textured Surfaces", Technometrics, 60, 1-13.

Bui, A.T. and Apley, D.W. (2018b) "Monitoring for changes in the nature of stochastic textured surfaces", Journal of Quality Technology, to appear.

See Also

surfacemodel, monitoringStat

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## construct a neighborhood data for an unrealistically small mock image (7x9 pixels).
mock.img <- matrix(sample(0:255,63), 7, 9)
mock.img
dataPrep(img = mock.img, nb = 2) # the same with nb = c(2, 2, 2)

## select only columns "V2", "V5", and "V13" in the output
dataPrep(img = mock.img, nb = 2, vars = c("V2", "V5", "V13"))

## return only a half number of rows
dataPrep(img = mock.img, nb = 2, subsample = .5)

spc4sts documentation built on April 10, 2018, 1:04 a.m.