## tweak/refine

### Summary

Refine creates an abstract profile, by comparing CIE measurement values from two test charts. The charts will usually be in .ti3 format, but only XYZ, Lab or spectral values will be used (ie. all device space values are ignored). Typically the charts would be printed on a target system (the one being emulated, say a printing press, or created using an ideal target profile such as Rec709), and the proofing system (the device that is being profiled). The abstract profile that refine produces will be a correction that makes the proofing system behave more like the target. This can then be used to recreate the proofing systems ICC profile, or device link. By feeding a previous abstract correction profile in as well, iterative improvement can be made to the proofing reproduction.
colverify is a useful tool to use on the two test charts, to check how well the refinement is proceeding. If a white point relative match is being created (refine -R), then use veryify -N.

### Usage Summary

`usage: refine [-options] cietarget ciecurrent [outdevicc] [inabs] outabs
-v Verbose
-c Create initial abstract correction profile
-g Don't impose output device gamut limit
-r res Set abstract profile clut resolution (default 33)
-d factor Override default damping factor (default 0.950000)
-R Aim for white point relative match rather than absolute
` `-f [illum] Use Fluorescent Whitening Agent compensation [opt. simulated inst. illum.:
M0, M1, M2, A, C, D50 (def.), D50M2, D65, F5, F8, F10 or file.sp]
-i illum Choose illuminant for computation of CIE XYZ from spectral data & FWA:
A, C, D50 (def.), D50M2, D65, F5, F8, F10 or file.sp
-o observ Choose CIE Observer for spectral data:
1931_2, 1964_10,` ``2012_2 (def.), 2012_10,` S&B 1955_2, J&V 1978_2 or file.cmf
cietarget Target CIE or spectral values, CGATS file (e.g. .ti3)
ciecurrent Actual CIE or spectral values, CGATS file (e.g. .ti3)
[outdevicc] Output device ICC profile to set gamut limit (not used if -g)
[inabs] Previous abstract correction ICC profile (not used if -c)
outabs Created/refined abstract correction ICC profile`

### Usage Details

refine provides a way of improving the profile accuracy of a proofing system.
The -v flag prints out extra information during the checking, and prints each patch value, rather than just a summary.
The -c option is used when refine is being used for the first time, and there is no previous abstract profile to continue refining. If -c is used, then the name of the previous abstract correction profile should not be supplied.
If the -g flag indicates that an output device profile is not being supplied, and that corrections should be attempted, even if the colors are outside the devices gamut. Normally an output device profile is supplied, and corrections aren't applied to colors outside the devices gamut, since this will not achieve anything useful, and can distort the results.
If the -r parameter overrides the resolution of the CLUT grid used in the abstract profile. By default the value is 33, but other
values can be chosen. An odd number is recommended.
If the -d parameter sets how aggressively refine should try and correct errors. Normally it will try and exactly compensate for the color errors revealed in comparing the two measurement files, but if the device behaviour is unusual, or not very repeatable, this may result in successive applications of refine making things worse, rather than better. If this is the case, try using a smaller number, such as 0.8, or 0.5.
If the -R flag is used, then refine creates an abstract profile for improving the match of the patch values when interpreted in a white point relative (ie. Relative Colorimetric) intent. If used to create a corrected device link profile using collink, remember to create a Relative colorimetric intent device link profile.
The -f flag enables Fluorescent Whitening Agent (FWA) compensation. This only works if spectral data is available and, the instrument is not UV filtered. FWA compensation adjusts the spectral samples so that they appear to have been measured using an illuminant that has a different level of Ultra Violet to the one the instrument actually used in the measurement. The optional illumination parameter allows specifying a standard or custom illumination spectrum to be used as the similated instrument illuminant, overriding the default D50 or CIE computation illuminant used for FWA (see -i below). See colprof -f for a fuller explanation. The same value should be used as was used during the creation of the profile.
The -i flag allows specifying a standard or custom illumination spectrum, applied to the spectral test point values to compute CIE tristimulus values. A, D50, D50M2, D65, F5, F8, F10 are a selection of standard illuminant spectrums, with D50 being the default. If a filename is specified instead, it will be assumed to be an Argyll specific .sp spectrum file. If FWA compensation is used during measurement, this illuminant will be used by default as the simulated instrument illuminant. The same value should be used as was used during the creation of the profile.
The -o flag allows specifying a tristimulus observer, and is used to compute CIE tristimulus values. The following choices are available:
1931_2 selects the standard CIE 1931 2 degree observer.
1964_10 selects the standard CIE 1964 10 degree observer.
2012_2 selects the proposed CIE 2012 2 degree observer
2012_10 selects the proposed CIE 2012 10 degree observer
1955_2 selects the Stiles and Birch 1955 2 degree observer
1978_2 selects the Judd and Voss 1978 2 degree observer
shaw selects the Shaw and Fairchild 1997 2 degree observer
file.cmf selects an observer specified by the given .cmf file.
If both CIE and spectral values are present in the input files, the CIE values will be used by default. Using the -i, -o or -f flag will force spectral values to be used. The the -i, -o or -f flags will apply to both the target and measured input files.
cietarget Is the filename of the target CIE or spectral values. This is a CGATS file (e.g. a .ti3 made using chartread). These are the color values wanted for each patch in the test chart, typically the product of the target print system.
ciecurrent Is the filename of the actual, current measured CIE or spectral values. This is a CGATS file (e.g. a .ti3 made using chartread). The errors between these patches and the patches in the cietarget file will be used to create a correction profile.
[outdevicc] If the -g flag is not used, then the output device ICC profile should be supplied here, to allow refine to limit its corrections to colors that are within the gamut of the device.
[inabs] After the first correction has been created, subsequent corrections need to improve upon previous ones, so the previous correction profile should be provided here. For the first correction, the -c flag should be used, and this argument is omitted.
outabs The name of the created or refined abstract correction ICC profile

