image_modify_local: Modify Only a Subregion of an Image

Description Usage Arguments

View source: R/image_modify_local.R

Description

The function allows you to modify a subregion of your image (or, the opposite, keep the subregion unchanged while modifying other parts). You can set the four sides of the subregion or an irregular polygon by mouse click. If it is irregular, you MUST click in order.

Usage

1
2
3
4
5
6
7
8
9
image_modify_local(
  x,
  FUN,
  geometry = "click",
  local = "local",
  rectangle = TRUE,
  trim = FALSE,
  ...
)

Arguments

x

an image read into R by magick::image_read or an image modified by functions in the magick package.

FUN

the function used to modify x. NOTE: the result of FUN must be of the same class as x and its width and height must not be changed during modification.

geometry

this parameter is different from the one used in package magick. Here, in this function, you can set geometry = "click" if you want to show which part you want to modify by mouse click (see function image_crop_click for how to use mouse click). Otherwise, you can use a length 4 vector with the exact order: left, right, top, bottom.

local

if it is 1 or "local", only a subregion of your image will be modified. If it is 2 or "other", keep the subregion unchanged while modifying other parts. If it is 3 or "subregion", the result is only the modified subregion, not the whole image.

rectangle

if it is TRUE (default), the subregion is a rectangle. If it is FALSE, the subregion can be an irregular polygon designated by your mouse click.

trim

whether to trim the subregion. This is only used when local is 3 or "subregion". It helps remove the transparent parts. See image_crop_click to know how to use this parameter.

...,

extra parameters used by FUN.


plothelper documentation built on July 2, 2020, 4:03 a.m.