Learn R Programming

Rvision (version 0.4.2)

morph: Morphological Operations

Description

morph applies various morphological operations (see Note) to an Image object.

Usage

morph(
  image,
  operation,
  kernel = NULL,
  k_shape = "rectangle",
  k_height = 5,
  k_width = 5,
  iterations = 1,
  in_place = FALSE
)

Arguments

image

An Image object.

operation

A string corresponding to the name of a morphological operation to apply to the image (see Note).

kernel

A binary matrix. If the matrix is not binary, all positive values will be automatically converted to 1, all negative values to 0, unless operation = "hitmiss" in which case they will be converted to -1.

k_shape

A string corresponding to the shape of the kernel for the morphological operation (see Note; default: "rectangle"). Ignored if a custom kernel is provided.

k_height

The half-height in pixels of the kernel. Ignored if a custom kernel is provided.

k_width

The half-width in pixels of the kernel. Ignored if a custom kernel is provided.

iterations

The number of times the morphological operations should be applied.

in_place

A logical indicating whether the change should be applied to the image itself (TRUE, faster but destructive) or to a copy of it (FALSE, the default, slower but non destructive).

Value

An Image object if in_place=FALSE. Otherwise, it returns nothing and modifies image in place.

See Also

Image

Examples

Run this code
# NOT RUN {
balloon <- image(system.file("sample_img/balloon1.png", package = "Rvision"))
balloon_eroded <- morph(balloon, "erode")
plot(balloon_eroded)

# }

Run the code above in your browser using DataLab