Learn R Programming

spc4sts (version 0.1.1)

sarGen: Stochastic Autoregressive Image Generator

Description

Generates 2D stochastic AR(1) images with/without a local defect.

Usage

sarGen(phi1 = .6, phi2 = .35, sigma = .01, m = 250, n = 250,
       defect = FALSE, loc = NULL, a = 7, b = 10, eps = .05,
       phi1_new = 0, phi2_new = 0, sigma_new = sigma,
       border = 200, greyscale = FALSE)

Arguments

phi1

the parameter phi1 of the process.

phi2

the parameter phi2 of the process.

sigma

the parameter sigma of the process.

m

the number of rows of the generated image.

n

the number of columns of the generated image.

defect

if set to TRUE, (smoothly) adds a defect (an ellipsoidal-shaped 2D AR(1) image) to the generated one.

loc

the location of the defect in the generated image.

a

2*a + 1 is the vertical axis length of the ellipsoidal defect.

b

2*b + 1 is the vertical axis length of the ellipsoidal defect.

eps

controls the curvature of the ellipsoidal defect.

phi1_new

the parameter phi1 of the defect.

phi2_new

the parameter phi2 of the defect.

sigma_new

the parameter sigma of the defect.

border

the number of top rows/left columns to be cut off from the generated image. This helps reduce the effect of the starting condition.

greyscale

whether to return greyscale (0-255) or continuous pixel intensities.

Value

If defect = TRUE, a list of the following:

img

the generated image in the matrix format.

defect.info

the information of the defects.

Otherwise, the generated image in the matrix format.

Details

The pixel y(i,j) of the generated image satisfies: y(i,j) = phi1*y(i-1,j) + phi2*y(i,j-1) + e(i,j), where e(i,j) follows a zero-mean Gaussian distribution with standard deviation of sigma.

References

Bui, A.T., and Apley., D.W. (2017) A Monitoring and Diagnostic Approach for Stochastic Textured Surfaces", Technometrics (in press).

See Also

imposeDefect

Examples

Run this code
# NOT RUN {
## generate an image without defects
img <- sarGen(m = 100, n = 100, border = 50)
image(img,col=gray(c(0:32)/32))

## generate an image with a defect
img <- sarGen(m = 100, n = 100, border = 50, defect = TRUE)
image(img$img,col=gray(c(0:32)/32))
# }

Run the code above in your browser using DataLab