Sunday, December 22, 2019

How All JPEG Images are Cobbled at Birth

Everybody knows that JPEG images are prone to compression artifacts. Meaning every time an image is opened (whether altered or not) and re-saved, the tonal structure of the photo is recompressed using the same destructive process. File recompression always causes additional detail to be lost. Every time a JPEG image is adjusted in any way, those original 256 levels of color are redistributed and detail is lost.
Watchtower Full
Watchtower JPEG - All JPEG Images Are Cobbled At Birth
JPEG files offer various levels of file compression and repeated editing and saving causes further 
degradation.
But, that’s the least of the JPEG limitations.
First of all, JPEG is an old format originally designed for a long-past era. A group of photographic experts (Joint Photographic Experts Group) was assembled in 1986 for the single purpose of whittling down very large image file sizes:
  1. To display on old CRT (Cathode Ray Tube) computer monitors – basically old TV sets without the channel tuners
  2. To travel efficiently over the fledgling (slow) Internet, which was designed to accommodate the best broadcast television standards
  3. In order to compress them for size and portability. The first JPEG specification was released in 1992 and ratified again in 1994.
Now over 25 years later, the same format is still in use!

The Price of the Program

Many elements of a digital image get altered with JPEG file compression. True, massive amounts of disk real estate get saved in the process but significant other parts of the image get thrown away.
First, the full RGB signal is converted to an abbreviated color space used for analog TV, called YCbCr. CRT displays are driven by red, green, and blue voltage signals, but storing RGB signals involves redundant data. While most of the luminance (brightness) information (Y channel) is retained, the two color channels (red and blue) are significantly reduced in scope.
JPEG Nassau - Why All JPEG Images Are Cobbled At Birth
Highlights clipped in the JPEG process are still present in the RAW file.
An original RGB camera image (TIFF, PSD) contains massive levels of color; many of which the human eye cannot distinguish. Since the end goal of JPEG is zero-body-fat, once a base interpretation of the image is defined, and the 256 colors identified, almost all the “extra” colors are removed, leaving a mere skeleton of the color range.
Colors are characterized as bit depth; the number of tiny measured steps between full color and no color. Humans can only perceive 200 levels of each color under ideal lighting.

The Problem

The decision on what colors get eliminated is pre-designated by a cookie cutter JPEG template, rather than by the human evaluation of each image’s tonal structure. JPEG restricts the color for all images indiscriminately. One template fits all. Excess information is discarded.
Basically, JPEG compression is like weight loss by body part elimination rather than fat reduction; more of an amputation than a diet. As I’ll explain later, the production of a JPEG file is the ideal final format, but not the most ideal for image editing.
JPEG makes use of a basic human sight limitation. We can see tonality more than we identify individual colors. This is why we see only shapes in low lighting conditions. Basic luminosity is retained with JPEGs but much of the color is down-sampled.
The next multistage high-math transformations in this process get mind-boggling very quickly, so let’s just say that some very intricate 8×8 pixel matrix calculations take place based on the limitations of visual perception. True optical illusionary voodoo is at work to further reduce the “weight” of each image. The vulnerability in this mass weight loss program is that JPEG colors are weakest in the highlights and can display nasty artifacts when the images are re-saved. All those compression calculations take place again when JPEG images are re-saved.
JPEG Clouds - Why All JPEG Images Are Cobbled At Birth
The basis of JPEG compression involves a complicated formulation involving blocks of 8 pixels. The 
values of each block are quantized and distilled into similar colors to eliminate color variations that 
the human eye has trouble distinguishing.
JPEG files typically reduce the size 90% from the original PSD or TIFF file with little perceptible loss in image quality, as long as the file remains unchanged in size and content. Images that contain significant areas of similar tones (skies, building surfaces, etc.) benefit most from this file compression format.

Quantization

This JPEG standard is not an image resolution issue as much as it is a color depth issue. The number of pixels is not reduced, but the number of colors is. The “pixelated” appearance is not caused by a reduced number of pixels, but a reduction of the color quality of those pixels. The visible loss comes from changes to the initial 8×8 pixel matrix when the edited file is re-saved.
In 1992 it was unthinkable to produce images at a higher quality than TVs could broadcast, including the 256-tone limitation and the sRGB color gamut. In 1992, this was state-of-the-art stuff and it served the industry well for many years.
How All JPEG Images are Cobbled at Birth
Image: 14-bit sensors can capture 16,000 levels of color in each RGB channel.
14-bit sensors can capture 16,000 levels of color in each RGB channel.
But then Silicon Valley developed camera image sensors and processors that could handle more than 8-bit images. That meant that digital manufacturers began building cameras whose images contained twice the level of color (10-bits, or 1000 levels of color).
Next, “deep-bit” images were accommodated by Adobe within Photoshop which changed everything. Much larger color spaces were developed to support this newly expanded color depth. (Keep in mind that bit depth is simply a way of dividing an image’s range into much smaller steps between zero color and full color of a pixel).

