image_segment_mask: Segment an 'Image' object using a brush mask

View source: R/utils_mask.R

image_segment_maskR Documentation

Segment an Image object using a brush mask

Description

It combines make_mask() and make_brush() to segment an Image object using a brush of desired size, shape, and position.

Usage

image_segment_mask(
  img,
  size,
  shape = "disc",
  rel_pos_x = 0.5,
  rel_pos_y = 0.5,
  type = c("binary", "shadow"),
  col_background = "white",
  plot = TRUE,
  ...
)

Arguments

img

A Image object

size

A numeric containing the size of the brush in pixels. This should be an odd number; even numbers are rounded to the next odd one.

shape

A character vector indicating the shape of the brush. Can be "box", "disc", "diamond", "Gaussian" or "line" Defaults to "disc".

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.

type

Defines the type of the mask. By default, a binary mask is applied. This results in white pixels in the original image that matches the 0s pixels in the brush. If type = "shadow" is used, a shadow mask is produced

col_background

Background color after image segmentation. Defaults to "white".

plot

Plots the generated mask? Defaults to TRUE.

...

Further arguments passed on to EBImage::makeBrush().

Value

A color Image object

Examples

img <- image_pliman("soybean_touch.jpg")
plot(img)
image_segment_mask(img, size = 601)
image_segment_mask(img,
                   size = 401,
                   shape = "diamond",
                   rel_pos_x = 0,
                   rel_pos_y = 0,
                   type = "shadow")

pliman documentation built on Oct. 15, 2023, 1:06 a.m.