RNotes | EBImage


library(EBImage)

Morphological Operations

Example

par(mfrow=c(1,5))
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

par(mfrow=c(1,3))
display(makeBrush(99, shape='diamond'))
display(makeBrush(99, shape='disc', step=FALSE))
display(2000*makeBrush(99, shape='Gaussian', sigma=10))

Example 2

From Introduction to EBImage by Andrzej Oles et al, Dec. 3, 2014.

Binary images are images where the pixels of value 0 constitute the background and the other ones constitute the foreground. These images are subject to several non-linear mathematical operators called morphological operators, able to erode and dilate an image.

ei <- readImage(system.file('images', 'shapes.png', package='EBImage'))
ei <- ei[110:512,1:130]
display(ei, title="Figure 10: ei")

eierode, eidilat

kern <- makeBrush(5, shape='diamond')
eierode <- erode(ei, kern)
display(eierode, title="eierode")

eierode, eidilat

eidilat <- dilate(ei, kern)
display(eidilat, title="eidilat")

eierode, eidilat


packageVersion("EBImage")
## [1] '4.8.2'

efg
2015-01-18 2014