dcsimg

Over the Rainbow

Learn how to improve color printing in Linux.

Imagine that you’re working on a report that includes a
full-page color photograph. Your report will be read by the suits
at your company, so you want it to look good. Unfortunately, when
you print it, you discover that the photo has an ugly green cast,
making the people pictured look ill. The image is also pixelated,
with obvious pixel patterns in parts of the photo. You try printing
on different types of paper, with little success. It’s not
your fault — the fault lies in Linux’s printing
system.

This scenario is a common one when printing photo-quality images
in Linux. Although Linux supports a wide variety of printers, many
of these drivers are designed for printing text and simple graphics
(bar charts and the like). Printing photo-quality graphics is a
secondary concern, leading to problems such as green casts.
Fortunately, it’s possible to tweak the Linux printing system
to provide better results, if you find yours are deficient. You can
make a wholesale change to your driver; change resolution and
dithering patterns; and tweak the color balance in several ways to
improve your graphics output.

Before proceeding, please keep one important caveat in mind:
Your monitor and your printer are two entirely different output
devices. If your monitor is calibrated incorrectly, your printed
output won’t match what you see on the screen, even if the
printed output is a more accurate representation of what’s in
your graphics files. Thus, you should perform at least rudimentary
monitor calibration before proceeding. Many Web sites describe this
procedure, which should take just a few minutes.

One of the quicker tools is at "http://epaperpress.com/monitorcal/" class=
"story_link">http://epaperpress.com/monitorcal/
. A site with
more detailed information and test images is "http://www.normankoren.com/makingfineprints1A.html" class=
"story_link">http://www.normankoren.com/makingfineprints1A.html
.
You can adjust the brightness and contrast using your
monitor’s physical controls. To adjust gamma, use the Linux
xgamma command, as in xgamma
–gamma 1.30
to set the gamma value to 1.30. Graphical
tools for doing the job are built into some desktop environments,
too. You can make your changes permanent by editing the X
configuration file (usually "i">/etc/X11/xorg.conf); set the "c">Gamma line in the Monitor section
(you may need to add this line). If you use a desktop
environment’s gamma correction tools, those settings will
probably override the ones set in "i">xorg.conf.

Finding Appropriate Drivers

The first step in optimizing your color print output is to
locate an appropriate driver. Even if your printer produces a page,
you may not be using the best driver, or the best drivers for
printing color photos and text may be different. You should consult
the Linux Printing Database at "http://www.linuxprinting.org/database.html" class=
"story_link">http://www.linuxprinting.org/database.html
for
information on drivers for various printers. You may need to apply
trial-and-error to locate the best driver for your printer.
Usually, though, the driver recommended at Linux Printing is the
one that produces the best output.

Most color printers today work well with the "i">Gutenprint drivers, so this column focuses on those. If
you’re using another driver, some options may differ, but the
basic principles should remain the same.

Here’s a tip: If you install a new driver for your
printer, don’t edit an existing printer definition; instead,
create a new printer definition. For instance, suppose you’ve
got a printer definition called epson that
works for printing text, but produces poor graphics printouts.
Instead of replacing your existing epson
queue, create a new one (say, epson_photo)
for printing graphics. This way, if your new configuration proves
to be unworkable, you won’t have to recreate the old one.

Sometimes the best driver or other settings for printing
graphics is undesirable for printing text; text output may be slow
or ugly. If you create two queues, you needn’t worry; you can
use the old queue for text and the new one for photo-quality
graphics. If your new queue works equally well for text and
graphics, you can delete the old one.

Color Theory

Before tweaking your printer driver’s settings, you must
understand some color theory.

The human eye uses photoreceptors, known as "i">cones, that are sensitive to three different colors of
light: red, green, and blue– the primary
colors. (A second broad class of photoreceptor, the "i">rod, produces no subjective perception of color.)
Because we perceive color through the combination of red, green,
and blue light, it’s possible to recreate any color by
setting appropriate levels of those three colors. This is how
computer monitors and televisions work: such devices contain red,
green, and blue phosphors, or LCDs, which are combined at various
intensities. This is known as an additive
color system.

