From: waldin@concerto.lcs.mit.edu (Earl Waldin)
Newsgroups: rec.railroad
Subject: Re: Uploads to wuarchive.wustl.edu
Date: 30 Jul 92 18:30:42 GMT
Reply-To: waldin@lcs.mit.edu
Organization: Laboratory for Computer Science, Massachussetts Institute of Technology

In article <1992Jul30.134228.6385@mksol.dseg.ti.com>, sdejour@mksol.dseg.ti.com (stewart l dejournett) writes:
|> 
|> Can someone tell me why the train files are stored in JPG format.  In the JPG 
|> format you lose image quality.  Also, in /graphics/gif/...  al the files ARE
|> store in GIF format so I don't feel space is the main consideration since there
|> are 1000+ files in /graphics/gif
|> 

As has been pointed out in other picture-oriented groups, BOTH gif and jpg
are "lossy" formats.   The human eye is capable of distinguishing between
thousands of colors.  A 24-bit color scanner does a good job of representing
a picture because it allows 2^24 colors.  However, a 24-bit color image
requires 3 to 5 _megabytes_ of storage, depending on its size and resolution.
Exising loss-less compression techniques will only give you about a
factor of 2, which still leaves you with mult-megabyte images.

Gif is an 8-bit color format, so it only has 2^8 = 256 colors.
Conversion to gif requires losing a lot of color information.  To get
some of this back, conversion uses a process called dithering to trade
off resolution for color.  There are a number of algorithms for
eliminating colors and dithering.

Jpg takes a different approach.  It performs a two-dimensional transform
somewhat akin to a Fourier transform.  It then "smooths" some of the high
frequency components (kind of like a low-pass filter does).  The result is
then compressed using run-length encoding (which does not lose any more
information).  A good-quality jpg image is about a factor of 10-20 smaller
than the original 24-bit image.

If you start with a 24-bit image, then jpg gives a better quality picture
for less storage.  A jpg image requires about 2 to 5 times less storage
than an equivalent gif image.  Jpg also allows you to "tweak" the loss, so
you can determine how much quality to give up in order to reduce the storage.

If you start with a gif file (which has already lost information) and then
compress it further with jpg, then you may or may not wind up with a lower 
quality picture.  My experience with some of the train pictures posted earlier
is that many images are just as good as the original gif, but take half the
storage or less.  Some pictures get totally botched.
I believe it depends on the specific algorithm used to create the gif file
in the first place.

In short, JPG is better if you compress the originally scanned image.
If you only have a gif image, then JPG will probably give you the same
quality as the gif, but save on storage.  Some experimentation and
tweaking is required to determine if it is worth jpg'ing a gif file.

One logistical problem with jpg is that when you decompress it, you have
to convert it for viewing on your monitor, which probably only allows
256 colors.  The quality of the result depends a lot on the software
you use to view the picture on your monitor.  Most of the unix
software out there (like xv) do a very good job of this.  I can't speak
for Macs or PCs.

Another inconvienence is that decompressing a jpg image for viewing requires
a lot of CPU power.  A high-end workstation (like a Dec-station 5000) takes
around 5-10 seconds.  A PC would probably require minutes.

Conversion for viewing is not a problem for gifs because they already
use (at most) 256 colors.


	Earl Waldin
	waldin@lcs.mit.edu
Newsgroups: rec.railroad