Archive for April, 2006

Get More Pictures on Your Camera’s Memory Card

April 22, 2006

Fewer Pixels or More Compression?
posted April 16, 2006

At the last HAL-PC Clear Lake Digital Photography SIG (Saturday 4/15/06) the question came up whether increasing JPEG compression or reducing the number of pixels recorded will result in the better image.

Sometime you may find yourself in the situation where you don’t have enough memory/storage space to record all the pictures you want to take — for example, you’re on a weekend trip and only have a memory card that can record 100 pictures at the best quality. Depending on your camera you may be able to increase this to 400-800 pictures by sacrificing a little image quality that you may never miss.

There are two way to increase the number of pictures you can record in the same space. One way is to decrease the number of megapixels you record for each picture. The other is to increase the JPEG compression used to store each picture. Either method sacrifices some picture quality. This raises the question of which method will result in the better image — which prompted this article.

NOTE: In this article the terms megapixels, MP, number of pixels,
and resolution all mean the same thing and are used interchangeably

JPEG is a “lossy” file format. The JPEG method of image storage can achieve a remarkable amount of compression (reduction in file size). It can reduce the file size by a factor of 20 and still have a reasonably good image. But, there’s no free lunch. To achieve its remarkable compression it throws away small amounts of the original image, and the greater the compression the more of the image gets thrown away. On the other hand, using a lower number of pixels to record the image results in an innately lower fidelity image. So, which method is best?

To create this demonstration I took two shots. They were taken with my 8 MP (megapixel), Olympus 8080 camera. The high resolution shot was taken at 8 MP (3254 x 2448), and the lower resolution shot at 2.8 MP (2048 x 1336). 2.8 MP was selected for the lower resolution because it produces roughly the same file size as the higher resolution when using increased JPEG compression. The target was a piece of striped cloth. The two shots were taken one after the other with the camera on a tripod.

The image on the left in both the upper and lower pair is the same crop from the shot taken at higher resolution and lower quality (higher JEPG compression). The image on the right in both pairs is same crop from the shot taken at lower resolution and high quality (low compression).

For the images to be comparable they must be the same size (same resolution/PPI). To do this, the low resolution image must be up-sampled (made larger) or the high resolution must be down sampled (made smaller). Anticipating an issue over which of these methods might yield the best results I have done it both ways. The pair on the top were done by up-sampling the low resolution image, the bottom pair were done by down-sampling the high resolution image (and magnified to make them large enough for comparison). Other than this, the upper and lower pair are the same — that is, the same crops from the same two images.

High Resolution
High Compression
File Size 1503Kb
Low Resolution
Low Compression
File Size 1605Kb
The low resolution shot above has been up-sampled to make the images the same resolution/PPI
The high resolution shot has been sampled down to make the images the same resolution/PPI.  The down-sampled pair has been magnified so the images are large enough to compare conveniently


To my eye the higher resolution/higher compression
images on the left, are clearly (pun intended) sharper


So, if I’m right and you need space for more pictures, first increase the JPEG compression. That is, choose a lower “quality” setting. If that still doesn’t give you enough pictures, start lowering the number of pixels (resolution). Step down through each lower resolution until you reach the number of pictures you need. I probably wouldn’t go below 1600×1200 (2 megapixels) if you intend to print your pictures. If you only intend to display them on a computer or TV you can go down to 1200×900 (1 megapixels). It’s important to remember, reducing the number of pixels you record limits the amount of cropping you can do and still have enough pixels for a good print.

I recommend you experiment with this by shooting and printing at the higher quantity settings before using them on something you can’t do over if the results aren’t good enough for you. Following this procedure on my camera with a 512 MB memory card, you would see the following increases in space available for pictures.

Resolution/Compression Setting Megapixels photos Shots Times X
3264×2448 / low compression 8 MP 130  
3264×2448 / high compression 8 MP 260 2
2592×1944 / high compression 5 MP 410 3
2288×1712 / high compression 4 MP 515 4
2048×1536 / high compression 2.8 MP 638 5
1600×1200 / high compression 2 MP 1000 8
1280×960 / high compression 1.2 MP 1600 12

One thousand shots is the equivalent of about 30, 36 exposure rolls of 35mm film; or 50, 20 exposure rolls..


JPEG Compression — Devil or Angel?

April 21, 2006

JPEG Compression — Devil or Angel?
posted April 23, 2006

You only have to fool with digital photography a short time before someone says something like, “Try to avoid JPG, it degrades your images, and each time you save the image it becomes worse and worse.” And they may add, “You need to buy a camera that supports RAW images and use that exclusively.” In this article I will try to shed some light on the pros and cons of using JPEG normally call JPG. JPEG is simply a file compression method. To identify files compressed using the JPG method they’re given the extension jpg (The letters after the dot at the end of a filename are called the extension.). Digital images tend to be large and so use a lot of storage space (and web resources). To combat this, ways of compressing image data have been devised. By far the most widely used compression method is JPEG. [GIF and PNG are also compression methods. They are best suited to graphical images that only have discrete colors.]

The JPEG method of image storage can achieve a remarkable amount of compression (reduction in file size). It can reduce the file size by as much as a factor of 20 and still have a reasonably good image. But, it’s not a free lunch. To achieve its remarkable compression it throws away small amounts of the original image data, and the greater the compression the more of the image gets thrown away/lost. For this reason it’s called a “lossy” compression method. This is why people are warned against using JPEG.