Light that reflects off a surface, such as a piece of paper,
acquires color by the removal of certain
frequencies of light from the original white (full-spectrum) light
source. This is a subtractive system. The
inks used by color printers work in this way, using cyan, magenta,
and yellow pigments (the three complementary
colors). Cyan is created by the removal of red, magenta by the
removal of green, and yellow by the removal of blue.

Taken together, the result is that color is a question of the
balance between red and cyan, between green and magenta, and
between blue and yellow. A tool that can help you understand the
relationship between these six colors is a color "i">ringaround, as shown in Figure
One
. The figure shows an image with a correct color balance
in the middle surrounded by images that are shifted toward each of
the primary and complementary colors. To correct a color cast in
one direction, you shift the balance toward the opposite side of
the figure.

In addition to overall color casts, images can contain casts
only in certain parts of the image. Shadows
are the dark areas of an image, whereas "i">highlights are the lightest parts of an image.
It’s possible for color shifts to appear in the shadows or
highlights, but not in the mid-tone parts of the image. To some
extent, you can correct for such problems by adjusting the gamma
values in the printer drivers, as described shortly; however, some
problems require complex adjustments to color curves that are only
possible from certain programs, such as the GIMP.

Printing Test Images

Before printing test images, you should be sure that your
printer’s nozzles are all working correctly. Most inkjet
printers provide some means to print a nozzle check page. You can
also align the nozzles on most printers. If necessary, use
nozzle-cleaning or alignment utilities to correct any problems. You
can find Linux programs to help with this task for some printers,
while others offer front-panel buttons to do the job. Some printers
either offer no such tools or require you to run Windows to clean
and align the nozzles.

