patch: Patch colour

Description Usage Arguments Value Examples

View source: R/patch.R

Description

Get the median (or mean or user-defined function) colour value of a specified patch of pixels on an image. This is useful for matching background colours.

Usage

1
2
3
4
5
6
7
8
9
patch(
  img,
  x1 = 1,
  x2 = 10,
  y1 = 1,
  y2 = 10,
  color = c("hex", "rgb"),
  func = stats::median
)

Arguments

img

The image

x1

starting x pixel of patch

x2

ending x pixel of patch

y1

starting y pixel of patch

y2

ending y pixel of patch

color

The type of color to return (hex, rgb)

func

The function to apply to an array of rgba values to determine the central colour (defaults to median)

Value

hex or rgba color value

Examples

1
patch(demo_stim()[[1]]$img)

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