Thought I'd come back to this to show some progress. I am getting close to the standard K20D colore while extracting just a tiny little bit of extra detail from the PEF (but boy, is it hard work: the K20D jpegs are nothing to sneeze at!).
The biggest advantage is the extreme level of control this now gives me. See
my post on FLICKR.
The idea of doing some ISO-dependent variable setting was brilliant, Quicksand! Take a bow cause that got me started. I also made the return from UFRaw to the more basic dcraw as it seems a more straightforward way to work.
dcraw -w -v -H 5 -p "/usr/share/profiles/PENTAX_K20D.icc" -4 -c "$rawname"| convert ppm:- -verbose -modulate 125,130,102 -sigmoidal-contrast 2x35% -depth 16 png:- | gmic -.png -div 256 $greycexec -gimp_mix_lab 1.03,0,0,1.2,0,0,1.2,0,0,0,2 $octaveexec -c 0,255 -type uchar -output "$jpegname",97
The variables $octaveexec and $greycexec are set depending on the ISO rating of the image as per below details:
$greycexec= -smooth(0 0 5 10 20 40 80) for ISO 100, 200, 400, 800, 1600 and 3200 respectively
$octaveexec= -unsharp_octave 4,3,$octave1,$octave2,2 where
$octave1(strength)= 3 3 3 3 2 2 1 1 for the ISO values mentioned
$octave2(threshold)= 0 0 0 1 1 4 8 8
$rawname contains the filename of the raw file and $jpegname contains the filename with postfix "-batch" and jpg extension.