To test and adjust your printer, you should begin with a test
image. The best choice is an image that’s designed to
demonstrate several aspects of color reproduction. Such images are
available from various online sources, such as the Digital Dog
( "story_link">http://www.digitaldog.net/tips/). Click the
Printer Test File link to download a test file that’s
properly calibrated and that will help you identify a variety of
problems. Load the file into a Linux program such as the GIMP and
print it on the sort of paper you intend to use for photo-quality
printouts. In evaluating the original printout and subsequent
printouts you make after adjusting various factors, pay attention
to several features:

*The black squares at the top
of the printout should each be a unique shade of gray. If you
can’t tell the darkest or lightest squares apart, you may
need to adjust your contrast, brightness, or both.

*The gray squares at the top of
the printout, and in the color chart about 1/3 of the way up from
the bottom on the left side of the printout, should be gray, not an
off color. In the scenario I described earlier, chances are
you’d see a green cast in these squares.

*Skin tones should look
realistic.

*Note the shadows and
highlights in the photos; these may produce off colors, even when
the mid-tones look correct.

Different Linux programs can produce slightly different
printouts. Thus, an appropriate adjustment for one program might
not be perfect for another. In a worst-case scenario, you might
need to create multiple printer queues, one for each program you
intend to use. Chances are just one will suffice, though.

Choosing Resolution and a Dithering Pattern

To begin adjusting your printing settings, you’ll need to
enter the Common Unix Printing System (CUPS)
printing utility. To do so, open a Web browser and enter
http://localhost:631 in the URL field. You
should see the main CUPS configuration page appear. Click Manage
Printers, then click the Configure Printer button for the printer
you want to adjust. The result varies from one printer to another,
but Figure Two shows a typical set of
options.

Figure Two:
CUPS provides tools that enable you to adjust
color balance and other printing options

class="story_image"> "http://www.linux-mag.com/images/2007-01/guru/cups.png" class=
"story_image">

Resolution is an obvious determinant of print quality; the
higher the resolution, the better the result. Higher resolution
usually equates to longer print times, though, so you may need to
choose a compromise setting. Most CUPS-aware programs enable you to
choose your resolution at print time, so you may be able to set a
default and deviate from it on a print-by-print basis. Older
programs don’t support resolution options, though, so you may
want to create multiple queues and set different resolution options
for each one. CUPS sometimes provides two methods of setting the
resolution. In Figure Two, both the Print
Quality and Resolution options do the job. I recommend setting
Print Quality to Manual and using Resolution to set the resolution
to a numeric value.

Most inkjet printers produce colors by squirting dots of ink
onto the paper in an all-or-none fashion; a pixel either has a drop
of ink or it doesn’t. (Ink does tend to spread a bit, though,
which complicates matters.) This contrasts with video displays,
which typically permit hundreds of different levels of red, green,
and blue light. The printer’s situation of having one of a
handful of colors (the number varies from one printer to another)
for each pixel means that the printer driver must "i">dither the available colors to produce subtle shades.
Dithering refers to placing different colors in a cluster to
produce an overall color that’s not available in the
printer’s ink set.

Most drivers provide several dithering options. Search for the
word “dither” on the configuration page. Which method
works best depends on your printer, but with modern photo-quality
inkjets that have more than four ink colors, “Adaptive
Hybrid” or “EvenTone” are good choices. An
inappropriate choice can lead to a speckled appearance or obvious
patterns in the print.

Your dithering choices affect more than just your printout;
different dithering algorithms consume different amounts of CPU
time. Thus, if you want to speed up output but don’t care as
much about output quality, you can select a less CPU-intensive
option, such as the appropriately-named “Fast” and
“Very Fast” options.

Precisely which dithering options are available vary with your
version of Ghostscript and your printer
drivers. Thus, you may want to experiment with dithering options,
particularly if the documentation for your printer driver
recommends use of an option not mentioned here.

Options that are related to dithering are the light color
transition options (“Light Cyan Transition” and
“Light Magenta Transition,” for instance). These
options exist on printers with more than four ink colors, and they
control the point at which the driver transitions from using the
lighter version of the specified ink to using the darker version.
An incorrect setting can produce color shifts or unnecessary
dithering in midtone-to-highlight areas.

Adjusting Color Balance

At this point, you can begin tweaking the color balance. Several
different types of parameters are available for adjustment:

*Overall color
cast.
If an image has an overall color cast, such as those
shown in Figure One, you can adjust the
cyan, magenta, and yellow balance options in the CUPS configuration
screen. For instance, if your printouts have an overall green cast,
you would increase the magenta value. Typically, color balance is
set using values from 0.1 to 2.0, with 1.0 (or “none”)
being the default.

*Color
saturation.
The color bars near the top of the page, the
color matrix near the top on the right side, and some of the images
should help you to judge color saturation. Unfortunately, without
an accurate reference, it may be hard to judge whether your printed
output is properly saturated or produces too much or too little
saturation. Your screen may or may not be a proper reference. One
clue is in skin tones: They can seem dull if color is
undersaturated or too extreme if color is oversaturated. You can
adjust saturation using an option entitled, unsurprisingly,
“Saturation.”

*Contrast and
brightness.
The double strip of gray squares near the top of
the printout can be used to judge the brightness and contrast. If
you’re not satisfied that you’re getting both the
brightest white and darkest black you think you should be getting,
increase the contrast. If you can’t distinguish between the
lightest few or the darkest few squares, then either the contrast
is too high or the brightness needs to be adjusted.

*Gamma
adjustment.
Ideally, the numbers used to describe a color in
a PostScript file and the way the color is reproduced by the
printer will be linearly correlated. Unfortunately, this
isn’t always the case. When this happens for all colors at
once, the result can be odd-looking contrast effects and an overall
dark or light look to the printout. More importantly, if just one
or two colors’ gamma settings are off, the result can be bad
colors in the highlights, shadows, or midtones, but not in other
areas. If you found such effects in your initial printout (or
printouts you’ve made after making other adjustments), you
should try adjusting the gamma values for the relevant channels.
Making such changes is likely to require re-adjusting the overall
color balance, though.

Many of these options offer both normal and fin controls. When a
fine option is available, that value is added to the normal value,
providing finer-grained control over the changes you make.

Most printer definitions offer additional adjustments, many with
mysterious-sounding names. You can find more information in the
Gutenprint user manual, which ships in both "i">OpenOffice.org and PDF format with recent versions of
Gutenprint.

Making the changes described here is likely to take at least
half a dozen test printouts, so be prepared to invest some time,
paper, and ink in the process. Once you’ve tweaked your
printer’s dithering pattern and color corrections, though,
your results will improve. Unless your printer definitions happen
to be perfect “out of the box,” the time and resources
you invest in this process will be well spent.

Comments are closed.