Color Filters¶
Filter¶
For instance, Hapycolor is able to determine if a color is too bright or too dark. A first step, would be to convert the colors in an hsl base and then add conditions on the luminosity. But that would be an illusory solution, as a matter of fact, both hsl/hsv or rgb color bases do not match the human’s eye perception of colors. That is why, we handpicked more than a hundred colors that we consider being at the interface between the space where the colors are too bright (respectively, too dark) and the space where they are not. From this discretisation, Hapycolor is able to generate a more fine discretisation of this hyperplan which is used to filter the colors. A similar approach has been implemented in order to filter out the colors that are deemed not enough saturated.
Reduction¶
A second innovative concept embedded into Hapycolor’s color processing core, is the ability to properly reduce the number of colors. Indeed, one of the challenges is to remove the colors that are to close to one another from the human’s eye perspective, but still keeping the largest palette possible. Thus, supposing that such a color base exists, the problem can be also stated as: imagining that each color represent a node in a graph and that two colors sufficiently “far” from each other, have a common vertex. In this situation, the question becomes “what is the maximum clique?”, an inquiry already answered by Coenraad Bron and Joep Kerbosch with the Bron-Kerbosch algorithm.
Back to the concreteness of our world, the hypothesis of the existence of a color base that is perceptually uniform still needs to be proven, and worse, found, if one hopes to disclose the impenetrable mysteries of Ricing’s Art. I am pleased to announce another saviour: Richard S. Hunter, a man and a color scientist who invented the Lab color space from which has been devised by the International Commission on Illumination the CIEL*a*b color space. The commission crafted various distances that could operate in this space, among others the: CIEDE2000, that have been used by Hapycolor to define the maximal clique problem.
How to add a color filter?¶
In order to add a custom filter, a class inheriting from hapycolor.filters.base.Filter should be implemented in the filters module.
Its main method, “apply” takes in a hapycolor.Palette and should output another hapycolor.Palette.
In addition, in order to enable it, the module’s name should be added in the “Filters” section of the configuration file,
coupled with a value representing the complexity of the algorithm. At runtime, hapycolor searches for classes stored in
the provided modules that inherits from hapycolor.filters.base.Filter and whose name is a PascalCase version of the respective module
(which should be named in snake_case, but you already know that).