Closed dylanbeaudette closed 5 years ago
I definitely like keeping the project restricted to R packages already used by most people (dplyr, purrr, etc) but will try this out when I get a chance. I can see this helping with shadows getting assigned to a completely new color and speeding up the functions.
In that case, Euclidean distance in CIE LAB via grDevices::convertColor()
would keep the dependencies to a minimum.
Another idea: image resampling can be done using the raster
package in about 1 line of code. Just a thought. Incidentally, I had to install the tidyverse
package.
Revisiting this...
Thanks for this. Ended up using the compare_color() function in farver. CEI94 looks best in general, though depends on the composition of the image. Leaving the original euclidean distance calculation in there as an alternative.
This is updated on the other branch. Will likely merge in August or September.
Thanks for considering.
I'm curious as to how "best" is defined--color matching is a tricky thing. I have found that CIE DE2000 has been the most universally "reasonable" in the realm of soil science and field description of soil color. Either metric will be far more "realistic" than Euclidean distance in sRGB.
Here are a few comparisons. CIE2000 seems like it loses some of the depth of the image. Overall, I'm happy that these options fix the problems with whites turning into light blue and light pink.
Nice! An excellent way to compare the results, thanks for the demo. I wonder if "depth" (contrast?) can be enhanced by using a 2-step process:
Beyond that, a simple dithering step might be useful.
Too much?
First of all this is just amazing. Congratulations on doing what many lego fans often dream about doing.
I am not sure, but I suspect that the lego colors are likely in the sRGB colorspace. This is a convenient color space for displaying colors on a screen but not the most accurate space to perform color matching. Would you be interested in using the CIELAB color space, or even better CIE2000 color distance metric? The CIELAB space is based on (typical) human perception of color and matching done in this color space is usually more realistic. It may not matter when working with a small palette of highly saturated colors but it might be worth a try.
There are a couple of ways to convert colors in R, my favorites are
grDevices::convertColor()
andfarver::convert_colour()
. Note that each specify the source color space in a slightly different manner,RGB
is typically used to describe a family of color spaces whilesRGB
is quite specific to uncalibrated computer screens, HTML colors, and so on.Here is a rather verbose example, based on a color system (Munsell) and methods used in soil science and geology.
You might be able to guess why this would be interesting to earth scientists.