From: tgl+@cs.cmu.edu (Tom Lane)
Newsgroups: comp.graphics,alt.graphics.pixutils,alt.binaries.pictures.utilities,alt.binaries.pictures.d
Subject: Re: JPEG "Standard"
Summary: the difference is quantization before compression
Date: 8 Jan 93 20:57:18 GMT
Article-I.D.: cs.C0JzJJ.Hup.2
Followup-To: comp.graphics
Organization: School of Computer Science, Carnegie Mellon

kxj6@po.CWRU.Edu (Kijin Jung) writes:
> I was concerned about the standardization of JPEG
> between two programs I have, so I did some tests.
> 
> ... I compressed them using ColorView 2.0 for DOS
> and WinJPEG 1.6. (The reason why I used a quality of
> 74 and 76 for Colorview was because it did not
> offer 75 as an option; so I also used those settings
> for WinJPEG.) Also, Cview only accepts BMP files.
> 
> Cview's JPEG output is much smaller than those of WinJPEG
> for a given Quality.

I'm guessing that you proceeded by loading and displaying the image, then
using "Save".  This is a bad move since both programs will quantize the
24-bit image down to 8 bits for display (assuming your display hardware is 8
bits).  JPEG is intended for compressing 24-bit data, not 8-bit; your JPEG
files are larger and of lower quality than they would be if you had made
them directly from the Targa or BMP file.

WinJPEG has a "batch conversion" option which allows direct compression of
Targa to JPEG format without a quantization step.  This is a much better
means of compressing full-color images.  As far as I can tell, ColorView has
no similar capability.

The difference in file size is due to Colorview and WinJPEG using different
quantization algorithms; hence the data fed to the JPEG compressor is not
the same.  In particular, I'd bet you had dithering turned off in ColorView.

> Which program adheres closer to the Quality settings
> described in the JPEG FAQ?

ColorView and WinJPEG use the same JPEG compression software (the free JPEG
code provided by the Independent JPEG Group).  Their Q scales are the same.
ColorView's user interface is a little bit weird, I don't know why they
chose to provide only the Q values they did.

> Exactly what is entropy optimization and how does it affect
> the quality of the compressed image? (Should it be used if
> I want a "standard" Q75 JPEG file?)

Entropy optimization picks an optimal Huffman code table for the particular
image, instead of using a default Huffman table.  It typically makes the
JPEG file a little smaller, but there is no change in image quality.  Any
non-broken JPEG decoder should be able to deal with optimized files.

> I am very confused by WinJPEG's method of saving JPG's.
> WinJPEG takes two original files of the same content but
> different format, yet outputs JPEG files of different sizes
> (with entropy optimization on).

That seems strange to me too.  Could it be that there is some history
dependence in their color quantization algorithm?  Are you *sure* the
BMP and Targa files are identical?

> And for those who have PhotoStyler 1.1a: how does the
> quality range in the JPEG export module translate to the
> quality range described in the FAQ? (PhotoStyler uses
> a range from 0 to 100, with 0 being minimal compression,
> 100 maximum - just the opposite of convention).

Good question.  Quality settings are not defined by the JPEG standard, they
are a user interface feature that can and does vary between implementations.
The quality settings described in the FAQ apply to the IJG software and
programs based on it, but PhotoStyler probably wrote their own JPEG code
and did something completely different.

> What the heck is the difference between YUV422 and YUV411 SubSampling?

The difference is how much the color information gets reduced.  If you have
v4 of the free JPEG software (cjpeg), these formats correspond to
"-sample 2x1" and "-sample 2x2" respectively.  Most decoders handle both.

			regards, tom lane

PS: learn how to do cross-posting properly.  Posting separately to each
group is NOT the right way --- I still don't know if I have found all the
groups that you posted in.
Newsgroups: comp.graphics,comp.graphics.visualization,comp.multimedia,comp.org.acm,alt.graphics.pixutils,comp.graphics.animation