mask: Mask Images with templates

Description Usage Arguments Details Value Examples

View source: R/mask.R

Description

Create a mask using template points.

Usage

1
2
3
4
5
6
7
8
mask(
  stimuli,
  mask = "face",
  fill = webmorph_options("fill"),
  reverse = FALSE,
  expand = 1,
  tem_id = "FRL"
)

Arguments

stimuli

list of class stimlist

mask

vector of masks or a custom list of template points

fill

color to make the mask

reverse

if TRUE, the mask covers the listed areas

expand

how many pixels to expand the mask

tem_id

template ID to pass on to tem_def to get built-in mask definitions, usually one of "FRL", "fpp106" or "fpp83"

Details

For FRL templates, the argument mask can be a vector with one or more of the following: oval, face, neck, ears (left_ear, right_ear), eyes (left_eye, right_eye), brows (left_brow, right_brow), mouth, teeth, nose.

For Face++ templates (fpp83 or fpp106), the argument mask can be a vector with one or more of the following: face, eyes (left_eye, right_eye), brows (left_brow, right_brow), mouth, teeth, nose. Because these templates have no forehead points, "face" is usually disappointing.

Set custom masks using the template points (0-based). View an image with labelled templates using plot(stim, pt.plot = TRUE, pt.shape="index"). Separate points along a line with commas, line segments with semicolons, and mask areas with colons. For example, this would be the custom mask for the eyes in the fpp83 template:

"44,4,56,51,79;79,58,11,25,44:61,67,38,34,40;40,41,17,47,61"

If you set expand = 0, there is sometimes a thin visible line where multiple components of the mask touch.

Value

stimlist with masked images

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
stimuli <- demo_stim()
masked <- mask(stimuli, c("face", "neck", "ears"), "red")
plot(masked)

revmasked <- mask(stimuli, "eyes", "#FFFF00", TRUE) %>%
  mask("brows", "purple", TRUE) %>%
  mask("nose", "#FF000066", TRUE) %>%
  mask("mouth", "blue", TRUE)
plot(revmasked)

masked_fpp <- demo_stim("lisa")  %>%
  crop_pad() %>%
  mask(mask = c("face"), tem_id = "fpp106")
plot(masked_fpp)

facelab/webmorph documentation built on April 11, 2021, 6:34 a.m.