| imagebary | R Documentation |
Using exact balanced optimal transport as a subroutine,
imagebary computes an unregularized 2-Wasserstein barycenter image
X^\star from multiple input images X_1,\ldots,X_N.
Unlike the other image barycenter routines, this function does not use
entropic regularization. Instead, it solves the barycenter problem with a
robust first-order method based on mirror descent on the probability simplex.
imagebary(images, p = 2, weights = NULL, C = NULL, ...)
images |
a length- |
p |
an exponent for the order of the distance (default: 2). Currently, only |
weights |
a weight of each image; if |
C |
an optional |
... |
extra parameters including
|
The algorithm treats each image as a discrete probability distribution on a
common (m\times n) grid. At each iteration, it computes exact OT dual
potentials u_i between the current barycenter iterate and each input
image via util_dual_emd_C. These dual potentials form a valid subgradient
of the barycenter objective, and a KL-mirror descent step produces a strictly
positive update of the barycenter weights. For numerical stability, the
implementation includes (i) centering of dual potentials (shift invariance),
(ii) gradient clipping, (iii) log-domain normalization, and (iv) optional
smoothing/backtracking safeguards to avoid infeasible OT calls.
an (m\times n) matrix of the barycentric image.
## Not run:
#----------------------------------------------------------------------
# MNIST Data with Digit 3
#
# small example to compare the un- and regularized problem solutions
# choose only 10 images and run for 20 iterations with default penalties
#----------------------------------------------------------------------
# LOAD DATA
set.seed(11)
data(digit3)
dat_small = digit3[sample(1:2000, 10)]
# RUN
run_exact = imagebary(dat_small, maxiter=20)
run_reg14 = imagebary14C(dat_small, maxiter=20)
run_reg15 = imagebary15B(dat_small, maxiter=20)
# VISUALIZE
opar <- par(no.readonly=TRUE)
par(mfrow=c(1,3), pty="s")
image(run_exact, axes=FALSE, main="Unregularized")
image(run_reg14, axes=FALSE, main="Cuturi & Doucet (2014)")
image(run_reg15, axes=FALSE, main="Benamou et al. (2015)")
par(opar)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.