Closed ijlyttle closed 3 years ago
this means that we would need a .get_distance_farver()
and a .get_distance_colorio()
.get_distance_farver <- function(a, b, from_space, method, ...) {
purrr::map2_dbl(
a,
b,
farver::compare_colour,
from_space = from_space,
method = method,
...
)
}
# this is a bit stinky, but it would get us out of jail
.get_distance_colorio <- function(a, b, from_space, method_space) {
# method_space would have to be one of the defined color spaces
space <- colorio::colorio[[method_space]]()
to_space <- function(x) {
as_ xyz <- farver::convert_color(x, from = from_space, to = "xyz")
as_space <- space$from_xyz(t(as_xyz))
as_space
}
a_space <- to_space(a)
b_space <- to_space(b)
sq_dist <- colorio$dist(a_space, b_space)
dist <- sqrt(sq_dist)
dist
}
obviated by #51
with colorio, we have access to a bunch of color spaces, including CAM16-UCS and Jzazbz, with the hope of "better" distance measurements.
The base color space for colorio is xyz100 - and we have a way to translate to it using
farver::decode_colour()
Currently, the internal function
.get_distance()
has a signature:Here,
method
refers tofarver::compare_colour()
; we use a default value of"cie2000"
.What if our
method
argument used a syntax like"farver::cie2000"
, and could also take a value like"colorio::CAM16-UCS"
?