Learn R Programming

imager (version 0.42.19)

imchange: Modify parts of an image

Description

A shortcut for modifying parts of an image, using imeval syntax. See doc for imeval first. As part of a pipe, avoids the creating of intermediate variables.

Usage

imchange(obj, where, fo, env = parent.frame())

Value

a modified image

Arguments

obj

an image or imlist

where

where to modify. a pixset, or a formula (in imeval syntax) that evaluates to a pixset.

fo

a formula (in imeval syntax) used to modify the image part

env

evulation environment (see imeval)

Author

Simon Barthelme

See Also

imeval

Examples

Run this code
#Set border to 0:
imchange(boats,px.borders(boats,10),~ 0) %>% plot
#Eq. to
im <- boats
im[px.borders(im,10)] <- 0
#Using formula syntax
imchange(boats,~ px.borders(.,10),~ 0)
#Replace with grayscale ramp
imchange(boats,~ px.borders(.,10),~ xs) %>% plot
#Kill red channel in image
imchange(boats,~ c==1,~ 0) %>% plot
#Shit hue by an amount depending on eccentricity
load.example("parrots") %>%
  RGBtoHSL %>%
  imchange(~ c==1,~ .+80*exp(-(rho/550)^2) ) %>%
  HSLtoRGB %>%
  plot

Run the code above in your browser using DataLab