binarizer {SpatialVx}R Documentation

Create Binary Fields

Description

Convert a spatial field to a binary spatial field via thresholding.

Usage

binarizer(X, Xhat, threshold = NULL,
	  rule = c(">", "<", ">=", "<=", "<>", "><", "=<>",
		   "<>=", "=<>=", "=><", "><=", "=><="),
	  value = c("matrix", "owin"), ...)

Arguments

X, Xhat

matrix or “owin” objects.

threshold

single number, numeric vector of two numbers, or two-by-two matrix; depending on the value of rule. May be missing or null if both X and Xhat are “owin” class objects, in which case binary fields are made wherever these fields are greater than zero, and other arguments are ignored.

rule

character giving the rule for identifying 1-valued grid squares. For example, if rule is the default (“>”), then threshold should either be a single numeric or a vector of length two. If the latter, it specifies a different threshold for X and Xhat, the result is that everywhere X > threshold will have a value of 1 and zero otherwise, etc. The rule “<>” means 1-values whenever X (Xhat) are less than the lower threshold and higher than the higher threshold, etc. For rules requiring two threshold values, if a two-by-two matrix is given, the first column is associated with X and the second with Xhat.

value

character telling whether the returned object be a list with two matrices or a list with two “owin” class objects.

...

Not used.

Details

The binary fields are created by assigning ones according to the rule: 1. ">": if X > threshold, assign 1, zero otherwise. 2. "<": if X < threshold, assign 1, zero otherwise. 3. ">=": if X >= threshold, assign 1, zero otherwise. 4. "<=": if X <= threshold, assign 1, zero otherwise. 5. "<>": if X < threshold[ 1 ] or X > threshold[ 2 ], assign 1, zero otherwise. 6. "><": if threshold[ 1 ] < X < threshold[ 2 ], assign 1, zero otherwise. 7. "=<>": if threshold[ 1 ] <= X or X > threshold[ 2 ], assign 1, zero otherwise. 8. "<>=": if threshold[ 1 ] < X or X >= threshold[ 2 ], assign 1, zero otherwise. 9. "=<>=": if X <= threshold[ 1 ] or X >= threshold[ 2 ], assign 1, zero otherwise. 10. "=><": if threshold[ 1 ] <= X < threshold[ 2 ], assign 1, zero otherwise. 11. "><=": if threshold[ 1 ] < X <= threshold[ 2 ], assign 1, zero otherwise. 12. "=><=": if threshold[ 1 ] <= X <= threshold[ 2 ], assign 1, zero otherwise.

Value

A list object with two components is returned with the first component being the binary version of X and the second that for Xhat. These fields will either be matrices of the same dimension as X and Xhat or they will be owin objects depending on the value argument.

Author(s)

Eric Gilleland

See Also

thresholder, im, solutionset

Examples

data( "obs0601" )
data( "wrf4ncar0531" )
bin <- binarizer( X = obs0601, Xhat = wrf4ncar0531, threshold = 2.1 )

image.plot( bin[[ 1 ]] )
image.plot( bin[[ 2 ]] )

bin2 <- binarizer( X = obs0601, Xhat = wrf4ncar0531,
		  threshold = 2.1, value = "owin" )
plot( bin2[[ 1 ]] )
plot( bin2[[ 2 ]] )


[Package SpatialVx version 1.0-2 Index]