Description Usage Arguments Details Value Note Author(s) References Examples
Functions to perform morphological operations on binary and grayscale images.
1 2 3 4 5 6 7 8 9 | dilate(x, kern)
erode(x, kern)
opening(x, kern)
closing(x, kern)
whiteTopHat(x, kern)
blackTopHat(x, kern)
selfComplementaryTopHat(x, kern)
makeBrush(size, shape=c('box', 'disc', 'diamond', 'Gaussian', 'line'), step=TRUE, sigma=0.3, angle=45)
|
x |
An |
kern |
An |
size |
A numeric containing the size of the brush in pixels. This should be an odd number; even numbers are rounded to the next odd one, i.e., |
shape |
A character vector indicating the shape of the brush. Can
be |
step |
a logical indicating if the brush is binary. Default is
|
sigma |
An optional numeric containing the standard deviation of
the |
angle |
An optional numeric containing the angle at which the line should be drawn. The angle is one between the top of the image and the line. |
dilate
applies the mask kern
by positioning its center over every pixel of the
image x
, the output value of the pixel is the maximum value of x
covered by the mask. In case of binary images this is equivalent of putting the mask over every background pixel, and setting it to foreground if any of the pixels covered by the mask is from the foreground.
erode
applies the mask kern
by positioning its center over every pixel of the
image x
, the output value of the pixel is the minimum value of x
covered by the mask. In case of binary images this is equivalent of putting the mask over every foreground pixel, and setting it to background if any of the pixels covered by the mask is from the background.
opening
is an erosion followed by a dilation and closing
is a dilation followed by an erosion.
whiteTopHat
returns the difference between the original image x
and its opening by the structuring element kern
.
blackTopHat
subtracts the original image x
from its closing by the structuring element kern
.
selfComplementaryTopHat
is the sum of the whiteTopHat
and the blackTopHat
, simplified
the difference between the closing
and the opening
of the image.
makeBrush
generates brushes of various sizes and shapes that can be used
as structuring elements.
Morphological functions position the center of the structuring element over each pixel in the input image. For pixels close to the edge of an image, parts of the neighborhood defined by the structuring element may extend past the border of the image. In such a case, a value is assigned to these undefined pixels, as if the image was padded with additional rows and columns. The value of these padding pixels varies for dilation and erosion operations. For dilation, pixels beyond the image border are assigned the minimum value afforded by the data type, which in case of binary images is equivalent of setting them to background. For erosion, pixels beyond the image border are assigned the maximum value afforded by the data type, which in case of binary images is equivalent of setting them to foreground.
dilate
, erode
, opening
, whiteTopHat
, blackTopHat
and
selfComplementaryTopHat
return the transformed Image
object
or array x
, after the corresponding morphological operation.
makeBrush
generates a 2D matrix containing the desired brush.
Morphological operations are implemented using the efficient Urbach-Wilkinson algorithm [1]. Its required computing time is independent of both the image content and the number of gray levels used.
Ilia Kats <ilia-kats@gmx.net> (2012), Andrzej Oles <andrzej.oles@embl.de> (2015)
[1] E. R. Urbach and M.H.F. Wilkinson, "Efficient 2-D grayscale morphological transformations with arbitrary flat structuring elements", IEEE Trans Image Process 17(1), 1-8, 2008
1 2 3 4 5 6 7 8 9 10 11 12 13 |
x = readImage(system.file("images", "shapes.png", package="EBImage"))
kern = makeBrush(5, shape='diamond')
display(x)
display(kern, title='Structuring element')
display(erode(x, kern), title='Erosion of x')
display(dilate(x, kern), title='Dilatation of x')
## makeBrush
display(makeBrush(99, shape='diamond'))
display(makeBrush(99, shape='disc', step=FALSE))
display(2000*makeBrush(99, shape='Gaussian', sigma=10))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.