Skip to contents

Given multiple images \(X_1,\ldots,X_N\), the Wasserstein median of order 2 is computed. The proposed method relies on a choice of barycenter computation in that we opt for an algorithm of imagebary15B, which uses entropic regularization for barycenter computation. Please note the followings; (1) we only take a matrix as an image so please make it grayscale if not, (2) all images should be of same size - no resizing is performed.

Usage

imagemed22Y(images, weights = NULL, lambda = NULL, ...)

Arguments

images

a length-\(N\) list of same-size image matrices of size \((m\times n)\).

weights

a weight of each image; if NULL (default), uniform weight is set. Otherwise, it should be a length-\(N\) vector of nonnegative weights.

lambda

a regularization parameter; if NULL (default), a paper's suggestion would be taken, or it should be a nonnegative real number.

...

extra parameters including

abstol

stopping criterion for iterations (default: 1e-8).

init.image

an initial weight image (default: uniform weight).

maxiter

maximum number of iterations (default: 496).

nthread

number of threads for OpenMP run (default: 1).

print.progress

a logical to show current iteration (default: TRUE).

Value

an \((m\times n)\) matrix of the Wasserstein median image.

Examples

if (FALSE) {
#----------------------------------------------------------------------
#                       MNIST Data with Digit 3
#
# EXAMPLE : Very Small Example for CRAN; just showing how to use it!
#----------------------------------------------------------------------
# LOAD THE DATA
data(digit3)
datsmall = digit3[1:10]
 
# COMPUTE
outsmall = imagemed22Y(datsmall, maxiter=5)

# VISUALIZE
opar <- par(no.readonly=TRUE)
par(mfrow=c(1,4), pty="s")
image(outsmall, xaxt='n', yaxt='n', main="Wasserstein Median")
image(datsmall[[3]], xaxt='n', yaxt='n', main="3rd image")
image(datsmall[[6]], xaxt='n', yaxt='n', main="6th image")
image(datsmall[[9]], xaxt='n', yaxt='n', main="9th image")
par(opar)
}