build.gaus: Build 2D Gaussian Image (Matrix)

Description Usage Arguments Details Value Author(s) Examples

View source: R/build.gaus.r

Description

Build a 2-dimensional Gaussian matrix for filtering, correlations, data testing, or other various uses.

Usage

1
build.gaus(xdim, ydim, sig.x, sig.y, x.mid, y.mid)

Arguments

xdim

size in the x dimension

ydim

size in the y dimension

sig.x

Gaussian sqrt(variance) in x direction

sig.y

Gaussian sqrt(variance) in y direction. Defaults to sig.x if undefined

x.mid

peak location in x direction

y.mid

peak location in the y direction

Details

Note that if xdim or ydim are even and x.mid and y.mid are left undefined, the Gaussian peak will be off center. This can be a problem when using a Gaussian matrix for multiple filtering operations.

Value

matrix with values corresponding to values in the 2D Gaussian.

Author(s)

Alex J.C. Witsil

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
############
### EG 1 ###
############

## define the dimensions of the gaussian image (matrix)
xdim=101
ydim=101

## sigma in the x direction.  The y sigma defaults to the sig.x if not supplied
sig.x=5

## build the first example
gaus1 <- build.gaus(xdim,ydim,sig.x)


###################
## PLOTTING EG 1 ##
###################
image(1:nrow(gaus1),1:ncol(gaus1),useRaster=TRUE,gaus1)


############
### EG 2 ###
############

## define the dimensions of the gaussian image (matrix)
xdim=101
ydim=201

## define a sigma in the both the x and y direction
sig.y=5
sig.y=20

## define the center (peak) location of the guassian
x.mid = 30
y.mid = 120

## now build the gaussian
gaus2 <- build.gaus(xdim,ydim,sig.x,sig.y,x.mid,y.mid)

##################
## PLOTTING EG2 ##
##################
image(1:nrow(gaus2),1:ncol(gaus2),useRaster=TRUE,gaus2)

imagefx documentation built on Feb. 14, 2020, 1:07 a.m.