Skip to contents

inRange performs range thresholding on an Image object. Pixels which values are within the desired range are turned white while pixels which values are outside are turned black. This operation is performed separately on each channel for multi-channel images.

Usage

inRange(image, low = 0, up = 255, target = "new")

Arguments

image

An Image object.

low

A vector indicating the inclusive lower end of the thresholding range. It can have as many elements as the number of channels in the image. If it has less elements than the number of channels, it is recycled to match the number of channels. If it has more elements than the number of channels, the extra elements are ignored without warning (default: 0).

up

A vector indicating the inclusive upper end of the thresholding range. Itcan have as many elements as the number of channels in the image. If it has less elements than the number of channels, it is recycled to match the number of channels. If it has more elements than the number of channels, the extra elements are ignored without warning (default: 255).

target

The location where the results should be stored. It can take 2 values:

"new":

a new Image object is created and the results are stored inside (the default).

An Image object:

the results are stored in another existing Image object. In this case, target must be a single channel image with an 8U bit depth. Note that this will replace the content of target.

Value

If target="new", the function returns an Image object. If target is an Image object, the function returns nothing and modifies that Image object in place.

An Image object.

See also

Author

Simon Garnier, garnier@njit.edu

Examples

balloon <- image(system.file("sample_img/balloon1.png", package = "Rvision"))
bw <- inRange(balloon, low = c(10, 20, 30), up = c(120, 130, 140))