Learn R Programming

imager (version 0.31)

imager.combine: Combining images

Description

These functions take a list of images and combine them by adding, multiplying, taking the parallel min or max, etc. The max. in absolute value of (x1,x2) is defined as x1 if (|x1| > |x2|), x2 otherwise. It's useful for example in getting the most extreme value while keeping the sign.

Usage

add(x)
average(x)
mult(x)
parmax(x)
parmax.abs(x)
parmin.abs(x)
parmin(x)
enorm(x)
which.parmax(x)
which.parmin(x)

Arguments

x
a list of images

Functions

  • add: Add images
  • average: Average images
  • mult: Multiply images (pointwise)
  • parmax: Parallel max over images
  • parmax.abs: Parallel max in absolute value over images,
  • parmin.abs: Parallel max in absolute value over images,
  • parmin: Parallel min over images
  • enorm: Euclidean norm (i.e. sqrt(A^2 + B^2 + ...))
  • which.parmax: index of parallel maxima
  • which.parmin: index of parallel minima

See Also

imsplit,Reduce

Examples

Run this code
im1 <- as.cimg(function(x,y) x,100,100)
im2 <- as.cimg(function(x,y) y,100,100)
im3 <- as.cimg(function(x,y) cos(x/10),100,100)
l <- list(im1,im2,im3)
add(l) %>% plot #Add the images
average(l) %>% plot #Average the images
mult(l) %>% plot #Multiply
parmax(l) %>% plot #Parallel max
parmin(l) %>% plot #Parallel min
#Edge detection
imgradient(boats,"xy") %>% enorm %>% plot
#Pseudo-artistic effects
llply(seq(1,35,5),function(v) boxblur(boats,v)) %>% parmin %>% plot
llply(seq(1,35,5),function(v) boxblur(boats,v)) %>% average %>% plot

#At each pixel, which colour channel has the maximum value?
imsplit(boats,"c") %>% which.parmax %>% table

Run the code above in your browser using DataLab