Previous: Outline Up: A Simple Application for Color Naming, Pointing Out, and Selecting
To make the color naming and pointing algorithms work in practice, with
real images, we can no longer avoid the issue of color constancy. The
approach I have adopted to deal with this problem is of a rather pragmatic
nature, and I make no claims about its generality or applicability to other
problems. Nevertheless, the results are interesting, and the approach seems
to be fairly robust with respect to different lighting conditions, and to
some extent even with respect to different sensing devices. It is
presumably related to the ``white balance'' algorithms implemented in home
video cameras and the like, but that is difficult to verify because of the
secrecy surrounding commercial applications.
The first thing that needs to be done, if it hasn't been done already, is to gamma correct the image, to make intensities perceptually linear:
where represents the normalized intensity in
,
represents the gamma correction factor, typically somewhere in the range
, and
represents the gamma corrected intensity. Video
cameras (especially home camcorders) often incorporate gamma correction,
but scanners may not, or may allow it to be specified under software control.
This step is required since the CIE XYZ standard assumes perceptually
linear intensity responses, and also for display on computer (or TV)
monitors. I used a gamma correction factor of
, if necessary.
Next we need to compensate for differences in lighting, both with respect
to intensity and with respect to spectral characteristics. Although the
spectrum of the light source can never be completely recovered from the
image (see Section ), we can use Von Kries adaptation
(Section
) with good results, as long as the spectrum of
the light source is not too wildly skewed or irregular.
In real
camera (and scanner) images it turns out that not only is white not white
(i.e. the RGB values are not equal and unity, viz.
),
but black is often not black either (i.e. the RGB values are not equal and
zero, viz.
). To compound the problem, lighting may
vary considerably across a single image (Figure
).
The ``constancy'' algorithm I have developed searches (a subsampled version of) the image for likely representatives of white and black, and then uses those do to a modified Von Kries adaptation:
where is the ``adapted'' pixel value (an RGB vector),
is the original pixel value,
is the black
representative, and
is the white representative (both RGB
vectors). Finding the black and white representatives works as follows
(regarding an image as a set of pixels for convenience):
where is the set of image pixels, represented as normalized RGB
vectors
in
,
is the subset of
containing potential gray axis pixels, and
and
are the chosen black and white representatives,
respectively. The criterion used to select potential gray axis pixels is
another RMS measure, enforcing a summed square error between pixel
components of less than
. I have obtained good results with
. The black and white representatives, then, are the
potential gray axis pixels with the lowest and highest brightness,
respectively, as determined by a simple sum-of-components measure. A visual
way to think of this process is that it stretches the image's actual gray
axis and realigns it with the theoretical gray axis for perfectly
homogeneous and flat-spectrum lighting, i.e. the line segment
. The procedure is illustrated in
Figure
.
One can image that this procedure might fail on certain images. It is not
meant to be foolproof under any circumstances, but to work well enough for
our purpose on a large class of ``ordinary'' images.
The performance of the algorithm is of course influenced by the choice of
the parameter , and perhaps by the method chosen to compute the
brightness of pixels (or blobs). I have not investigated this in any
detail, but settled on values that seem to work well for the range of
images I have used to test the naming functions on.