Vous êtes sur la page 1sur 15

A few scanning tips

www.scantips.com

Web scantips.com

JPEG - Joint Photographic Experts Group

(.JPG file extension, pronounced Jay Peg). This is the right format for
those photo images which must be very small files, for example, for
web sites or for email. JPG is often used on digital camera memory
cards, but RAW or TIF format may be offered too, to avoid it. The JPG
file is wonderfully small, often compressed to perhaps only 1/10 of the
size of the original data, which is a good thing when modems are
involved. However, this fantastic compression efficiency comes with a
high price. JPG uses lossy compression (lossy meaning "with losses to
quality"). Lossy means that some image quality is lost when the JPG
data is compressed and saved, and this quality can never be
recovered.

File compression methods for most other file formats are


lossless, and lossless means "fully recoverable". Lossless compression
always returns the original data, bit-for-bit identical without any
question about differences (losses). We are used to saving data to a
file, and getting it all back when we next open that file. Our Word and
Excel documents, our Quicken data, any data at all, we cannot imagine
NOT getting back exactly the original data. TIF, PNG, GIF, BMP and
most other image file formats are lossless too. This integrity
requirement does limit efficiency, limiting compression of photo image
data to maybe only 10% to 40% reduction in practice (graphics can be
smaller). But most compression methods have full lossless
recoverability as the first requirement.

JPG files don't work that way. JPG is a big exception. JPG
compression is not lossless. JPG compression is lossy. Lossy means
"with losses" to image quality. JPG compression has very high
efficiency (relatively tiny files) because it is intentionally designed to
be lossy, designed to give very small files without the requirement for
full recoverability. JPG modifies the image pixel data (color values) to
be more convenient for its compression method. Tiny detail that
doesn't compress well (minor color changes) can be ignored (not
retained). This allows amazing size reductions on the remainder, but
when we open the file and expand the data to access it again, it is no
longer the same data as before. This lost data is like lost purity or
integrity. It can vary in degree, it can be fairly good, but it is always
unrecoverable corruption of the data. This makes JPG be quite
different from all the other usual file format choices. This will sound
preachy, but if your use is critical, you need a really good reason to
use JPG.

There are times and places this compromise is an advantage. Web


pages and email files need to be very small, to be fast through the
modem, and some uses may not need maximum quality. In some
cases, we are willing to compromise quality for size, sacrificing for the
better good. And this is the purpose of JPG. There is no magic answer
providing both high compression and high quality. We don't get
something for nothing, and the small size has a cost in quality. Still,
mild quality losses may sometimes be acceptable for less critical
purposes. The sample JPG images on next page show the kind of
problem to expect from excessive compression.

Even worse, more quality is lost every time the JPG file is compressed
and saved again, so ever editing and saving a JPG image again is a
questionable decision. You should instead just discard the old JPG file
and start over from your archived lossless TIF master, saving that
change as the new JPG copy you need. JPG compression can be
selected to be better quality in a larger file, or to be lesser quality in a
smaller file. When you save a JPG file, your FILE - SAVE AS dialog box
should have an option for the degree of file compression.

Many programs (Photoshop, Elements, PhotoImpact, PhotoDeluxe) call


