What exactly does "subsampling factor" do?

Ask for help and post your question on how to use XnView Classic.

Moderators: XnTriq, helmut, xnview

User avatar
Troken
Posts: 698
Joined: Thu Feb 09, 2006 10:18 am
Location: Sweden

What exactly does "subsampling factor" do?

Post by Troken »

Hello,

could somebody help me? When exporting a JPG, there is three different "Subsampling-factor" alternatives. What is the difference? I can clearly see differences in the output, but other than that? Is there an alternative thats overall better?

I.e. red colours seem to get low detail and darker with the default subsampling-factor.

Could not find an explanation in the help-file.
User avatar
JohnFredC
XnThusiast
Posts: 2010
Joined: Wed Mar 17, 2004 8:33 pm
Location: Sarasota Florida

Post by JohnFredC »

Here is a good over-view of jpg compression in general, with a link to more details about subsampling etc.

This is a very interesting, albeit technical, topic.

The JPEG standard allows for changing the "sub-sampling" of the image. Sub-sampling settings can adjust the amount of "down-sampling" the compression algorithm performs on the image. Down-sampling reduces the amount of data used to describe the image. The down-sampling is part of what allows a jpg image to be smaller than the equivalent bmp.

For image (geometric) resolution, down-sampling reduces the number of pixels, hence reducing the size of the image, but also reducing the detail and increasing the aliasing artifacts (for instance).

For color resolution, down-sampling reduces the number of colors in the image (irrespective of the pixel resolution), leading to color banding/posterization effects. Color sub-sampling settings are expressed as 3 numbers (4:4:4 or 4:1:1, for instance). What these numbers mean is tangentially discussed in the second reference cited above.

Those two articles have been very helpful to me in more fully understanding JPEG compression.
John
User avatar
Troken
Posts: 698
Joined: Thu Feb 09, 2006 10:18 am
Location: Sweden

Post by Troken »

JohnFredC wrote:Here is a good over-view of jpg compression in general, with a link to more details about subsampling etc.
A big thank you John. The second link was maybe over my league, but the first seems to be great to start with.

Especially these sentences helps me understand - as a Photoshop user:
"The subsampling ratios according to the spec are 4:4:4 (no subsampling), 4:2:2 (standard subsampling) and 4:1:1. Adobe Photoshop also contemplates this option but it's adjusted automatically depending on the quality level selected: it applies subsampling for Medium and Low levels and uses no subsampling for Maximum and High."

Which makes me question the choise in XnView to use 4:1:1 as a default, 4:2:2 would be better. If you read this Pierre, please consider to change it. Personally, I'll now use 4:4:4, its a noticable quality change, but not such a big increase in filesize.
User avatar
Drahken
Posts: 884
Joined: Sun Apr 10, 2005 4:29 pm

Post by Drahken »

The difference is in the colors. It's most noticeable with red, but it also strongly affects colors in the yellow~green range (blue seems largely immune to it). The subsampling factor is very much like the compression factor in that you trade off quality for filesize. Personally, I never use the lowest setting, the quality is just too terrible. The highest setting is a good compromise for many images, images which you would normally have to choose between using a PNG (which would be several times the size of any comparable JPG), or having a terrible quality image.
In the end, it's really just something that you have to look at each image seperately for. Some don't look too bad at the lowest setting (especially if they started out as a JPG anyway), some look really bad at anything other than the highest setting. The biggest deciding factor is contrast between nearby colors. If you have bright oranges & reds which gradually blend to a darker color nearby, you won't notice much difference at the lowest setting. On the other hand, if you have bold reds & oranges which cut sharply to black or some other high contrast color, the image will look extremely bad at anything other than the highest setting.
User avatar
foxyshadis
Posts: 394
Joined: Sat Nov 18, 2006 8:57 am

Post by foxyshadis »

Just to clear up a technical misconception: There is no 4:1:1 in jpeg (though DV uses it), there's 4:4:4 (1x1), 4:2:0 (2x2), 4:2:2 (1x2), and there's no real name for 2x1's format.

Good jpeg decoders will upsample downsampled chroma so that it's not as obvious. (Good ones will also minimize corruption damage.) Sadly, there are practically no really good jpeg decoders, even xnview's; most of them will just use straight 2x2 blocks of color for the decode.

1x1:
C1 C2
C3 C4

1x2:
C1 C1
C2 C2

2x1:
C1 C2
C1 C2

2x2:
C1 C1
C1 C1

4:1:1, for completeness:
C1 C1 C1 C1
C2 C2 C2 C2