
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. "parsort","parrank" and "parorder" aren't really reductions because they return a list of the same size. They perform a pixel-wise sort (resp. order and rank) across the list. parvar returns an unbiased estimate of the variance (as in the base var function). parsd returns the square root of parvar.
add(x, na.rm = FALSE)wsum(x, w, na.rm = FALSE)
average(x, na.rm = FALSE)
mult(x, na.rm = FALSE)
parmax(x, na.rm = FALSE)
parmax.abs(x)
parmin.abs(x)
parmin(x, na.rm = FALSE)
enorm(x)
parmed(x, na.rm = FALSE)
parvar(x, na.rm = FALSE)
parsd(x, na.rm = FALSE)
parall(x)
parany(x)
equal(x)
which.parmax(x)
which.parmin(x)
parsort(x, increasing = TRUE)
parorder(x, increasing = TRUE)
parrank(x, increasing = TRUE)
a list of images
ignore NAs (default FALSE)
weights (must be the same length as the list)
if TRUE, sort in increasing order (default TRUE)
add
: Add images
wsum
: Weighted sum of 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 min in absolute value over images,
parmin
: Parallel min over images
enorm
: Euclidean norm (i.e. sqrt(A^2 + B^2 + ...))
parmed
: Median
parvar
: Variance
parsd
: Std. deviation
parall
: Parallel all (for pixsets)
parany
: Parallel any (for pixsets)
equal
: Test equality
which.parmax
: index of parallel maxima
which.parmin
: index of parallel minima
parsort
: pixel-wise sort
parorder
: pixel-wise order
parrank
: pixel-wise rank
imsplit,Reduce
# NOT RUN {
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 <- imlist(im1,im2,im3)
add(l) %>% plot #Add the images
average(l) %>% plot #Average the images
mult(l) %>% plot #Multiply
wsum(l,c(.1,8,.1)) %>% plot #Weighted sum
parmax(l) %>% plot #Parallel max
parmin(l) %>% plot #Parallel min
parmed(l) %>% plot #Parallel median
parsd(l) %>% plot #Parallel std. dev
#parsort can also be used to produce parallel max. and min
(parsort(l)[[1]]) %>% plot("Parallel min")
(parsort(l)[[length(l)]]) %>% plot("Parallel max")
#Edge detection (Euclidean norm of gradient)
imgradient(boats,"xy") %>% enorm %>% plot
#Pseudo-artistic effects
l <- map_il(seq(1,35,5),~ boxblur(boats,.))
parmin(l) %>% plot
average(l) %>% plot
mult(l) %>% plot
#At each pixel, which colour channel has the maximum value?
imsplit(boats,"c") %>% which.parmax %>% table
#Same thing using parorder (ties are broken differently)!!!
imsplit(boats,"c") %>% { parorder(.)[[length(.)]] } %>% table
# }
Run the code above in your browser using DataLab