Photo post / audio analogy - de-yellow night shot

Personally, I prefer the monochrome versions. Second best, I like the yellowish cat and rocks with electric blue background. That has a kind of dreamy quality, as if the background has been invented by the cat, and projected into our eyes by that intense stare. The car almost sits like a toy on the stone wall.

And I won’t comment on the blue spotlight on the cat’s, umm, nether regions.

Anyhow, let’s treat this as an exercise. Remove the overall orange colour cast by multiplying the Red channel by the average Green and dividing by the average Red, similarly B = B*average(G)/average(B). Also find the average color of the light chest fur. Windows BAT scripts, using ImageMagick:

rem This is the crop for the cat's fur.
set sCROP=-crop 115x87+627+486 +repage

for /F "usebackq" %%L in (`%IMG7%magick ^
  %SRC% ^
  -colorspace RGB -set colorspace sRGB ^
  ^( +clone ^
     -scale "1x1^!" ^
     -set option:FR %%[fx:u.g/u.r] ^
     -set option:FB %%[fx:u.g/u.b] ^
     +delete ^
  ^) ^
  -channel R -evaluate Multiply %%[FR] ^
  -channel B -evaluate Multiply %%[FB] ^
  +channel ^
  -set colorspace RGB -colorspace sRGB ^
-define "quantum:format=floating-point" -depth 32 ^
+write x.miff ^
  +write x.jpg ^
  %sCROP% ^
  -scale "1x1^!" ^
  -format "COL=#%%[hex:p{0,0}]" ^
  info:`) do set %%L

echo COL=%COL%

COL is #7E4E99CE7A9EBF9E5E046B04, or roughly #7E7B5E.

As I say, I like this intermediate result, x.jpg:


Here comes the clever bit. Transform to a new colorspace with 2 colour channels and a lightness channel. Channel 0 is the “yellowness/blueness” where yellow is the hue of the average colour in the patch of fur. Channel 1 is the orthogonal colour channel. Channel 3 is lightness. The colorspace is defined by a matrix from sRGB:

  0.295412, 0.204585, -0.5
  -0.429262, 0.5, -0.0707384
  0.2, 0.7, 0.1

(I haven’t yet published the software that calculates the matrix, the process module “colsp012”.) The inverse matrix, from the new colorspace back to sRGB, is:

  0.422527, -1.57289, 1
  0.122187, 0.550004, 1
  -1.70036, -0.704252, 1

Values can be negative. We adjust channel 0 to push values towards zero. We could simply multiply by 0.25 or whatever, but I prefer an S-curve, which mean first adding 0.5, applying an S-curve centred at 0.5, then subtracting 0.5.

%IM7DEV%magick ^
  x.miff ^
  -process 'colsp012 color %COL% f stdout v' ^
  -channel 0 -evaluate Add 50%% -clamp +sigmoidal-contrast 10,50%% -evaluate Subtract 50%% +channel ^
  -process 'colsp012 color %COL% inverse f stdout v' ^
  x1c.jpg

x1c.jpg is:

3 Likes