?

Log in

No account? Create an account
Previous Entry Share Next Entry
How to make a "correction" profile
sail2ithaki
Suppose you have a converter that renders colours not exactly to your liking. Here is how you can adjust for that. Let's say you have an image that exhibits a problem. Render it through a converter with the default settings for colour and additionally render a colour target (I use ColorChecker SG) with the same settings. Open both in Photoshop and combine into a single image. Do the necessary corrections to the combined image to get the colour right (obviously those edits will affect the target as well). Crop out the colour target leaving about 40 pixels around it. Same way crop the non-edited colour target. Get Argyll CMS, unpack it, and copy bin/scanin, bin/colprof, bin/extracicc, bin/txt2ti3, bin/xicclu and ref/ColorCheckerSG.cht to some folder. Save the cropped targets to the same folder. Run the script and assign the resulting profile when opening an image in Photoshop.

#!/bin/bash
#set camera manufacturer
manufacturer=$1
#set camera model
model=$2
# you may want to put a note of the edits you've made for this profile
# for example "skin tone for studio portrait"
description=$3
# name of the non-edited conversion (points to cropped target)
# no extension, .tif will be added in the script
raw=$4
# name of the edited conversion (also points to cropped target) 
# no extension, .tif will be added in the script
converted=$5
your_name=$6
# automatic pattern recognition for the non-edited conversion
# source RGB values are going to raw.val
scanin -o -v -p -a -G 2.2 -dipn $raw.tif ColorCheckerSG.cht $raw.diag.tif
# extract working profile from the edited output
extracticc -v $converted.tif $converted.icm
# automatic pattern recognition for the edited conversion
# output RGB values are in converted.val
scanin -o -v -p -a -G 2.2 -dipn $converted.tif ColorCheckerSG.cht $converted.diag.tif
# get RGB values from converted.val
# convert them to XYZ through converted.icm
# the result is in converted.XYZ.val
echo "IT8.7/2
ORIGINATOR \"$your_name, $(date +%Y)\"
DESCRIPTOR \"XYZ  values obtained from the reference converter $3\"
CREATED  \"$(date)\"
MANUFACTURER \"X-Rite/Gretag Macbeth\"
NUMBER_OF_FIELDS 4
BEGIN_DATA_FORMAT
SAMPLE_ID XYZ_X XYZ_Y XYZ_Z
END_DATA_FORMAT
NUMBER_OF_SETS 140
BEGIN_DATA" > $converted.XYZ.val
awk '/BEGIN_DATA$/ {
for(i=1; i<=140; i++) {
getline; print $2/255, $3/255, $4/255;
}
}' $converted.val |\
xicclu -v0 -ff -ip -pX $converted.icm |\
nl -nln |\
awk ' {l=sprintf ("%c", ($1-1)%14+65); print l int(($1-($1-1)%14)/14)+1, $2, $3, $4}' >> $converted.XYZ.val
echo "END_DATA" >> $converted.XYZ.val
# compose the final ti3, matching input RGB to output XYZ
txt2ti3 -v -i $raw.val $converted.XYZ.val $raw.rgb2xyz
# calculate profile
colprof -v -A "$manufacturer" -M "$model" -D "$manufacturer $model $description" -C "Copyright $your_name, $(date +%Y)" -qh -bn -ax -O "${manufacturer// /_}_${model// //_}_${description// /_}.icc" $raw.rgb2xyz