getColorDistanceMatrix {colordistance} | R Documentation |
Distance matrix for a list of color cluster sets
Description
Calculates a distance matrix for a list of color cluster sets as returned by
extractClusters
or getHistList
based on the
specified distance metric.
Usage
getColorDistanceMatrix(
cluster.list,
method = "emd",
ordering = "default",
size.weight = 0.5,
color.weight = 0.5,
plotting = TRUE,
...
)
Arguments
cluster.list |
A list of identically sized dataframes with 4 columns each
(R, G, B, Pct or H, S, V, Pct) as output by |
method |
One of four possible comparison methods for calculating the
color distances: |
ordering |
Logical if not left as "default". Should the color clusters
in the list be reordered to minimize the distances between the pairs? If
left as default, ordering depends on distance method: "emd" and "chisq" do
not order clusters ("emd" orders on a case-by-case in the
|
size.weight |
Same as in |
color.weight |
Same as in |
plotting |
Logical. Should a heatmap of the distance matrix be displayed once the function finishes running? |
... |
Additional arguments passed on to
|
Details
Each cell represents the distance between a pair of color cluster sets as measured using either chi-squared distance (cluster size only), earth mover's distance (size and color), weighted pairs (size and color with user-specified weights for each), or color distance (Euclidean distance between clusters as 3-dimensional - RGB or HSV - color coordinates).
Earth mover's distance is recommended unless binAvg
is set to false
during cluster list generation (in which case all paired bins will have the
same colors across datasets), in which case chi-squared is recommended.
Weighted pairs or color distance may be appropriate depending on the
question, but generally give poorer results.
Value
A distance matrix of image distance scores (the scales vary depending on the distance metric chosen, but for all four methods, higher scores = more different).
Examples
## Not run:
cluster.list <- colordistance::getHistList(c(system.file("extdata",
"Heliconius/Heliconius_A", package="colordistance"), system.file("extdata",
"Heliconius/Heliconius_B", package="colordistance")), lower=rep(0.8, 3),
upper=rep(1, 3))
# Default values - recommended!
colordistance::getColorDistanceMatrix(cluster.list, main="EMD")
# Without plotting
colordistance::getColorDistanceMatrix(cluster.list, plotting=FALSE)
# Use chi-squared instead
colordistance::getColorDistanceMatrix(cluster.list, method="chisq", main="Chi-squared")
# Override ordering (throws a warning if you're trying to do this with
# chisq!)
colordistance::getColorDistanceMatrix(cluster.list, method="chisq",
ordering=TRUE, main="Chi-squared w/ ordering")
# Specify high size weight/low color weight for weighted pairs
colordistance::getColorDistanceMatrix(cluster.list, method="weighted.pairs",
color.weight=0.1, size.weight=0.9, main="Weighted pairs")
# Color distance only
colordistance::getColorDistanceMatrix(cluster.list, method="color.dist",
ordering=TRUE, main="Color distance only")
## End(Not run)