Would you say the above photograph has any compression artifacts? Compressed too much, not enough, or just right? What exactly is “just right” anyway. This post will explore the concept of compression, why and how do we do it, and how aggressive should we be in either reducing the file size or increasing the image quality.
I have been asked many times about the JPEG compression, file size, screen or projection resolution and how these affect the visible quality of an image. It is hard to convince people that at the same pixel dimensions, lower compression rates (or larger file sizes) do not necessarily produce visibly better results; at least after a certain threshold. I will take a stab at explaining these concepts and their related topics with images to examine with your own eyes. I ask that you approach the subject objectively without prior convictions. It is a bit lengthy post but there is nothing beyond visual comparisons. So, stay with it!
Human Perception is Organized
JPEG is a lossy compression algorithm developed by the Joint Photographic Experts Group–thus the name– to apply controllable levels of compression to digital image files to reduce their byte sizes. Also note that JPEG is a CODEC, compression and decompression standard, not a file format. It is fundamentally based on human perception and our visual systems, eyes, and brains, compensating for missing pieces of information and sometimes even making it up where one does not exist. So, humans are inherently involved in the compression-decompression process. The actual computation and math are far beyond mere mortals I am sure! So, I will deal with practical aspects here. The purpose of this article is to shed some light on this often confusing and misunderstood set of concepts so that you can make more informed decisions.
Take a look at the image on the left. Most people will see two triangles and three circles although none of them is a complete shape. Human perception is an organized process. If the information received is not sufficiently organized, we impose a structure on it to perceive it. This is probably the starting point of how JPEG compression works. If some pieces of information are missing our visual systems will recreate them given that the missing information does not create other perceivable structures such as posterization or banding. I will show examples of this later on.
Since JPEG is a standard, one would think that image editing software that is capable of creating these files will all work the same way. Unfortunately, the methods used, the user interface presented, and the end results produced may vary from one software to another. Since this is an article about the compression levels and their impact on perceived quality of images, I will use one software and produce controlled quality outputs from that. Since I use Lightroom for this kind of task, and since I have found a very useful plugin that would make the process easier I will stick with Lightroom. Rest assured though that the relative comparisons will likely hold true in different software as well.
What Influences Compression and File Size
We generally use JPEG format to reduce the file size for easy transmission, be on for Web use, e-mailing to friends, submitting them to competitions, and the like. Some may even argue that compression is a red herring and we should not compress our files at all, but reality speaks otherwise.
All digital image files have horizontal and vertical pixel dimensions, say 1024 x 768, 1000 x 1500, etc. As one would imagine, as the pixel dimensions grow the file size will increase everything else remaining the same. In other words, a 1000 x 1500 file exported at 60% JPEG quality level will be larger than a 1024 x 768 pixel file at the same quality level. There are simply more pixels.
Resolution or DPI
This measure has no bearing on the file size so long as the pixel dimensions and the compression levels remain the same. A 1024 x 768 file set at 300 dpi will have the same file size as one set at 100 dpi. As the acronym stands for Dot Per Inch, this measure is relevant when images are output to specific “inch” dimensions rather than pixel dimensions. Put this aside for screen displayed images, it has no bearing on the output. Pay attention to it if the submission guidelines indicate a specific DPI for other purposes; otherwise, it is safe to ignore.
It is easy to imagine that as the quality level goes up and the compression level goes down the file size will increase. Please keep in mind that even at the highest quality setting, JPEG compression will still discard some information to compress the file size. That is how it reduces a 4MB TIFF file to a 1.5 MB JPEG file. So, if you want smaller file sizes then you need lower quality levels. The question is “how low is too low?” That is the main exploration here, and keep your mind open to be surprised.
Is Larger Better
Not necessarily! Remember, we are looking at these images on computer screens which are inherently low-resolution devices. We also use tremendously powerful tools, our eyes and minds to process the information. There is a point beyond which it will be almost impossible to see any quality deterioration due to compression. This will be particularly true for photographs in digital projection competitions which have a lifespan of 5 seconds anyway.
Image Content and Detail
Take a look at the following two photographs, can you tell the quality difference at the displayed size? I bet you cannot! Now, click on each to enlarge it and skip from one to the next using the arrow keys. Can you tell the difference in quality? Probably not. One is compressed at 100% quality and the other around 50%. Such is the illusion of JPEG Voodoo.
Mixed Low and High-Frequency Content
This is an image that has a reasonably large area of sky, low-frequency information with practically no detail; and a sizable area of the building with fine detail, high-frequency information. This probably represents the middle of the road in terms of the detail information that may exist in an image. So, how low can I go in quality, or put in another way increase compression, before I may start seeing compression artifacts?
This image on the left shows obvious signs of quality deterioration mainly visible in the sky as posterization, or banding. There is also a visible spill of the building information into the sky along the vertical edges where the two meet. To see these you will need to click to enlarge the image on your screen. What may be surprising to note is that the building surface with its intricate brick pattern seems, just seems, not to bother us. The naturally nonuniform brick pattern is working to hide the JPEG compression artifacts. All said, this is not an acceptable level of image quality and I think we will all agree on that.
The image on the right will likely please most viewers as a reasonably good quality image that will not do a disservice to the photograph. Its compression ratio is about 35% quality level! I think you could sleep comfortably if your images are compressed at about 70-80% quality level although they probably do not look any better than a version compressed at 55% quality level.
Let’s take a look at the behavior of a different kind of photograph, that has very little fine detail and most of the image is surfaces, that is to say, a “low-frequency” image.
A low-frequency image has a minimum amount of abrupt tonal shift from dark to light that creates “edges” like in the building above against the sky or its brick structure. Here are two versions of a low-frequency image with the minimum amount of fine detail.
You can clearly see that one image is quite poorly displayed with lots of compression artifacts. It is easy to see the “sand pit” like area on the base around the shakers. But also note that the red background is quite mottled although not as strongly posterized as the sky in the previous example. These are two extremes of the compression, at the highest and the lowest settings; yet despite the obvious defects, the difference is probably not as much as one would imagine.
At around 47-53% quality level, the quality is perfectly acceptable. Go back and forth between this last image and the one before it at 100% quality and look very carefully. You may, just may, see some differences because you are able to compare them. If you look only at the last image, would you honestly say it suffers from compression artifacts or what you see is the texture of the background? Of course, you can increase the quality level a little more without paying too much penalty on the file size increase if you want to fuss over minute details.
Some images contain much fine detail, a lot of transition from light to dark tones creating a large number of edges. How would they behave when compressed at different levels? This time I will provide two separate images and ask you to look at them carefully and see if you can live with the level of compression in each; I am not going to tell you the quality level so as not to add bias to your judgment.
Now that you are not comparing different quality levels of the images, the decision is exactly what a judge or a visitor to your site may make. The image is either of good quality or not. My guess is that you will find the above images fine in terms of their presentation quality. One thing that aids in camouflaging compression artifacts is the fine detail in the image itself. It becomes rather difficult, if not impossible to decide what is part of the image and what is coming from compression unless the latter is grossly visible as was the case with the salt and pepper shakers.
It is fair to say that for most projected images in competitions, or images used on Web sites compression levels above 50-60% will only add to the file size without adding any higher quality to the image. On the Web, smaller file sizes will load faster which is what visitors want. When you e-mail a file to a friend or a family member, you do not want to clog their mailbox or your sending capacity with huge file sizes. In fact, many mail systems will not even accept mail attachments over a certain file size. So, there is merit in using reasonable levels of compression for these purposes.
Your photo lab may want JPEG files submitted as well, but since they are prepared for printing purposes and will be output on high-resolution devices you do not want to inject any compression artifacts since they will surely show in the print. While on the subject of photographs prepared for printing, it is not a good idea to sharpen a photograph for a large print, say 16 x 20, and then resample it to a smaller size to submit to a competition. The high levels of print sharpening will most likely produce processing artifacts that will remain in the image. Every image must be prepared from the master file for its intended size, THEN sharpened for the output device.
Does On The Fly Resizing Affect Image Quality
I kept these images on the large side, each is 1500 x 1000 pixels. I did that partly to show a reasonably large image for your careful inspection. The other reason was to keep them large so that they will not fit most browser windows, especially on smaller screens. If you are on a large monitor, just resize your browser window to display these images about 1000 x 800 pixels before reading further. If your monitor is 24″ or under chances are you are not seeing them full size anyway.
Another related question I have received many times is: “what happens to my image if it is displayed on a monitor or projector with a higher or lower resolution?” Well, again, it is not a matter of “resolution” but the display pixel dimensions that is at the heart of the matter. The short answer is, “nothing bad will happen to your images”.
If you submit an image to a digital competition in your club according to the guidelines, say 1024 x 768 and it is projected on the club computer and projector set to the same screen size, your image will fit the screen perfectly. If that image is submitted to a different contest but that organization uses a projector and computer set at 1400 x 1050, your image may either appear exactly as it did before but not fill the screen; or the display software may enlarge it to fit the screen stretching the pixels. In the case of the latter, there may or may not be a minor quality loss depending on the sophistication of the software used to display the projected images.
What if we think of the reverse situation: your image is sized 1400 x 1050 but is projected on a 1024 x 768 projector? In this instance you will experience what you have been seeing on the screen when viewing the images in this post, they will be automatically scaled to fit into a smaller area. This is in most instances totally unnoticeable, may even make the image a little crisper. Now go back and review some of the images once more in this post. If the full size does not fit on your screen do you see any quality reduction because of this fitting in the available space? I will bet a cup of coffee you did not even notice this all the while you were viewing these images!
So, go ahead, have that projector you have set to its native resolution, say 1400 x 1050, instruct your club members to submit images to fit in a box that size, and start displaying images with inherently more information. The screen size of 1024 x 768 does not even exist on smartphones anymore! Welcome to 2015!
I would like to conclude by saying that “higher quality level” setting in JPEG export runs out of high quality pretty quickly. After a point, it simply inflates the file size without any visible improvements in the image. I am also not advocating to use the lowest quality settings in compression either. The purpose of this post was to present to you a common misconception about compression levels and image quality.
I am going to provide image galleries for you to view and inspect. You will also find in each batch the relative file size information. I used a plugin by Jeffrey Friedl, JPEG Export Quality Tester. (He has other very good plugins for Lightroom, take a look at his collection.) The plugin exports 13 quality levels of the same image and, optionally embeds compression ratio and file size information in the file name. I left the image titles as file names so you can use them as another piece of information in your image assessment. Don’t jump to conclusions though that high-compression (lower quality setting) always produces lower quality images.
Here are the photographs I used in this analysis.