DPReview.com is closing April 10th - Find out more

Impact of Noise and DoF on JPG File Size

Started Sep 20, 2021 | Discussions thread
ProfHankD
ProfHankD Veteran Member • Posts: 9,147
Quick overview of JPEG encoding
3

DJMusic wrote:

I recently did some tests in response to a question on a Facebook group. The question was around JPG files for the D780 that were considerably smaller than their D750 counterparts--same lens, same file size/quality, etc. After I switched to DxO PureRaw, I noticed that the JPGs were considerably smaller, though the images were still quite sharp. This got me thinking about the affect 1) depth of field (DoF) and 2) noise had on a JPG file.

JPEG compression has several key components:

1. Remapping to YUV space from RGB.

2. Removal of much of the U and V precision (maintaining luminance, limiting color).

3. DCT (Discrete Cosine Transform -- frequency domain) on 8x8 pixel blocks.

4. Lossless compression of the results.

1 & 2 are relatively harmless except in that JPEGs will not preserve color edges that are not also luminance edges. 3 & 4 do not handle random noise well. Most JPEG artifacts really come from 3; the DCT is great for compressing regular patterns, but even representing a solid-color 8x8 patch is problematic, and those little square box artifacts seen at high-contrast edges are basically 8x8 DCT artifacts. Blurring or lesser DoF basically reduce the range of frequencies within each 8x8 block, making the DCT more efficient. Incidentally, higher-resolution image of natural scenes tend to compress better then lower-resolution images of the same scene because the frequency domain variance in an 8x8 block tends to be less, which is why 42MP images are often far less than 2X the size of 24MP ones.

Here's an old (but still valid) comparison of how the JPEG quality settings work:

Basically, 100% quality JPEG is far from lossless, but things don't really get blurry at low quality settings. Aside from discarding more color information at lower quality settings, the DCT compression basically just restricts the frequency domain variation within an 8x8 block: you get regular patterns, not exactly blur.

The interesting result of this is that lower quality setting on a higher resolution image often produce a sharper, yet smaller file. For example, setting your camera to do low-quality full resolution JPEG encoding is probably smarter than setting it to do high-quality compression with a lower pixel count. As a simple example, here's a 16,309-byte 128x128 JPEG at 100% quality:

and here's the same image taking just 9,025 bytes as a 256x256 JPEG at 50% quality:

Yes, the smaller file is higher resolution and sharper!

BTW, here I'm talking about 1990s-style JPEGs... which unfortunately is what almost all cameras and software use. The JPEG2000 standard does much better, but it's very different internally, and the old-style JPEG algorithms are embedded in a lot of hardware, so it's a pain to switch. For example, most cameras have hardware JPEG encoders.

 ProfHankD's gear list:ProfHankD's gear list
Canon PowerShot SX530 Olympus TG-860 Sony a7R II Canon EOS 5D Mark IV Sony a6500 +32 more
Keyboard shortcuts:
FForum PPrevious NNext WNext unread UUpvote SSubscribe RReply QQuote BBookmark MMy threads
Color scheme? Blue / Yellow