morphology {EBImage}R Documentation

Perform morphological operations on images

Description

Functions to perform morphological operations on binary images.

Usage

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)

Arguments

x

An Image object or an array. x is considered as a binary image, whose pixels of value 0 are considered as background ones and other pixels as foreground ones.

kern

An Image object or an array, containing the structuring element. kern is considered as a binary image, whose pixels of value 0 are considered as background ones and other pixels as foreground ones.

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., size = 4 has the same effect as size = 5. If shape is line, size represents the length of the line.

shape

A character vector indicating the shape of the brush. Can be box, disc, diamond, gaussian or line. Default is box.

step

a logical indicating if the brush is binary. Default is TRUE. The argument is relevant only for the disc and diamond shapes.

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.

Details

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.

Value

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.

Author(s)

Oleg Sklyar, osklyar@ebi.ac.uk, 2006 Ilia Kats, ilia-kats@gmx.net, 2012

References

[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

Examples

	
  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))
  }

[Package EBImage version 4.4.0 Index]