Deep (Color) Space

My friend Bruce Fraser (the father of color management) worked with Adobe to formulate what we know as Adobe RGB. Later a larger color space was developed called ColorMatch RGB. Even later, an even larger color space was developed and was labeled ProPhoto RGB. All three of these color spaces exceed the 256-level limitation of JPEG.
But even if an image is edited in one of these larger color spaces, when it is saved as a JPEG, it is automatically reduced to 8-bits (256-levels) per channel.
Image: Bit depth is the measure of tones between full color and no color. JPEG images affect the ima...
Bit depth is the measure of tones between full color and no color. JPEG images affect the image bit 
depth, not the image resolution, as commonly believed. Each time a JPEG file is re-saved, the color 
loss increases and the image clarity decreases.

Camera JPEGs

Camera-saved JPEG files are “shaped” by the camera settings in place when the image is captured. The algorithm applied to the image data harvested by the image sensor reflects the color model (sRGB, Adobe RGB, and ProPhoto RGB), sharpening preferences, etc.
A word about compression. Compression is probably not as accurate a term to describe JPEG limitations as it could be. Compression sounds like what your Aunt Martha does when she uses a girdle to compress herself into a smaller “container,” but that’s a totally different thing. When she is decompressed, all of Aunt Martha is still there.
JPEG uses “lossy” compression, which really means that some parts were discarded (or lopped off) for good. Aunt Martha only wishes her girdle would help her permanently “lose” something.
Think of image compression more like an abbreviation. When a JPEG file is saved to disk, the data captured by the camera’s image sensor gets compressed into a general mold, dictated by the color settings in the camera when the picture is taken.

Photo Finished

This JPEG process effectively plays the premature role of photofinisher, stamping out its own interpretation of the scene. What started out as a 4000-16,000 level per color image gets reduced to a 256-level picture with just a skeleton of color, leaving precious little room for tone (or color) adjustments.
JPEG March - Why All JPEG Images Are Cobbled At Birth
Both dark and light tones were clipped by the JPEG template but recovered from the RAW file.
JPEG Bit Depth Template - Why All JPEG Images Are Cobbled At Birth
JPEG limitations of 256 levels often clip brighter tones to white and darker tones to black prematurely 
(top grayscale above). RAW images allow the user to recover details that appear lost 
(bottom grayscale).
If the camera settings were not perfectly set to capture the brightness (bit depth) and contrast (tonal range) of the existing scene, the JPEG-rendered the photo leaves little room for recovery.
In the end, every image will be reduced to a 256-level file before it is either shared publicly or produced as a print. That’s just the nature of photography. There are very few printing devices that can reproduce more than 256 levels of color, and even if they could, the human eye couldn’t see those extra colors anyhow.
Image: While digital cameras can capture up to trillions of colors, human eyesight recognizes less t...
While digital cameras can capture up to trillions of colors, human eyesight recognizes less than 200 
individual red, green, and blue colors.

JPEG Sufficiency?

So if we can’t see more than 200 different levels of each color (and JPEG provides 256), why do we need the billions captured as RAW files? Simple answer… those excess levels provide ample elbow room to push color levels and saturation into the most visually ideal 256 tones for printers to print and humans to observe. It’s all about optimizing detail.
JPEG Harbor - Why All JPEG Images Are Cobbled At Birth
The dynamic range of the beach scene exceeded the JPEG “template” and highlight detail appeared 
to be lost (left) but was retained in the RAW file (right).

So what can we take away from this?
First, JPEG is the most basic of photo file formats and is only ideal (as a camera file) when ALL the pre-capture lighting factors match the current camera settings. Second, it’s always best to set your camera to record both hi-level JPEG and RAW files as an insurance policy. And third, the unabridged image data saved as a RAW file enables the final JPEG to be shaped (as close as possible) to what your mind perceived when you clicked the shutter button.
JPEG is the digital file format you want to end up with but it is not always the one you want to start with. There is a waste factor involved in every manufacturing process, and digital imaging is no exception. It’s better to have too much than too little. Always start with more than you need.
Intend to lose the weight, but do it on your schedule.

Share this article.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.