morph | R Documentation |
morph
applies various morphological operations (see Note)
to an Image
object.
morph(
image,
operation,
kernel = NULL,
k_shape = "rectangle",
k_height = 5,
k_width = 5,
iterations = 1,
target = "new",
in_place = NULL
)
image |
An |
operation |
A string corresponding to the name of a morphological operation to apply to the image (see Note). |
kernel |
A binary matrix. |
k_shape |
A string corresponding to the shape of the kernel for the
morphological operation (see Note; default: "rectangle"). Ignored if a
custom |
k_height |
The half-height in pixels of the kernel. Ignored if a custom
|
k_width |
The half-width in pixels of the kernel. Ignored if a custom
|
iterations |
The number of times the morphological operations should be applied. |
target |
The location where the results should be stored. It can take 3 values:
|
in_place |
Deprecated. Use |
If target="new"
, the function returns an Image
object. If target="self"
, the function returns nothing and modifies
image
in place. If target
is an Image
object,
the function returns nothing and modifies that Image
object in
place.
There are 8 types of morphological operations that can be achieved with this function:
"erode":for each point, returns the minimum of the points in its neighborhood, with that neighborhood defined by the kernel.
"dilate":for each point, returns the maximum of the points in its neighborhood, with that neighborhood defined by the kernel.
"open":erosion followed by dilation.
"close":dilation followed by erosion.
"gradient":difference between the dilation and the erosion of an image.
"tophat":difference between an input image and its opening.
"blackhat":difference between the closing and its input image.
"hitmiss":(1) erodes the image with kernel > 0
; (2) erodes
the complement of the image with kernel < 0
; (3) returns the
intersection (AND
) of step 1 and step 2. The hit-or-miss transform
is the basis of more advanced morphological operations such as thinning
or pruning.
There are 3 types of predetermined kernel shapes that can be used with
this function when a custom kernel
is not provided:
"rectangle" (the default):
"cross"
"ellipse"
Simon Garnier, garnier@njit.edu
Image
balloon <- image(system.file("sample_img/balloon1.png", package = "Rvision"))
balloon_eroded <- morph(balloon, "erode")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.