Compute the unbalanced or balanced Wasserstein distance between two kanjimat objects
Source:R/kanji2.R
kmatdist.Rd
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.
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 thep
-th root after summation).- C
the penalty for extra mass if
type="unbalanced"
, i.e. we addC^p
per unit of extra mass (before applying thep
-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 costC^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.- output
the requested output. See return value below.
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.