clean: Clean up and fill in pixel sets (morphological opening and...

Description Usage Arguments Functions Author(s) Examples

View source: R/pixset.R

Description

Cleaning up a pixel set here means removing small isolated elements (speckle). Filling in means removing holes. Cleaning up can be achieved by shrinking the set (removing speckle), followed by growing it back up. Filling in can be achieved by growing the set (removing holes), and shrinking it again.

Usage

1
2
3
clean(px, ...)

fill(px, ...)

Arguments

px

a pixset

...

parameters that define the structuring element to use, passed on to "grow" and "shrink"

Functions

Author(s)

Simon Barthelme

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
im <- load.example("birds") %>% grayscale
sub <- imsub(-im,y> 380) %>% threshold("85%")
plot(sub)
#Turn into a pixel set
px <- sub==1
layout(t(1:2))
plot(px,main="Before clean-up")
clean(px,3) %>% plot(main="After clean-up")
#Now fill in the holes
px <- clean(px,3)
plot(px,main="Before filling-in")
fill(px,28) %>% plot(main="After filling-in")

imager documentation built on May 30, 2018, 9:04 a.m.