\documentclass[10pt]{article}

%\usepackage[latin1]{inputenc}
%\usepackage[american]{babel}

\usepackage[]{amsmath}
\usepackage[]{amssymb}
\usepackage[]{color}
\usepackage[]{epsfig}
\usepackage[]{subfigure}
\usepackage[]{eepic}
\usepackage[]{float}

% More generous margins
\setlength{\textheight}{245mm}
\setlength{\textwidth}{160mm}
\setlength{\oddsidemargin}{0mm}
\setlength{\evensidemargin}{0mm}
\setlength{\topmargin}{0mm}
\setlength{\headheight}{0mm}
\setlength{\headsep}{0mm}

\setlength{\parskip}{1.3mm} % Add some space between paragraphs.



%\usepackage[super,comma,sort&compress]{natbib}

\title{\textbf{little cms Engine}\footnote{http://www.littlecms.com}\\
  lprof - A profile construction set library\\
  How to use the the sample profilers\\
  Ver 1.09}

\author{Marti Maria}
\date{}

\begin{document}

\maketitle

%\tableofcontents

Welcome to this small guided tour on littlecms sample profilers.
The goal of this document is to show how these programs can be
used to generate ICC profiles for your monitor, scanner, digital
camera, film projector or input device. It has also some advice
on color management in general, as well as some guidelines on
how to handle several littlecms utilities.


Since the best way to see how it works seems to be by example, we
will step by step make a whole calibration procedure for monitor
and scanner.

In all this tour, we will make extensive use of the measurement
and proof utility: \texttt{qtMeasurementTool}. You will also need a IT8
target, available from several vendors. If you plan to do scanner
profiling, make sure to get one of these.

\texttt{qtMeasurementTool} is a ``virtual colorimeter'' that used in
conjunction with a proper scanner profile can be used as a cheap
replacement of expensive hardware. It can also be used to proof
an image across two profiles. The most simple way to check if
all is going fine is by visual inspection. You can load an image
in the measurement tool, and apply a transform between your
input profile (AKA, scanner or camera) and your monitor profile.
Since right now we have no profiles to check, we should first
create a profile for our monitor.

This is done by \texttt{qtMonitorProfiler}. This program can work in two
different modes. The ``advanced''  mode, that gives accurate
profiles by using hardware devices like X-Rite DP92 or EyeOne,
and the ``simple''  mode, that allow to build reasonably accurate
profiles without any additional hardware.


\section{Building a monitor profile: a coarse approximation}

So, let's build our first monitor profile to check how all this
stuff works. We don't need right now a big accuracy. We want to
calibrate coarsely, just to visually check if is all going ok.

After installing the package, type
%
\begin{verbatim}
  ./qtmonitorprofiler
\end{verbatim}
%
This will start the monitor profiler application. As said, we
need only a coarse profile, so, we select the radio button
labeled:
%
\begin{itemize}
  \item[] \emph{I want to build a coarse profile, giving approximate values}
\end{itemize}
%
This is selected by default. We need not any measurement right
now, only a few visual adjusts. Press the button labeled:
%
\begin{itemize}
   \item[] \emph{Enter monitor values}
\end{itemize}
%
You will see the monitor values page. In order to obtain maximum
performance, we need to adjust first the physical monitor
controls.

Set contrast to near maximum, (yes, near maximum. This is the
gain of monitor and we need as many as monitor can deliver) and
then adjust brightness until you can see all grays of a
grayscale. Leave the monitor alone, and return to monitor
profiler program.

Now we will adjust gamma correction. This is by far the most
important setting. On our first approach, we will try with only
one gray channel (make sure \emph{Link channels} is checked).

Move the slide until the central frame seems to \emph{fade} on background. 
Don't  spend too much time adjust it, gamma varies with many factors.
A coarse adjust will be enough right now.

You should obtain a typical value of 2.1--2.4, in some cases it
could be even lower.

Now we go on the white point stuff. Some monitors refers white
point as ``temperature''. Most users does have white point set to
D93 in order to get more bright, unfortunately this  restricts
the gamut and adds a big quantity of blue, so my advice would be
to select something lower.

If you can switch temperature of your monitor, D65 (near 6500K)
could be a good choice for multiuse. For proofing devices, D50
is almost a must, but it adds too yellow for a unadapted used.
D50 requires a dim or dark room to give the best results. If you
don't know which temperature your monitor has, select D65 or
D93. On our fist approach both these will give reasonable
results.

If your monitor has any other white point, you can select \emph{User
defined}, the last option. You can then select your particular
white point as a temperature in Kelvin degree.

Don't use CIE illuminants. They are intended for  workspace 
construction, and will be discussed latter.

Next adjust is primaries set. For the primaries, select the
default ITU/R BT.709 if you are profiling a CRT monitor. There
are primaries for Samsung TFT and LCD, but these devices are not
fully supported by the profiler. The reason to not support them
is the angular dependence, which makes them unusable for color
management tasks.

Other primaries are for building workspaces. If you don't know
the primaries, don't worry. Use the default ITU/R BT.709. There
are 6 or 7 CRT tube manufacturers in the world, and all them
does use this set.

Now you can fill the info about your monitor. Although this is
not strictly required, it could prevent a lot of pain when you
have more than a couple of profiles.  For filling the info field, 
select the \emph{profile identification} tab, and be creative on your 
comments!

Now we are ready to generate our profile. We must specify the
output filename, so, select the \emph{Main} tab, and press the \emph{...}
button on right side of the \emph{output profile file} edit.

Select \texttt{profiles} directory. This is where other tools will look
for monitor profile. There are a couple of profiles there, leave
them alone. For the name, we could use \texttt{CoarseMonitor.icm}. So,
type in the name and then proceed to generate the profile by
pressing the \emph{GO!} button. If all is ok, the status console will
show \emph{Profile DONE!}

Let's now check how well is working our profile by eye. For
that, we need another tool. So, close the monitor profile and
start the measurement tool by typing
%
\begin{verbatim}
  ./qtMeasurementTool
\end{verbatim}
%
This utility has many usage. One would be to ``proof'' a color
transform. Let's first configure the measurement tool. Select
the \emph{Options} tab. Adjust the default settings as following:
%
\begin{itemize}
  \item[] On \emph{Pick template}   $\rightarrow$ \emph{Empty Picker}
  
  \item[] On  \emph{Input profile}   $\rightarrow$  \emph{Tutorial Workspace}
\end{itemize}
%
On \emph{Monitor profile} should appear your profile. If you filled
the info fields, here will be your description. If you didn't
enter description it will be \emph{(unknown) - Little cms construction
set}, which is the default string. Now you know why to fill
information fields!

We are going to check your profile with a highly tweaked sample
image This is a counterexample on what a good workspace should
be. NEVER use this profile for practical purposes!

Ok, let's see how an image looks in this tweaked colorspace.
Select the \emph{Image} tab, and press \emph{Load Image} button.

Select \texttt{pics} directory. There is a \texttt{party\_4s.png} file. Load it. You
will see the raw, non color managed picture. Since the encoding
space of this image is quite different of any monitor, the
images looks ``flat'' and ``washed out'' Now press the \emph{Proof}
button. The image is shown using color management. Color
changes should be noticeable, despite gamma of image is
near gamma of monitor.


\section{Building scanner profile}

We have now our monitor calibrated, and will try to generate a
scanner profile. For this, we will also need the measurement
tool.

Scanner profiles are built by using a thing known as ``IT8
target''. IT8 targets are just a photo with a set of color
patches. There are known colorimetric measurements for each
of these patches. There is also a standard way to specify 
these measurements, the IT8/CGATS format.


IT8/CGATS is a way to encode data that is both, human and
machine readable. You can open any of these IT8 reference sheets
with your text editor to see it. You can even modify the
contents. Since it is a standard, most color management systems
does accept it. For these reasons, seems a good way to store
measurement data.


A IT8 file does contain measurements for a set of color patches.
The measurement of each patch can be the device colorant values
(the RGB or CMYK in 0--255 range) the tristimulous values (XYZ
or Lab) and some statistic data.

An IT8 sheet looks like:
%
\footnotesize
\begin{verbatim}

  -----------------------------------------------------------
  IT8.7/2
  ORIGINATOR "Wolf Faust"
  DESCRIPTOR "L* a* b* Batch average data (light D50, viewing angle 2)"
  MANUFACTURER "Wolf Faust - http://www.coloraid.de"
  CREATED "January 07, 2002"
  PROD_DATE "2001:12"
  SERIAL "DIN A4  R012020"
  MATERIAL "Kodak Professional Digital 3 - Non-Glossy"
  NUMBER_OF_FIELDS 9
  BEGIN_DATA_FORMAT
  SAMPLE_ID   XYZ_X   XYZ_Y   XYZ_Z          LAB_L   LAB_A   LAB_B          LAB_C   LAB_H
  END_DATA_FORMAT
  NUMBER_OF_SETS 288
  BEGIN_DATA
  A1           3.25    2.71    1.94          18.86   11.18    2.87          11.55   14.41
  A2           4.07    2.73    1.60          18.91   23.59    6.54          24.49   15.48
  A3           5.79    3.42    1.75          21.67   33.38    9.60          34.73   16.05
  A4           4.28    2.66    1.46          18.62   27.73    7.59          28.75   15.32
  A5          11.97   10.30    7.42          38.38   15.04    4.16          15.61   15.47
  .... etc ...
  ------------------------------------------------------------
\end{verbatim}
\normalsize

The target manufacturer does provide a IT8 file containing these
measurements for the target. So, the target is giving to us a set
of KNOWN colors. We must then, tell to the profiler which RGB
values our scanner returns for each of these patches.

Measurement tool can generate sheets with the RGB values of each
patch grabbing them from an image. In order to generate a
profile, we need the RGB and Lab values for each patch.

let's outline the scanner profiling procedure:
%
\begin{itemize}
\item First (and very important!) adjust controls of scanner to
  obtain a proper exchange space.
  
\item Scan by means of you scanning software an image of your
  target.
  
\item By using measurement tool, grab the RGB values of each
  patch. Store them in a IT8 file
  
\item The scanner profile then will compare the RGB
  obtained by the scanner, with the known colorimetric
  measurement of target, as stored in vendor's reference
  sheet.
  
\item The scanner profiler will create a model for the
  translation RGB $\rightarrow$ Lab or RGB $\rightarrow$ XYZ and will store it in
  a profile.
\end{itemize}

The math behind this model is not trivial. There is a big
quantity of factors taken into account. Don't worry for the
apparent missing of data. Yes, there are colors not present in
target, however the scanner profiler is capable to ``guess'' or
extrapolate them, and should produce a profile handling all
gradients between these colors in a smooth and pleasant way.

Lets' discuss each step in detail:
%
\begin{description}
 
\item[Step 1:] Adjust controls of scanner.

  You will need 24 bits per pixel at least. Gray profiles
  are NOT supported in this revision.
  
  There is a big amount of controversy about how to set the
  scanner controls. Some people does advice to use linear gamma
  (gamma=1.0), which is a wrong advice unless you are working with
  16 bits per sample (48 bits per pixel)
  
  If you are going to scan in 8 bits per sample (24 or 32 bits)
  your best choice is a gamma between 2.2 and 3.0
  
  Gamma 2.2 has the additional benefit of being close to sRGB, and
  this means the uncorrected image will ``look nice'' on average
  monitors. It is also near to perceptual gamma.
  
  Gamma 2.4 has the additional benefit of being closest to
  perceptual space, and this is a very good reason to use this
  value.
  
  Less that 2.2 (and of course the infamous 1.0) can generate huge
  loss of detail in shadows, only to give a slight bettering of
  highlights. Don't use this unless your are using 16 bits per
  sample, and even in such case, don't do it unless you know what
  are you doing!
  
  More that 2.4 (up to 3.0) drops too much highlight to be safe,
  despite you will still see the image quite correct.
  
  More on controls: Turn off all color management, color enhancing
  and tweaking on scanner driver. Set brightness contrast and hue
  (if available) to default values. It is supposed this will be your 
  working scanning mode, so set all to reasonable defaults.
  
  IMPORTANT: The profile will only be valid with those settings!

\item[Step 2:] Scan the IT8 target.
  
  Store it in PNG, TIFF, BMP on depending of supported formats of
  your platform. DON'T use JPEG! Its lousy nature makes it
  unsuitable for this purpose. You could use JPEG on final images,
  but not in profiling process.
  
\item[Step 3:] Extract the RGB values for each patch.
  
  Without help, this could be a huge task. There are plenty of
  patches and taking each sample by hand would be tedious. With
  the help of measurement tool, this is a easy task.
  
  Start the measurement tool by typing
  \begin{verbatim}
    ./qtMeasurementTool
  \end{verbatim}
  %
  Press \emph{Load Image} button. Select the image of target you scanned 
  in step 2. I will use the \texttt{scandmo.png} image sited on \texttt{pics} 
  directory as sample. This is a Kodak film target, scanned with a 
  scanner that adds a huge violet cast. Don't worry, the profile 
  will turn this one to a nice looking image.
  
  Since this is a Kodak target that has some additional patches
  (those on I,J,K,L - 20,21,22) we can choose a picker template
  according the nature of target. Press \emph{Options} tab, and in the
  combo labeled \emph{Pick template} select:
  
  \emph{IT8.7 19+3 (Kodak) column picker}
  
  Press \emph{Image} tab.
  
  You will see a lot of green rectangles. Using the mouse you 
  must place the pick template over the patches. Use left button to
  move whole template and right button to resize it. Since this
  image is not perfectly horizontal, you may want to ``unshear'' the 
  layout: You can do it by pressing \emph{Ctrl} key while dragging with 
  left mouse button.
  
  The ``hot area'' is marked with green rectangle. Assure all green
  rectangles are inside patches. Failure to do so could result in
  wrong profile! You can also adjust the relative size of ``hot
  areas'' by setting the \% in \emph{safe frame} on \emph{Options} tab.
  Normally there is no need to touch anything.
  
  Once you were happy with the location of patch grabber zones,
  press the \emph{Pick} button, placed on left side of window.
  
  The measurement tool will build a IT8 sheet containing RGB
  values of each of your patches. Now you can save this sheet by
  pressing the \emph{Save IT8 sheet} button. For our tutorial I will
  name this measurement \texttt{scandmo.it8} and will place it on
  \texttt{pics} directory. (There is already one \texttt{scandmo.it8}, that you
  can overwrite)
  
  Our work with measurement tool is now done. We have right now
  the reference sheet of target, which is given by Kodak, and the
  RGB values obtained by our scanner. Now we can compare these
  files to create a profile.

  \item[Step 4:] Close the measurement tool, and launch the 
    scanner profiler by typing:
    \begin{verbatim}
      ./qtScannerProfiler
    \end{verbatim}
    %
    From here is quite easy. First we must select the target
    reference. In this tutorial, we have used a film target of
    reference 1996-08, so, press the \emph{Select target \& vendor type}
    button and select \emph{targets}, \texttt{Kodak} folder, then \texttt{Emissive}
    folder (since it is film). Press Ok. The left combo will be
    filled with all target references. Then select 1996-08 (is on
    last part of list)
    
    Once selected, you need to specify your measurement. Press the
    \emph{...} button placed on right side of \emph{Measurement} edit. Select
    \texttt{picts} folder and \texttt{scandmo.it8} file.
    
    Now we have to specify the profile filename. Press the \emph{...} button
    placed on right of \emph{output profile file}, select the \emph{profiles}
    folder. The name could be \texttt{scandmo.icm}.
    
    You can now, as we did in the monitor profile, fill some info to
    help us to locate the profile latter. Press the \emph{profile
    identification} tab, and fill in the fields.
    
    You are ready to generate the profile. Press \emph{GO!} button to
    launch the profiler process. After a few seconds, you will have
    a small profile for your scanner. In the demo, the obtained dE is
    about 1.24, which is reasonably. Now,  we can better a lot the 
    error level, but this will take more time to generate the profile.
    Press the \emph{Parameters and tweaking} tab, and select on
    \emph{Resolution} group \emph{33 points}. Then check the checkbox labeled
    \emph{local convergence analysis}. Press the \emph{GO!} button. Now the
    generation will take a while, but the obtained profile has
    bettered a lot... maximum dE is about 0.7 and the peak value is
    as small as 3!!!
    
  \item[Step 5:] Let's check how this profile does affect the 
    original image.
    
    Start the measurement tool, select \emph{options} tab and make sure
    picker template is set to \emph{empty picker}, \emph{input profile} should
    be set to this newly created scanner profile, and \emph{monitor
    profile} should be the profile we have made for monitor. Press
    \emph{Image} tab, press \emph{Load Image} button, load the scanned image
    (\texttt{scandmo.png} in our sample) and then press the \emph{proof} button to
    see the results. The girl's image is dark, this is normal.
    However, rest of patches are hugely modified, the grayscale
    should appear smooth and without any cast, as well as all violet
    tint should disappear.
\end{description}


\section{Making workspace profiles}

Some applications, for example Adobe Photoshop, does use what is
called ``Workspaces''. These are RGB color spaces, which are not
intended to be representing any device, nor storage but a
``working space''. That is, image processing operations are
performed in such space, and also can be used as a way to 
interchange image data between applications.


The monitor profiler, despite its name, can be effectively used
to build such profiles. 

Just select the gamma, primaries set and white point. Press \emph{GO!}
and the workspace profile will be generated.


\section{Building accurate monitor profiles by hardware measurement devices}

To measure your monitor, you need to fill a IT8 sheet,
containing XYZ measurements for several RGB combinations. A
sample sheet of this kind can be found in \texttt{pics} directory. The
file is called \texttt{sRGB.IT8} and it measures an ideal sRGB monitor.

You need to change the XYZ values by those read by your
measurement device. Don't put any Lab value, just RGB and XYZ.

Please keep the RGB values the \texttt{sRGB.IT8} has. Optionally, you can 
use more patches to assure consistent color reproduction, but make 
sure to include at least that ones.

Note the big amount of gray patches needed. You can also add as
many as you wish, on more gray patches, better linearization
curves control. You must specify at least 16 gray patches.

Now we will try this procedure, no matter you have not any
hardware device. As we will see below, this method could be used
to dissect profiles and do some tweaking.

We are going to generate a sRGB profile, by using the \texttt{sRGB.IT8}
measurement sheet. For that, we will use monitor profiler, so
start it by typing:
%
\begin{verbatim}
  ./qtMonitorProfiler
\end{verbatim}
%
Now, we are going to use it in advanced mode. Select the radio
button labeled:
\begin{itemize}
  \item[] \emph{I want to build accurate profile from measurement sheet}
\end{itemize}

Then press the \emph{...} button located at right of edit. Select in
\texttt{pics} directory the file called \texttt{sRGB.IT8}. In the \emph{Output
profile file}, select a new profile in \texttt{profiles} directory.
Call it texttt{my\_sRGB.icm}.

I will use this sample to present another utility, the profile
checker. Since the profile checker can understand advanced tags,
we want to include all information in the profile, so select the
\emph{parameters and tweaking} tab, and make sure to select \emph{Verbose,
store anything} in the \emph{profile verbosity level} group.

Now, fill the info fields if you want (again, I recommend to do
that) and press the \emph{GO} button. A new \texttt{my\_srgb.icm} profile will
be created.

We will check now how accurate is this profile. Start the
profile checker program by typing
%
\begin{verbatim}
  ./qtProfileChecker
\end{verbatim}
%
The profile checker is a tool for inspecting some of profile
internals. In our case, we want to check the accurancy. For
selecting the profile, press the \texttt{..} button on the right side
of the \emph{profile} edit. Select \texttt{pics} directory, and choose
\texttt{my\_srgb.icm} profile. Press \emph{GO!} button.

On \emph{dE report tab} you will see the error statistics. (unless
you forgot to set the profile verbosity to \emph{store anything}) 
Our sample scored 0.18, which is a incredibly low value, not 
to be even reached in real world cases, but this could give 
an idea of the precision the profiler can give with only a 
very few measurements.


The profile checker has also the capability of draw chromaticity
diagram, to show primaries, color displacements, to guess the
gamma of the profile and many other functionality. Feel free to
experiment, the profile checker will never write on your
profile, so you can play with it in a safe way.

\section{Additional utilities}

Finally, there is a additional command-line utility that can be
used in conjunction of monitor profiler. It is called \texttt{icc2it8}
and is placed on \texttt{ICCtoIT8} directory. This utility is capable of
generate IT8 measurements from profiles, so, it can be used as a
``profile tweacker''. You can generate a IT8 sheet from a given
profile, then edit manually XYZ values and then build a new
profile using the modified sheet. This right now is limited to
matrix-shaper profiles, but even with this small limitation, 
it can become a valuable tool. 

Other useful tools are included in littlecms CMM package. 
You have \texttt{TIFFICC} that can be used to apply profile transforms
to TIFF files, and \texttt{JPEGICC} that does same on JPEG. Also, 
you have \texttt{ICCTRANS}, that can be used to check profiles
by numbers. See the littlecms documentation for more details.


That's all for now. There are still many options that this small
introduction don't cover, like the CIECAM97s appearance model,
and a more advanced usage. However, you have now a basic
knowledge of how this stuff works. There is a mailing list on
littlecms for asking and sharing your tricks on how get the best
from littlecms profilers. Feel free to ask.
\begin{verbatim}
  http://lists.sourceforge.net/lists/listinfo/lcms-user
\end{verbatim}

Enjoy!

\end{document}
