snibgo's ImageMagick pages

Colour wheels

We can draw some pretty colour wheels.

See also the closely-related Rainbow cluts.

setlocal enabledelayedexpansion

"%IMG7%magick" ^
  -size 100x300 gradient: -rotate 90 ^
  -distort Arc "360 -90 50" +repage ^
  -gravity center -crop 100x100+0+0 +repage ^
  -rotate -90 ^
  cwx_angular.png

"%IMG7%magick" -size 100x100 radial-gradient: -negate cwx_radial.png

"%IMG7%magick" -size 100x100 xc:gray(50%%) cwx_solid.png

set WHEELS=

for %%H in (HSL,HSB,HSV,HSI,HCL,HCLp,HWB) do (
  "%IMG7%magick" ^
    cwx_angular.png cwx_solid.png cwx_radial.png ^
    -combine ^
    -set colorspace %%H ^
    -colorspace sRGB ^
    ^( label:%%H -trim +repage ^
       -bordercolor White -border 2 ^) ^
    -gravity Center ^
    -append +repage ^
    +depth ^
    cwx_%%H.png

  set WHEELS=!WHEELS! cwx_%%H.png
)

%IMG7%magick %WHEELS% +append +repage cw_wheels.png

del %WHEELS%
cw_wheels.png

We can vary the middle channel, saturation, from zero to 100%.

setlocal enabledelayedexpansion

"%IMG7%magick" ^
  -size 150x450 gradient: -rotate 90 ^
  -distort Arc "360 -90 75" +repage ^
  -gravity center -crop 150x150+0+0 +repage ^
  -rotate -90 ^
  +depth ^
  cwx_angular.png

"%IMG7%magick" ^
  -size 150x150 radial-gradient: ^
  -negate ^
  +depth ^
  cwx_radial.png

set ROWS=
for /L %%P in (0, 10, 100) do (
  "%IMG7%magick" -size 150x150 xc:gray^(%%P%%^) cwx_solid.png

  set WHEELS=

  for %%H in (HSL,HSB,HSI,HSV,HCL,HCLp,HWB) do (
    "%IMG7%magick" ^
      cwx_angular.png cwx_solid.png cwx_radial.png ^
      -combine ^
      -set colorspace %%H ^
      -colorspace sRGB ^
      ^( label:"%%H %%P" -trim +repage ^
         -bordercolor White -border 2 ^) ^
      -gravity Center ^
      -append +repage ^
      +depth ^
      cwx_%%H.png

    set WHEELS=!WHEELS! cwx_%%H.png
  )

  %IMG7%magick %WHEELS% -set colorspace sRGB +append +repage +depth cwx_wheels_%%P.png
  set ROWS=!ROWS! cwx_wheels_%%P.png
)

del %WHEELS%

%IMG7%magick %ROWS% -append +repage cw_rows.png

del %ROWS%
del cwx_*.png
cw_rows.png

We can get a different style of colourwheel from Lab colorspace.

%IMG7%magick ^
  -size 200x200 ^
  xc:gray(75%) ^
  gradient: ^
  ( gradient: -rotate 90 ) ^
  -combine -set colorspace Lab ^
  -colorspace sRGB ^
  cw_lab.png
cw_lab.png

Formulae:

HCL and HCLp Luma = 0.298839*red+0.586811*green+0.114350*blue;
Chroma = max - min

HSB Brightness = max (red, green, blue);
Saturation = (max-min) / max

HSI Intensity = (red + green + blue) / 3.0;
Saturation = 1 - min / Intensity

HSL Lightness = (max + min) / 2.0;
c = max - min;
Saturation = (Lightness <= 0.5) ? c / (2*Lightness) : c / (2 - 2*Lightness)

HSV Value = max;
Saturation = (max-min) / max

HWB Whiteness = min;
Blackness = 1 - max

Note: HSB and HSV are the same.


All images on this page were created by the commands shown, using:

%IMG7%magick -version
Version: ImageMagick 7.1.0-42 Q16-HDRI x64 396d87c:20220709 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenCL 
Delegates (built-in): bzlib cairo freetype gslib heic jng jp2 jpeg jxl lcms lqr lzma openexr pangocairo png ps raqm raw rsvg tiff webp xml zip zlib
Compiler: Visual Studio 2022 (193231332)

Source file for this web page is colwheel.h1. To re-create this web page, execute procH1 colwheel.


This page, including the images, is my copyright. Anyone is permitted to use or adapt any of the code, scripts or images for any purpose, including commercial use.

Anyone is permitted to re-publish this page, but only for non-commercial use.

Anyone is permitted to link to this page, including for commercial use.


Page version v1.0 21-Jan-2014.

Page created 22-Aug-2022 03:26:04.

Copyright © 2022 Alan Gibson.