kmatdist: Compute the unbalanced or balanced Wasserstein distance between two kanjimat objects
Description
This gives the dissimilarity of pixel-images of the kanji based on how far mass (or "ink") has to be
transported to transform one image into the other.
Usage
kmatdist(
k1,
k2,
p = 1,
C = 0.2,
type = c("unbalanced", "balanced"),
output = c("dist", "all")
)
Value
If output = "dist", a single non-negative number: the unbalanced or balanced Wasserstein
distance between the kanji. If output = "all" a list with detailed information on the transport plan
and the disposal of pixel mass. See unbalanced for details.
Arguments
k1, k2
two objects of type kanjimat.
p
the order of the Wasserstein distance. All distances and a potential penalty are taken
to the p-th power (which is compensated by taking the p-th root after summation).
C
the penalty for extra mass if type="unbalanced", i.e. we add C^p per unit
of extra mass (before applying the p-th root).
type
the type of Wasserstein metric. "unbalanced" means the pixel values in the two images are
interpreted as mass. The total masses can be very different. Extra mass can be disposed of at cost C^p
per unit. "balanced" means the pixel values are normalized so that both images have the same total
mass 1. Everything has to be transported, i.e. disposal of mass is not allowed.