build.gaus {imagefx} | R Documentation |
Build 2D Gaussian Image (Matrix)
Description
Build a 2-dimensional Gaussian matrix for filtering, correlations, data testing, or other various uses.
Usage
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 |
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
############
### 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)
[Package imagefx version 0.4.1 Index]