## xicc/tiffgamut

### Summary

Create a gamut file or X3DOM file of the color gamut of the contents of a set of TIFF or JPEG image.
tiffgamut allows creation of gamut files from the pixel values in a set of TIFF and/or JPEG raster images, as defined by an ICC profile, in L*a*b* or CIECAM02 Jab colorspace, and can also represent the gamut as a X3DOM file. This can be used for visualizing and comparing the gamut of an image to the colorspace it is in, or a colorspace it might get transformed into, and can also be used to create an image source gamut for use with collink.
NOTE that if you are creating an image gamut suitable for use with the collink -g or -G flags, or colprof -g, use the Jab appearance space intent for appearance space gamut mappings, and the same input viewing conditions to be used in collink or colprof using the -c flag, i.e. "tiffgamut -pj -cmt sRGB.icm image.tif" See Image dependent gamut mapping using device links for an example workflow.
See 3D Viewing Format for switching to VRML or X3D output format.

### Usage Summary

tiffgamut [-v level] [profile.icm | embedded.tif/jpg] infile1.tif/jpg [infile2.tif/jpg ...]
-v Verbose
-d sres Surface resolution details 1.0 - 50.0
-w emit X3DOM .x3d.html file as well as CGATS .gam file
-n Don't add X3DOM axes or white/black point
-k Add markers for prim. & sec. "cusp" points
-f perc Filter by popularity, perc = percent to use
-i intent p = perceptual, r = relative colorimetric,
s = saturation, a = absolute (default), d = profile default
-o order n = normal (priority: lut > matrix > monochrome)
r = reverse (priority: monochrome > matrix > lut)
-p oride l = Lab_PCS (default), j = CIECAM02 Appearance Jab
-c viewcond set appearance mode and viewing conditions for CIECAM02,
either an enumerated choice, or a parameter:value change
pp - Practical Reflection Print (ISO-3664 P2)
pe - Print evaluation environment (CIE 116-1995)
pc - Critical print evaluation environment (ISO-3664 P1)
mt - Monitor in typical work environment
mb - Monitor in bright work environment
md - Monitor in darkened work environment
jm - Projector in dim environment
jd - Projector in dark environment
pcd - Photo CD - original scene outdoors
ob - Original scene - Bright Outdoors
cx - Cut Sheet Transparencies on a viewing box
s:surround n = auto, a = average, m = dim, d = dark,
c = transparency (default average)
w:X:Y:Z Adapted white point as XYZ (default media white)
w:x:y Adapted white point as x, y
a:adaptation Adaptation luminance in cd.m^2 (default 50.0)
b:background Background % of image luminance (default 20)
l:imagewhite Image white in cd.m^2 if surround = auto (default 250)
f:flare Flare light % of image luminance (default 1)
g:glare Glare light % of ambient (default 1)
g:X:Y:Z Glare color as XYZ (default media white)
g:x:y Glare color as x, y
-O outputfile Override the default output filename & extension.

### Usage Details and Discussion

The -v flag dumps out the ICC profile header information.
The -d parameter controls the level of detail displayed in the surface. The parameter roughly corresponds to a deltaE value, so smaller values give greater detail. The default value is around 10, and is a good place to start. Small values may take a lot of time to generate, and will produce big files.
The -w flag causes a X3DOM file to be produced, as well as a gamut file.
The -n flag suppresses the L*a*b* axes being created in the X3DOM.
The -k flag adds markers for each of the primary and secondary "cusp" points (Red, Yellow, Green, Cyan, Blue & Magenta). No markers will be displayed if the cusps cannot be determined.
The -f perc parameter turns on filtering of the raster colors. The colors from the image are clustered, and then sorted according to popularity, and then the perc most common percentage of colors are used to create the gamut surface. This may be useful in creating a source gamut mapping surface that favors the important colors within an image, and doesn't attempt to compress the color reproduction in order to reproduce the little used colors. A value of perc of 90 or 80 may be a good place to start. Note that the filtering is performed independently on each raster image processed, with the final gamut being the union of all the filtered image gamuts.
The -i flag selects the intent transform used for a lut based profile. It also selects between relative and absolute colorimetric for non-lut base profiles. Note that anything other than colorimetric may not represent the native capabilities of the device. The default intent will be absolute colorimetic for L*a*b* output, and CIECAM02 appearance for Jab output.
An ICC profile is allowed to contain more than the minimum number of elements or table needed to describe a certain transform, and may contain redundant descriptions. By default, LUT based table information will be used first if present, followed by matrix/shaper information, and only using monochrome information if it is all that is present. The -o flag, reverses this order.
-p: By default the gamut will be created in L*a*b* colorspace. If -pj is selected, then CIECAM02 appearance space Jab will be used for the output, and the viewing conditions will be taken into account. Jab space is what is normally needed to be compatible with the default intents used in colprof.
Note that the CIECAM02 output space selection by default uses the colorimetric transform of the profile resulting in the appearance of the native device, but that the perceptual or saturation transforms may be used by selecting them using the -i parameter, which may give a different result with some profiles. This may be desirable if an image is to be transformed through the perceptual or saturation tables of a profile as part of a link with an Argyll generated output profile, since it will then represent the apparent gamut of the image when subject to these tables. If the absolute colorimetric intent is chosen using -ia in combinations with -pj, then Jab with a fixed white reference is used, which emulates an absolute CIECAM02 Jab appearance space.
The -c parameter sets the output space to CIECAM02 appearance Jab values, and also allows choosing a set of viewing conditions, either by choosing a typical viewing environment, or controlling particular viewing condition parameters. This is only functional if an ICC profile is provided.
The -O parameter allows the output file name & extension to be specified independently of the last tiff/jpeg filename. Note that the full filename must be specified, including the extension.
If the TIFF or JPEG files are in a device space (ie. RGB, CMYK etc.), then it is necessary to supply an ICC profile to translate the device space values to a CIE space value such as L*a*b* or CIECAM02 Jab space for creating a gamut surface. For the ICC profile provided it is then possible to select exactly what type of conversion is used. A TIFF or JPEGfile with an embedded ICC profile may be supplied as the profile argument - e.g. to get the gamut of a tiff file that contains an embedded profile use something like:
tiffgamut image.tif image.tif
To create a gamut suitable for CIECAM02 gamut mapping space in colprof or collink, something like
tiffgamut -ir -pj -cmt image.icm image.tif
where the viewing conditions "mt" should the same as the source conditions in colprof or collink.
If a TIFF file is already in a CIE space such as CIELab or ICCLab, then it is not necessary to select an ICC profile, although a PCS to PCS colorspace profile may be chosen. All the TIFF and JPEG files must be in the same colorspace.
One or more TIFF and/or JPEG files may be specified, and the gamut is the union of the gamuts of each file. This is useful for creating an image specific gamut mapping that can be applied to a set of images with consistent results between the images. Note that the output gamut file name will by default be taken from the last TIFF or JPEG file specified, with the .gam extension added automatically. The -O parameter will override this default.
NOTES
The white and black points put in the gamut are the colorspace white and black points. For the purposes of latter gamut mapping, it is assumed that the image should retain it's position within the colorspace dynamic range. For an L*a*b* image, the values value 100,0,0 and 0,0,0 for white and black are assumed. An image in L*a*b* should be adjusted be neutral to, and sit within the dynamic range of those white and black points.