trimMask | R Documentation |
Remove large and small objects from an integer Image
mask,
remove objects that are near the edge of the image, and remove
eccentric objects.
trimMask(
mask,
cutoff = FALSE,
k = c(1.5, 3),
border = 0,
brush = 0,
ecc.max = 1,
reenumerate = TRUE
)
mask |
Object mask or list of masks with connected pixels having the same integer value. |
cutoff |
Optional integer value of length 1 or 2 specifying the
limits for the area in pixels. If only one value is provided, it
is assumed to be the lower limit. A value of |
k |
Numeric value of length 2 specifying the lower and upper
multiplier to determine the cutoff from the |
border |
Objects within this many pixels of the edge will be excluded. |
brush |
After coercion to the nearest odd integer, values > 0
|
ecc.max |
Exclude objects with elliptical eccentricity greater than this value. |
reenumerate |
Logical value (default of TRUE) passed to rmObjects() to re-enumerate the objects after trimming. |
For each non-NA
value in cutoff
, objects smaller than
cutoff[1]
and larger than cutoff[2]
will be removed.
Otherwise, objects smaller than median(area) - k[1]*mad(area)
and
larger than median(area)+ k[2]*mad(area)
will be removed. Objects
that are within border
pixels of the edge will be removed. Objects
that have eccentricity greater than ecc.max
will be removed. A circle
has eccentricity of 0 and a straight line has eccentricity of 1. Note
that EBImage provides a poor approximation of this value. The final mask
will be dilated or eroded if brush
is non-zero using a disc-shaped
brush with size determined by the adjusted value of brush
.
Object mask or list of masks with objects removed and re-enumerated.
x <- readImage(system.file("extdata", "by_folder/a1/file001.tif", package = "virustiter"))
xm <- nucMask(x)
xm2 <- trimMask(xm, cutoff = c(200, 400))
xm3 <- trimMask(xm, border = 24)
xm4 <- trimMask(xm, ecc.max = 0.75)
plot(colorLabels(combine(xm, xm2, xm3, xm4)), all = TRUE)
sapply(list(xm, xm2, xm3, xm4), max) # how many remain?
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.