this setting JPG Quality. Other programs (Paint Shop Pro and Corel)
call it JPG Compression, which is the same thing, except Quality runs
numerically the opposite direction from Compression. High Quality
corresponds to Low Compression. Typical values might be 85 Quality,
or 15 Compression. These numbers are relative and have no absolute
meaning. Compression in one program will vary from another even at
the same number. The number is also not a percentage of anything,
and Quality 100 does NOT mean no compression, it is just an arbitrary
starting point. JPG will always compress, and Quality 90 is not so
different from Quality 100 in practice. There's very little improvement
over 95.
Digital cameras also offer JPG quality choices too. Large image files do
fill memory cards fast. You can buy more and larger cards, or you can
compromise by sacrificing image quality for small file size (but I hope
you won't go overboard with this). The camera menu will have two
kinds of resizing choices. One size choice actually creates a smaller
image size (pixels), resampled smaller from the original standard size
of the CCD chip, for example perhaps to half size in pixel dimensions.
The correct image size in pixels is related to your goal for using the
image. For example you may need enough pixels to print 8x10 inches
on paper (6 megapixels), or you may only want a small image for
video screen viewing (1 megapixel).

Regardless of that selected image size in pixels, the camera menu will
also offer a smaller file size choice in bytes, related to quality, via JPG
file compression. This menu will offer a best quality setting which is
the largest file, and maybe intermediate sizes, and a smallest but
worst quality choice. My Nikon D70 offers three JPG file size choices of
Fine (about 1/4 size in bytes), Norm (about 1/8 size in bytes), or Basic
(about 1/16 size in bytes), comparing compressed file size to the
uncompressed size. The best (largest) JPG file size will still contain JPG
artifacts, but very mild, essentially undetectable, vastly better than the
smallest file choice. Even better, some cameras also offer a RAW or
TIF format to bypass JPG problems all together. These images may be
large, but memory cards are becoming less expensive ($100 for 1 GB),
and larger or multiple cards are by far the best quality solution.

With either scanner or camera images, individual image JPG file sizes
will vary a little, because detail in the individual image greatly affects
compressibility. Large featureless areas (skies, walls, etc.) compress
much better (smaller) than images containing much tiny detail all over
(a tree full of leaves). Therefore images of the same size in pixels and
using the same JPG quality setting, but with differing image content,
will vary a little in JPG file size, with extremes perhaps over a 2 to 1
range around the average size.

Since each image varies a little, the file size is only a crude indicator of
JPG quality, however it is a rough guide. For ordinary color images (24
bit RGB), the uncompressed image size when opened in memory is
always 3 bytes per pixel. For example, an image size of 3000x2000
pixels is 6 megapixels, and therefore by definition, when
uncompressed (when opened), this memory size is 3X that in bytes, or
18 MB. That is simply how large the 24 bit data is. The compressed
JPG file size will be smaller (same pixels, but fewer bytes). A High
quality JPG file size might be compressed to 50% to 25%
uncompressed size (bytes). A JPG file size only 10% of that image's
size in memory would the general ballpark for a fair tradeoff of quality
vs. file size for color images of web page quality (but not best quality).

The 10% size is not very precise, but of course only refers roughly to
the average image size, since each individual image varies a little.
Color compresses better than grayscale files, so grayscale doesn't
decrease as much. These are very rough guidelines, your image, your
photo program, your purpose, and your personal criteria or tolerance
will all be a little different.

It is difficult to describe the JPG quality losses, except by seeing an


example image (next page). JPG does not discard pixels. Instead it
changes the color detail of some pixels in an abstract mathematical
way. JPG is mathematically complex and requires considerable CPU
processing power to decompress an image. JPG also allows several
parameters, and programs don't all use the same JPG rules. Programs
vary, some programs take shortcuts to load JPG faster but with less
quality (browsers for example), and other programs load JPG slower
with better quality. Final image quality can depend on the image
details, on the degree of compression, on the method used by the
compressing JPG program, and on the method used by the viewing
JPG program.

Continued, JPEG Artifacts

Copyright © 1997-2008 by Wayne Fulton - All rights are reserved.

A few scanning tips


www.scantips.com
Web scantips.com

JPEG Artifacts

I am sent JPG images with questions why they appear "bad" and very
"unclear", when the only problem is excessive JPG compression, too
much, or saved too many times, or both. Too little Quality or too much
Compression will affect JPG image quality visibly. It can be awful.

You can and should learn to recognize this bad effect yourself.
It's easy to recognize, almost trivial, after you've seen it once. Then
you will know if it is acceptable or not, and you will know that you
have choices.

How to see JPG artifacts the first time

If using a digital camera, shoot the same scene as the best file format
you have, a RAW or TIF file, or at least at the best JPG quality setting
(largest file). Also shoot exactly the same scene at the lowest JPG
quality setting (smallest file). If using a scanner, scan a new photo
image and save it as a TIF file. Then, after that, also save the same
image as a JPG file using more compression than usual, a lower JPG
quality setting this one time to help learn to see it. Then close that JPG
image, and reopen that file to be sure you are viewing the contents of
the file image you actually wrote (instead of the uncompressed image
on the screen that you thought you wrote).

Then examine both large and small file images side by side on the
same screen, by zooming in to about 4 times size (400%,
huge) on both. You will have to scroll around on them, but the 400%
is to help you learn to recognize the artifacts this first time. The
differences you see are the JPG artifacts of compression.

The visible signs of excessive JPG compression are JPG artifacts,


which include:

• Areas of similar color (generally featureless areas like skies or


walls) become "blocky", with tile-like squares that are 8x8 pixel
blocks of one color (compresses well), or which may contain
horizontal or vertical patterns at extremes. You see the 8x8
squares, like big pixels, but at 400% zoom, you can recognize
the size difference in the pixels (jaggies) and the 8x8 pixel
blocks.
• The sharp contrasting edges in the image will have "vague dark
smudges" surrounding the sharp edges. This is normally the
worst effect in most images, it obsures detail. Excessive JPG
compression is tough on all sharp edges in the image (especially
so for text and graphic images). This is very counterproductive
to apparent sharpness and fine detail.
• Some false color or color changes.

Here are samples below, zoomed large, but same size and side by side
for comparison, to better learn to recognize the JPG artifacts (that is a
cookie jar at left, with a little reflection on it)
Original TIF image ABOVE, zoomed to 300% size

Low Quality JPG image BELOW, zoomed to 300% size


Not that it seems necessary, but I have marked a few of the 8x8 pixel
blocks seen in areas of similar color, and also some of the smudging
around sharp edges (all edges). You can find more almost any place in
the image. Notice the missing detail at the ridged knob marked in
blue. The two power cords behind the fruit are nearly obscured by JPG
artifacts. The tiny jaggies in the TIF are the original pixels zoomed to
300%. Their size is a guide to show the larger JPG 8x8 pixel blocks are
clearly a different artifact.

Zooming to 300% size is not the normal thing to do, but it does help
to recognize these JPG artifacts the first time. After you learn what you
are looking for, then you can recognize them at 100% size too.

This sample shows what is meant by "lossy compression" in JPG - the


losses are from deteriorating image quality due to the JPG artifacts.
Using a Higher JPG Quality setting to produce a larger JPG file
improves the JPG image quality. Using a Lower JPG Quality setting to
produce a smaller file makes it worse. That seems straight-forward. A
High JPG Quality setting of 8 or 9 (assuming a 1-10 scale, but 80 or 90
on a 1-100 scale is used by some software - same thing) is normally a
pretty good image, normally not much problem for read-only uses, like
viewing or printing (both zoomed images above are in a High quality
JPG now for web presentation). The problem then is when you want to
edit the image and save it yet again as JPG (additional JPG artifacts
accumultate each time). We should only save a JPG image ONE TIME.

Note that most other types of image file compression (for example
PNG or TIF LZW) are lossless compression, meaning that there is
absolutely no loss of quality due to compression (zero loss), so that
then file quality is simply not an isssue at all, and the most critical user
need not ever worry about it. The TIF file above used LZW
compression. However lossless file compression is less effective,
meaning that it can not produce files so drastically small as JPG. The
lossless file size is closer to the actual size of the color data, perhaps
70% or 80% instead of 5% to 20%.

I want to call this JPG an extreme example, and it is poor, but it is not
extreme. You ought to see some of the images that people send me
asking why their images are so poor. This JPG was done in Photoshop,
and Adobe's lowest quality settings are conservative, and won't let us
make them as extreme and poor as some other programs will. The JPG
quality numbers like 8 or 9 are NOT absolute values, instead they are
relative to the JPG properties that each program chooses to
individually use.

JPG artifacts do vary, and this will be of more concern when you do
this same test on your own images. Once you realize what you are
looking for, then JPG artifacts are easy to see and recognize at 100%
size. Some people are more critical than others, asking "How good can
I make it?" instead of "How small can I make it"? Your priorities are
your own, but afer you are able to recognize JPG artifacts, you will be
able to judge how much of this you want in your own images.

Here is another older sample showing JPG artifacts.

Use a higher JPG Quality factor to minimize these effects (or don't use
JPG at all if maximum quality is important). Less JPG Quality is more
JPG compression, a smaller file, but worse artifacts. Normally you may
detect some artifacts even at high Quality factors, and you can learn
to recognize this easier if you zoom in to about 400% size. But the
image can still be very usable size if the compression is mild. Now you
know what to look for, and how to look for it, and how to judge if you
want it or not.

The JPG artifacts become part of the image data, and it cannot be
removed. Sharpening again after JPG compression (next time) will
emphasize these JPG artifacts, so be careful with that. Actually, very
slight intentional softening or blurring before JPG compression will help
minimize the effect of the JPG artifacts (and will slightly reduce JPG file
size too).

JPG normally should not be used for text or graphic images. It


obscures the sharp edges too much, and the results are typically poor.
TIF LZW, PNG, and GIF are vastly better for line art or graphic images,
and these will normally compress text and graphics effectively. The
way to make a scanned text document PDF file smaller is to scan in
Line art mode and use compression. Acrobat will use G4 compression
which is very small for line art, but LZW is good too. For text, line art
will be smaller and better result than a JPG grayscale file. JPG cannot
handle line art or indexed color anyway, JPG requires 8 bit grayscale
or 24 bit color. However for continuous tone photo images, as opposed
to text or graphics, then files with high JPG Quality (low compression)
are normally acceptable for viewing (read-only purposes), and the
small file size is extremely desirable for modems.

Due to the quality concerns, JPG compression is generally NOT suitable


for archiving the important master copy of your image. With only mild
compression, it might view OK, but you should grit your teeth, hold
your breath, and cross your fingers for luck, if you ever have the need
to modify and save a JPG file again. Because this will lower the quality
of that image even more, every time you save the file. By "save", I
mean to select the FILE - SAVE or FILE - SAVE AS or FILE - SAVE FOR
WEB menu with JPG format from an image program. That SAVE step
does the JPG compression again.
Note that downloading, or copying, or opening and viewing JPG files is
no problem at all. This does not save the file again, and it does not
alter the file in any way, so it does not create more artifacts. You can
open and view a JPG file a jillion times without any concern (a web
page for example). The artifacts are created only when the data is
compressed for saving it as a JPG file. This happens only at the menus
FILE - SAVE or FILE - SAVE AS or FILE - SAVE FOR WEB when you
select JPG format.

Archive your important master copy images in a non-lossy format (TIF


LZW and PNG are very good, and compress moderately), and then also
make a JPG copy if needed for view-only purposes that need it to be
smaller, like email and web pages. You won't gain any quality by
converting JPG to TIF now, because that image copy will still contain
the JPG artifacts it had before. It is part of the image now, there is no
way to improve it again. However, if you do need to edit a JPG, then
saving it as TIF will prevent adding more artifacts by not doing another
JPG Save, so TIF would be a good plan then.

If you find that you must edit the JPG image and must save it as JPG
again, at least try to use the same program and same value of Quality
or Compression every time you save the file. Using different values will
use different parameters that will aggravate the damage due the lossy
compression. I am certainly not suggesting repeated saving of JPG
files with the same parameters is a good thing, but only that there are
even worse ways to do it.

JPEG Lossless Rotation

Sometimes for viewing, we need to rotate an image beween horizontal


or vertical (Landscape or Portrait), without needing any other editing
operations. But if you save that rotated image as JPG, that is another
SAVE operation and additional JPG artifacts. But there are image
programs that can rotate a JPG file image exactly 90 or 180 degrees,
and then save it again without additional loss, by rotating it without
uncompressing and recompressing it first, thus preventing any
additional JPG artifacts. This option merely rearranges the row and
column data, without uncompressing that data. So while the JPG file
itself is still lossy, the lossless rotation does not create additional
artifacts.

Jpegclub.org has a list of programs that support this lossless rotation


feature. Standard photo editor programs typically do not provide this
option, but a few of the better known programs that can do this are
IrfanView Free, Windows
GraphicConverter Trail available, Macintosh
ThumbsPlus Trial available, Windows

IrfranView needs its free extra JPG plugin package to provide lossless
rotation, which is then found at menu Options - Lossless JPG
Operations when the JPG file is open.

Irfanview also shows the JPG EXIF information well (Exchangeable


Image File Format) - extra file data added by cameras showing
information like camera name, date, f-stop, shutter speed, exposure
compensation, metering and flash used, etc.

Continued

Copyright © 1997-2008 by Wayne Fulton - All rights are reserved.

A few scanning tips


www.scantips.com

Web scantips.com

More Preaching, but it is important

JPG format has a magic status for us. JPG is wonderful when the
purpose is right, but we need to understand we pay a cost in quality. I
know you surely will consider using JPG for master copies, everyone
does at first, because the JPG file is so small, and the idea is frightfully
appealing. But it's a high price paid in lost quality, and you will
eventually come around to appreciate the quality of TIF files. I hope
that happens before you have damaged important images that you
cannot scan again. Some people argue that high quality JPG masters
are not so bad. That's OK with me, it's your file, but the file size is one
property of an image, and quality is another. You can choose either
way, and I hope you choose Highest Quality, at least for your master
copies. My goal is that you understand the effects of your choice in
regard to your valuable master copies.

If you simply must use JPG for your master copy (if file size is the
most important property of this image), then at least use the best
Quality you can. Aim for a average JPG file size at least as large as
25% of its true memory size. For web images, file size is indeed
important, and absolute quality is less important, and a JPG file size
10% of uncompressed size is often a good tradeoff of quality for size
for color images, but that is too extreme for any notion of a master
copy. Grayscale images do not compress as much as color at the same
settings. Grayscale is already 1/3 the size of color, and grayscale JPG
files won't compress as much.

Then keep a master copy that you never rewrite. For any purpose,
always start with a copy of that JPG master and never modify that JPG
master itself. Saving that JPG master image again causes more
artifacts, even more loss, permanent loss, so simply don't do it. If you
simply need to rotate to vertical, or to scale for printing, consider not
saving that simple change at all if it is trivial to do again. Save any
change to a different file, and never make your one master copy
worse. Or save the change to a TIF file, so as to not create more JPG
artifacts. You could of course just use a TIF master instead, and sleep
better at night. And be aware that lowering scan resolution to
reasonable values for the purpose is often the best size reduction you
can make.

Judge your own common sense periodically. Why can't we see that a
decent JPG image compressed to be only 25% of original size (1/4
size, still amazingly small, and still with mild artifacts), is more useful,
and a much better deal, than one at 5% size that is simply too awful
to use? I know, the macho types are saying "but I can get it down to
3%". Then go for it man! <grin>

For emailing and for web pages, JPG file format is the smallest by far,
and the best goal by far (for photo images). JPG is acceptable for such
read-only "viewing" use, and a JPG copy normally is used for such
purposes. JPG is NOT very acceptable for "editing" use, when you may
need to edit and save the image again (we always do). JPG is best
only for photographic images. For line art and graphic files
(characterized by containing graphic sharp edges and very few but
solid colors), then TIF LZW or PNG is good, or GIF files too, which have
historically been used for graphics on web pages.

The process of saving a JPG file to disk first compresses the image
data to make the file be much smaller. This JPG compression affects
the image quality, because JPG compression uses a very different
technique than does PKZIP or TIF LZW or PNG file compression (lossy
vs. lossless). JPG compression is extremely effective, because it does
not attempt to be 100% faithful to the original image data. If parts of
the image data are a problem for it, the JPG compression simply
modifies that data to make it conform better. That means when we
read that JPG file later, we don't get back the same original image
data (that is the meaning of lossy, losses of image quality). Also the
software opening that JPG image does a similar thing when it reads it.
It does not necessarily show exactly what is in the file, it can also take
similar liberties. Web browsers for example are not the best JPG image
viewers, but they are the fastest JPG viewers.

Every time we save a JPG file (menu FILE - SAVE AS - JPG), it


compresses again, and image quality is lost. This loss is variable,
depending on the JPG Quality factor used, but it is never zero. If we
edit the JPG file image and save it again, then quality is lost again.
Even if we save it at a much higher quality setting the second time, it
is still a second compression and another loss. Every time we
compress a JPG file, we add more JPG artifacts and lose a little more
quality. Artifacts are always a one way trip, there is no recovery. The
damage is done.

Most other file formats (say TIF or PNG) use lossless compression.
These files are larger than JPG because they use milder, fully
recoverable (lossless) compression to carefully preserve all of the
original image data. These file formats remain full quality at all times,
no matter how many times we might save them to a file, which is of
course exactly what is needed for a master copy.

The small JPG file size is great, but it has a big price of reduced
quality. There are proper times and places one would use it, and also
major reasons one would not. There's nothing wrong with creating a
JPG image using a moderate to high Quality factor to put a photo
image on a web page or to send it via email. It's the only practical
way. However there is an additional quality loss when we try to edit
and save that JPG file a second time, so JPG is usually inappropriate
for important archived master copies. The risk if you make this
mistake now is that you cannot undo it in the future, so now is the
best time to understand the situation.

See the very worthwhile JPG FAQ by Tom Lane

Progressive JPG is a web option that quickly shows the entire image in
very low quality, and the quality fills in and improves as the file
download completes.

JPEG 2000

A new JPEG 2000 file format is available now in many newer program
versions, with various file extensions, normally .jp2 (or .jpx, with
option extensions). JPEG 2000 uses a wavelet compression method. It
has a lossless option (to perhaps 65% size). Otherwise it is lossy, size
comparable to regular JPG files, but different... slower then JPG, but
arguably perhaps better quality. Extremes of compression have few
detectable artifacts, however JPEG 2000 images become noticeably
soft with greater compression.

Paint Shop Pro 8 and PhotoImpact 8 started including JPEG 2000.


Adobe Elements 3.0 includes JPEG 2000. Elements 2.0 has an update
to add JPEG 2000 - at the How To palette, Select a Recipe, Download
New Adobe Recipes, then (very important) the BACK button, and you
will see it. Photoshop has an optional JPEG 2000 plugin from CD, see
JPEG 2000 at the CS or CS2 Help menu.

Note that web browsers do NOT support JPEG 2000 yet, and so
compatibility is still a very significant issue. Therefore it seems
important to stay with the original JPG format for now, at least if you
want others to be able to open your files.

Copyright © 1997-2008 by Wayne Fulton - All rights are reserved.

Vous aimerez peut-être aussi