Re:CSS Gradients that avoid the “gray dead zone”
by rikroots on Wednesday January 12, 2022 @03:46AM
(#29903900)
The approach I finally settled on was: check each pixel in the image to build up a list of (RGB) most popular colors and to memoize new colors into LAB values; sort the color data into commonest first; then build up the required palette from commonest downwards, excluding colors that were too close to each other based on a distance measure. Then you can go back to the original image and measure its color against the palette colors, from which you can determine the 3 palette colors closest to it. From that you can give each pixel a propensity range of the likelihood of it taking on one of those 3 colors and run it against a randomly generated value, or a set of preset values for blue noise.
Re:CSS Gradients that avoid the “gray dead zone”
by capitainenemo on Wednesday January 12, 2022 @10:43AM
(#29907931)
https://github.com/gvlsq/palettize how about this approach?
Re:CSS Gradients that avoid the “gray dead zone”
by capitainenemo on Wednesday January 12, 2022 @11:00AM
(#29908255)
(er, for the initial palette generation, that is)
I have had some success manually using Photoshop to generate a reduced color space image to only 5 distinct colors (probably optimally chosen by the algorithm) and then remapping those 5 colors to 5 the 5 colors I actually have. There must be better ways