call_corners: Quickly find corners in contact matrix

Description Usage Arguments Details Value Author(s) Examples

View source: R/call_corners.R

Description

Use the Canny edge detector to find edges in a smoothed contact matrix, and determine corners based on the results.

Usage

1
call_corners(x, alpha, pow=0.2, t=3, t1=NULL, t2=NULL, sigma=2)

Arguments

x

Numeric square contact matrix

alpha

threshold adjustment factor for the Canny edge detector

pow

Power to raise elements of the contact matrix to for image construction. Defaults to 1.

t

Diffusion parameter for the initial contact matrix. Defaults to 1.

t1, t2

Threshold for weak and strong edges.

sigma

Degree of smoothing for the image gradient. Defaults to 2.

Details

This function calls cannyEdges from the imager package, and arguments alpha, t1, t2, and sigma are exactly those described in the documentation there.

Value

A binary, upper triangular matrix that is the same size as x. Corner loctions are indicated by 1.

Author(s)

hbk5086@psu.edu

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
set.seed(1)
nbasis <- 15

b <- create.lognormal.field(100, .5, 3, nbasis, rev = TRUE, reduce = FALSE,
                            copula = TRUE, copulaType = "frank", param = -4)
b <- b[-sample(1:nbasis^2, 75, replace = FALSE)]

coefs <- rexp(nbasis^2-50) + 1
fld <- lapply(seq_along(b), function(X) b[[X]]*coefs[X])
fld <- Reduce('+', fld) + matrix(rnorm(100^2, 0, .008), nrow = 100)

fld <- fld + abs(min(fld))
fld[lower.tri(fld)] <- 0


corners <- call_corners(fld, alpha = .4, pow = 0.2)

par(mfrow = c(1,2))
image(fld^.4, col=colorRampPalette(c("white","blue"))(256), useRaster=TRUE, main = "image")
image(corners, col=colorRampPalette(c("white","blue"))(256), useRaster=TRUE, main = "called corners")

hillarykoch/nrbfields documentation built on May 25, 2019, 8:17 a.m.