### Discussion

Refine is typically used in a proofing situation, in which a verification chart is being used to check the accuracy of a proofing system. (It might also be used for more arbitrary color alterations by created two test chart files by hand.) By using the errors between the target chart and the measured values, refine attempts to improve the match between the proofing system and its target.
There is facility in collink, colprof and revfix to incorporate an abstract profile.
For systems using two device profiles or a device link to convert between the target space printing files and the proofing device space, the following would be a typical scenario:
We have a reference set of test chart values, read from the target system reference.ti3. The ICC profile for the target system is target.icm. The ICC profile for the proofing system is proofer.icm. If using a device link, the device link used to print proofer test charts is currently target_proofer.icm:
First we print the test chart out on the proofing system and read it in, resulting in a chart1.ti3 file.
Lets check how well the proofing system current matches using colverify:
colverify reference.ti3 chart1.ti3
We then create our initial abstract correction fix profile fix1.icm using refine:
refine -v -c reference.ti3 chart1.ti3 proofer.icm fix1.icm
Applying this to your process for creating the proofer device profile or target to proofing device link (choose one of the three options below, depending whether you are using the proofer profile and just want to alter its colorimetric B2A table using revfix, whether you are going to recreate the proofer file from the original measurement data using colprof, or whether you are using a device link profile created using collink):
revfix -v -1 -ke -p fix1.icm proofer.icm proofer_fix1.icm
or
copy proofer.ti3 proofer_fix1.ti3
colprof -v -p fix1.icm proofer_fix1
or
collink -v -s -ia -oa -p fix1.icm target.icm proofer.icm target_proofer_fix1.icm
Note that the above example is a simple one - you should use all the same options as you used to create your initial proofer.icm or target_proofer.icm, with the addition of the "-p fix1.icm" option to specify the abstract correction profile be applied.
Use the proofer_fix1.icm or target_proofer_fix1.icm to print out the test chart again, and read it in, resulting in chart2.ti3 file.
Lets check how well the proofing system matches after this first round of refinement using colverify:
colverify reference.ti3 chart2.ti3
>>>
We can then start another round of improvement:
We refine our previous abstract correction fix profile using refine:
refine -v reference.ti3 chart2.ti3 proofer.icm fix1.icm fix2.icm
Applying this new abstract profile to our process for creating the proofing device profile or link again:
revfix -v -1 -ke -p fix2.icm proofer.icm proofer_fix2.icm
or
copy proofer.ti3 proofer_fix2.ti3
colprof -v -p fix2.icm proofer_fix2
or
collink -v -s -ia -oa -p fix2.icm target.icm proofer.icm target_proofer_fix2.icm
Use the proofer_fix2.icm or target_proofer_fix2.icm to print out the test chart again, and read it in, resulting in chart3.ti3 file.
Check again how well the proofing system matches after this first round of refinement using colverify:
colverify reference.ti3 chart3.ti3
Rounds of improvements can be continues by looping back to >>>, being careful to increment the names of the fixN.icm, proofer_fixN.icm or target_proofer_fixN.icm and chartN.ti3files. Stop when exhausted, or if it looks like things are getting worse, rather than better. If the latter happens, it might be good to revert to the results from a previous round.