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)
image | An |
---|---|
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
|
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. |
An Image
object.
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
# TODO