ColorQuery overview
ColorQuery provides a simple DSL for querying and manipulating the HSV values of images. The intent is to provide a quick and simplified tool for understanding how the colors of different images work.ColorQuery language (CQL) overview
CQL queries consist of a series of statements executed one after the other. The first statement in a CQL query is always pixels
.pixels
Statements
Statements are executed sequentially and separated by|
. Other than pixels
, the only other statement are assignment statements. Assignment statements consist of an assignment expression, optionally followed by a boolean expression that determines whether the assignment expression is executed. If the boolean expression is omitted then the assignment expression is always executed. An example query is:pixels
| saturation = 0.5 if saturation > 0.5
| value = 0.5
Expressions
Assignment expressions assign a new value to one of saturation
, hue
or, value
. The left-hand side is one of these, followed by an =
with the right-hand side consisting of a numerical expression.Numerical expressions support the standard operators
*
,/
,+
,-
and precedence using ()
. The values saturation
, hue
or, value
can also be used and their values will be the ones set in previous statements.Boolean expressions support the standard comparison operators
=>
,>
,<
,<=
and ==
between numerical expressions. The standard boolean operatorsand
,or
are also supported to combine these boolean expressions. Precedence using ()
is also supported.Hue, Saturation and Value
Hue, saturation and value each work on a limited scale. Hue
must be in the range [0, 360] Saturation
must be in the range [0, 1] Value
must be in the range [0, 1]For the sake of simplicity this range limit is only applied after all the statements have been executed, and rounds the value to the closest valid value in the range. For example:
pixels
| hue = hue + 180
pixels
| hue = hue + 180
| hue = hue - 360 if hue > 360