This gets closer to the concept with linear images (thanks Bo). Nothing precise at this stage.
Applied to the final stacked image and then stretched, colour gradients are problematic, if not unworkable. The process should probably be applied post deBayer prior to stacking.
This was all done on an Android tablet, with dcraw and imagemagick installed in Termux, then gradient removal in Ivo's Android StarTools.
Code:
#! /bin/bash
# Apply DSLR channel multipliers, obtained from
# https://www.dxomark.com/Cameras/Canon/EOS-450D---Measurements
# Windows OS replace \ with ^ AFAIK...
# Canon 450D
# R sRGB G sRGB B sRGB
# R raw 1.91 -1 0.09
# G raw -0.19 1.65 -0.46
# B raw 0.07 -0.7 1.64
#Color matrix as defined in ISO standard 17321
# Nikon D3300
# R sRGB G sRGB B sRGB
# R raw 1.85 -0.74 -0.1
# G raw -0.17 1.56 -0.39
# B raw 0.05 -0.47 1.42
percent=100
Rr=$(echo "scale=4; 1.91/100*$percent" | bc )
Rg=$(echo "scale=4; -1/100*$percent" | bc )
Rb=$(echo "scale=4; -0.09/100*$percent" | bc )
Gr=$(echo "scale=4; -0.19/100*$percent" | bc )
Gg=$(echo "scale=4; 1.65/100*$percent" | bc )
Gb=$(echo "scale=4; -0.46/100*$percent" | bc )
Br=$(echo "scale=4; 0.07/100*$percent" | bc )
Bg=$(echo "scale=4; -0.7/100*$percent" | bc )
Bb=$(echo "scale=4; 1.64/100*$percent" | bc )
echo $Rr $Rg $Rb
echo $Gr $Gg $Gb
echo $Br $Bg $Bb
#Play around with multipliers for Ha modded cameras
cd storage/downloads
convert in.tiff -color-matrix \
"$Rr $Rg $Rb \
$Gr $Gg $Gb \
$Br $Bg $Bb" -alpha off out.tiff
convert in.tiff in.jpg
convert out.tiff out.jpg
animate -delay 100 -loop 0 -resize 800x600 -page 800x600 in.jpg out.jpg
exit