Skip to contents

In Place Logical Operators for Images

Usage

e1 %i&% e2

e1 %i|% e2

not(image, target = "new")

Arguments

e1, e2

Either 2 Image objects or 1 Image object and 1 numeric value/vector. If a vector and its length is less than the number of channels of the image, then it is recycled to match it.

image

An Image object.

target

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

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

  • "self":the results are stored back into image (faster but destructive).

  • An Image object:the results are stored in another existing Image object. This is fast and will not replace the content of image but will replace that of target. Note that if target does not have the same dimensions, number of channels, and bit depth as image, an error may be thrown.

Value

The operators do not return anything. They modify the image in place (destructive operation). If 2 images are passed to the operators, only the one of the left side of the operator is modified; the other is left untouched.

If target="new", not returns an Image object. If

target="self", not returns nothing and modifies image

in place. If target is an Image object, not

returns nothing and modifies that Image object in place.

Note

R does not support the creation of custom unary operators. This is why there is no !-like operator but the not function instead.

See also

Author

Simon Garnier, garnier@njit.edu

Examples

balloon1 <- image(system.file("sample_img/balloon1.png", package = "Rvision"))
balloon2 <- image(system.file("sample_img/balloon2.png", package = "Rvision"))
balloon1 %i|% balloon2
not(balloon2)
#> Class: image. 
#> Dimensions: 640x360.
#> Type: BGR, 3-channel, 8U.
#> GPU: FALSE.