| morphology {EBImage} | R Documentation |
Functions to perform morphological operations on binary images.
dilate(x, kern)
erode(x, kern)
opening(x, kern)
closing(x, kern)
dilateGreyScale(x, kern)
erodeGreyScale(x, kern)
openingGreyScale(x, kern)
closingGreyScale(x, kern)
whiteTopHatGreyScale(x, kern)
blackTopHatGreyScale(x, kern)
selfcomplementaryTopHatGreyScale(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 Gaussian shape. Default is 0.3. |
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 positioning its centre over every background pixel
(0), every pixel which is not covered by the mask is reset to foreground (1).
erode applies the mask positioning its centre over every foreground pixel
(!=0), every pixel which is not covered by the mask is reset to background (0).
opening is an erosion followed by a dilation and closing is a dilation
followed by an erosion. The same goes for the greyscale versions.
dilateGreyScale applies the mask positioning its centre over every pixel of the
Image, the output value of the pixel is the maximum value of the Image
covered by the mask.
erodeGreyScale applies the mask positioning its centre over every pixel of the
Image, the output value of the pixel is the minimum value of the Image
covered by the mask.
whiteTopHatGreyScale substracts the opening of the Image from the Image
blackTopHatGreyScale substracts the Image from the closing of the Image
selfcomplementaryTopHatGreyScale is the sum of a white top-hat and a black top-hat, simplified
the difference between closing and opening of the Image
makeBrush generates brushes of various sizes and shapes that can be used
as structuring elements.
Operations on greyscale images use an implementation of the Urbach-Wilkinson algorithm[1] and can only handle flat (i.e. binary) brushes.
dilate, erode, opening, closing, dilateGreyScale,
erodeGreyScale, openingGreyScale, closingGreyScale,
whiteTopHatGreyScale, blackTopHatGreyScale and
selfcomplementaryTopHatGreyScale return the transformed Image object
or array, after the corresponding morphological operation.
makeBrush generates a 2D matrix containing the desired brush.
Oleg Sklyar, osklyar@ebi.ac.uk, 2006 Ilia Kats, ilia-kats@gmx.net, 2012
[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
x = readImage(system.file("images", "shapes.png", package="EBImage"))
kern = makeBrush(5, shape='diamond')
if (interactive()) {
display(x)
display(kern, title='Structuring element')
display(erode(x, kern), title='Erosion of x')
display(dilate(x, kern), title='Dilatation of x')
}
## makeBrush
if (interactive()) {
display(makeBrush(99, shape='diamond'))
display(makeBrush(99, shape='disc', step=FALSE))
display(2000*makeBrush(99, shape='gaussian', sigma=10))
}