Skip to contents

Make a mask using an Image object and a brush.

Usage

make_mask(img, brush, rel_pos_x = 0.5, rel_pos_y = 0.5, plot = TRUE)

Arguments

img

A Image object

brush

An object created with make_brush()

rel_pos_x, rel_pos_y

A relative position to include the brush in the image. Defaults to 0.5. This means that the brush will be centered in the original image. Smaller values move the brush toward the left and top, respectively.

plot

Plots the generated mask? Defaults to TRUE.

Value

A binary image with 0s and 1s.

Details

It applies a brush to an Image, selecting the Image pixels that match the brush values equal to 1. The position of the brush in the original image is controlled by the relative positions x (rel_pos_x) and y (rel_pos_y) arguments. The size of the brush must be smaller or equal to the smaller dimension of image.

Examples

img <- image_pliman("soybean_touch.jpg")
make_mask(img, brush = make_brush(size = 201))

make_mask(img,
          brush = make_brush(size = 401, shape = "diamond"),
          rel_pos_x = 0.1,
          rel_pos_y = 0.8)