Detecting Colour Neutrality From HSL

245 views Asked by At

I have a number of HSL values that I want to categorise in terms of:

  • colour neutrality (i.e. group all neutral colours such as black/grey/white/beige/brown together, and group all non-neutral colours such as yellow/blue/green/red in a separate category)
  • brightness

The latter is relatively simple in that I can take the L value and define >50% as light and <50% as dark. However I'm having trouble defining a rule that would categorise HSL values by their colour neutrality - what's the best way to do this?

1

There are 1 answers

0
AkselA On

I put together a few colour charts arranged by HSL, HSV and LCH (cylindrical LAB) to see what's the better metric for 'colour neutrality'. Saturation/chroma increases top–down, luminance/value increases left–right and hue increases diagonally top-left–bottom-right inside each 4*4 sub square.

HSL
HSL colour chart

HSV
HSV colour chart

LCH
LCH colour chart

Of course it's up to you to decide, but I think HSL S, HSV S and LCH C all seem to correspond fairly well with 'colour neutrality'.


Had a little idea. To me it sort of looks like this:

HSL colour chart with red arrows showing 'neutrality' gradient

We can implement a version of this with some simple arithmetic.

convert xc:blue xc:darkRed xc:red xc:pink xc:brown xc:gray \
  -colorspace HSL -format '%[fx:(abs(b-0.5)+(1-g))/1.5]\n' info:-
# 5.08634e-06
# 0.151629
# 5.08634e-06
# 0.250985
# 0.333272
# 0.670588

Or applying it to the HSL colour chart

convert comp-hsl.png -colorspace HSL \
  -channel red -fx "(abs(b-0.5)+(1-g))/1.5" -channel R -separate \
  hsl4.png

HSL colour chart 'netrality' gradient in grey scale