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)
Imageobject or an array.
Imageobject or an array, containing the structuring element.
kernis considered as a binary image, with pixels of value 0 being the background and pixels with values other than 0 being the foreground.
size = 4has the same effect as
size = 5. Default is 5
line. Default is
TRUE. This argument is relevant only for the
Gaussianshape. Default is 0.3.
selfComplementaryTopHatreturn the transformed
Imageobject or array
x, after the corresponding morphological operation.
makeBrushgenerates a 2D matrix containing the desired brush.
dilateapplies the mask
kernby positioning its center over every pixel of the image
x, the output value of the pixel is the maximum value of
xcovered 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
x, the output value of the pixel is the minimum value of
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
blackTopHat subtracts the original image
x from its closing by the structuring element
selfComplementaryTopHat is the sum of the
whiteTopHat and the
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.
Processing Pixels at Image Borders (Padding Behavior) 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.
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))