I’ll start by saying if it’s about as easy for you to record/store your images in one of the lossless format such as TIFF or RAW, by all means do so. But, it’s impractical to use large uncompressed images on the web and they bog down email, particularly for those who use dialup. And, let’s say you can take 100 of the highest quality (least compression) JPEG pictures on your camera’s memory card. You’ll likely only be able to take about 15 pictures using TIFF. Also, you may be able to shoot 6-10 pictures in rapid succession using JPEG, where you’ll have to wait 10 to 20 seconds between shots for the camera to finish recording each TIFF picture.

You’ll hear people talk about JPG artifacts. They may say saving an image over and over in JPG is like passing it through a copy machine repeatedly — the image degrades every time you save it. I hope to to shed some light on these things.

Disclaimer — I am not expert in these areas. For example, I don’t know how the JPEG compression algorithm works. I will simply show you some images I have fooled around with in PhotoShop, and tell you what I think they show and let you judge for yourself.

For these illustrations/comparisons I want you to see the pictures side-by-side. In order to do this I will sometimes use the same pictures more than once. When I use the same caption name, it is the same picture. The original picture used in these illustrations is at the top of the page. I’ve magnified the demonstration images to make differences more apparent, so the image named “Original X3” is the original picture magnified three times.

This first illustration is a comparison of the original (magnified 3 times) with a JPEG of the same image using moderately aggressive compression (50 in PhotoShop’s Save For Web). You may not notice much difference at first, but as you study the image on the right you will begin to see areas where it is disintegrating. Look carefully near the outer edges of the upper petals. Also, look on the petals around the yellow “eyes” Also, at the small petal at the 4 o’clock position. This is JPG artifact.

Original X3 1st generation JPG of original

Below, when you compare the original with the same JPG compressed image in actual size (not magnified) you don’t see the artifact, but of course, you and I know it’s there, so our obsessive selves can brood about it.

Original 1st Gen JPG

Now about the copy machine analogy. The picture on the left below is the same as the one above on the right. The picture below on the right is this very same picture saved ten more times using the same compression (50 in PhotoShop’s Save For Web). The first generation of compression left obvious JPG artifacts, but many subsequent saves at the same compression level caused no further degradation. And, I’m not even a guest star on Mythbusters. The answer is, as long as you use an amount of compression less than or equal to the amount used for the first JPG it will not further degrade the image — the damage has been done, but it’s not made worse. Nonetheless, for reasons too messy to explain here it’s my opinion that repetitive saves in JPG are almost always unnecessary and should be avoided.

1st generation JPG of original 11th generation JPG

The following is an illustration of what you get when minimal JPEG compression (75 in PhotoShop) is used. Now that you know what you’re looking for you can probably find the minimal JPG artifacts in the image on the right, but they’re fairly minor and you would certainly never see them in the actual size image.

Original X3 Minimal JPG compression

To demonstrate that you cannot tell the difference, the final two images below are similar to the two images above, except they’re normal viewing size — that is, not magnified. Like the above left image, the below left image has no JPEG compression. Like the above right image the below right image has been JPEG compressed, and by the same amount (75 in PhotoShop). I can’t see any difference. Can you?

No JPEG compression Minimal JPEG compression

I end by repeating, lossless file formats maintain the full fidelity of your images, so by all means use them whenever practical. However, it’s my opinion that modest JPEG compression does not do serious damage to your images even if you compress/save the same image time and again.

JPG Compression — Part 2

April 20, 2006

Iterative Compression, With Changes
posted April 30, 2006

This is an attempt to address the issue Johno raised in his Comment to my previous article “JPEG Compression — Devil or Angel?” If you haven’t read that article it may make it difficult to understand this one, so I urge you to read it first.

In the earlier article we established that repeatedly saving the same image at the same or less compression does not further degrade the image. But, when changes are made to the image between saves the effects of the compression will be somewhat different, raising the question of whether, and by how much, this causes further observable degradation. For this test I repeatedly made a modest (not small and not major) Curves adjustment to the image. Though each adjustment was modest, the cumulative effect of these adjustments was a major and unacceptable increase in image contrast. For the reference/control I repeated the adjustment to the image in PhotoShop four times and then saved it with the same moderately aggressive compression I used in the first article (50 in PhotoShop’s Save For Web). For the test image I started with the same image used for the control (the original from the earlier article). After making the first adjustment, I saved it (50 in PhotoShop’s Save For Web). I then loaded this first generation JPG image in PhotoShop, repeated the adjustment, and repeated the JPG Save For Web; creating a second generation JPG. I repeated this procedure two more times creating the third and fourth generation JPG.

To be clear: for the control, the adjustment was applied four times, ending with one JPEG save. For the test image, after each adjustment the image was saved as JPG — this JPG was then used to make and save the next JPG, etc., such that the final test image included four adjustments and four JPEG compressions. The two images below show the result. Though the two are different I’m not sure which is better. In some areas the control looks better, in others the test image looks better. Neither seems obviously superior to me overall. Both seem about the same amount different/distant from the original — your opinion may differ.

Images below are magnified by three.



Test Image — 4th Generation JPEG

Below you can compare the single JPEG compression from the original article with the control image in this test. Each image has been subjected to only one JPEG compression, but the contrastier reference/control image has more conspicuous JPG artifact. I included this comparison in case you were thinking, ‘Wait! Something else is different — the artifact are more prominent in both of the images in this test. They are; apparently because the image is more contrasty.


1st generation JPG of original



Original X3

I have included the original image so you can see where we started before any adjustments or JPEG compressions.