Beechlog‎ > ‎July 2002‎ > ‎

July-2002.4

Beechlog
 
The on-line magazine of the Burnham Beeches Radio Club.

Blog title

July 2002 Edition, Page 4

More on Pictures

A while ago I wrote about the methods of coding digital pictures, and jpeg in particular. The methods I mentioned have been around for quite a while, and in the meantime researches have not been idle in seeking modern replacements.

Since jpeg is currently the most suitable format for presenting compressed photographic images, efforts have been made to deal with the problems in the DCT compression system, and also to find a way of encoding photographic images without discarding image data.

A few years ago the JPEG-LS format was developed to satisfy the latter requirement. To see the problem, just find a photographic image in an uncompressed bitmap format, like BMP or TIFF, and then compress it into a zip file. Provided the image originally possessed the full range of colours, you will find the results disappointing, perhaps a ten to fifteen percent reduction in size. JPEG-LS was developed to solve this problem, but where are all the compressors? Unfortunately this did not catch on. I don't know why - perhaps there was too much intellectual property to pay for (standard jpeg requires no licence fee payments), or maybe the need was not great enough? JPEG-LS has no relationship to jpeg so different codecs are required.

However another international standard has been developed to improve on jpeg and to compress without loss. This is JPEG 2000. While I believe it draws on JPEG-LS to perform its lossless compression function, the lossy compression is quite different. Instead of DCT (Discrete Cosine Transform), it uses DWT (Discrete Wavelet Transform), which is also used in MPEG-4.

The problem with jpeg is that it tends to produce visual artefacts as the compression increases. These are prevalent at high contrast boundaries in the picture. Also blocks appear where there are areas of continuous tone, and dramatic colour shifts occur. These problems are not troublesome where the compression is moderate, say 20:1, but are very noticeable at, say 50:1. People who need to transmit large images across slow networks are really in need of improvement here.

JPEG 2000 does address these problems, although I have seen some other shortcomings. The artefacts are mostly gone, and highly compressed pictures look much better. I have compressed 12 Mb bitmap images down to 10 kb (greater than 1000:1), and the difference between JPEG 2000 and jpeg is dramatic.

The methods used by JPEG 2000 are very complex. This leads to an increase in compression/decompression times, very noticeable on this 800MHz PC I am using. But of course it depends on image size, and in any case will become less important as machines get faster and the codecs are refined.

However JPEG 2000 has plus points. Many of the limitations in jpeg have been removed, such as top limit on image size. It codes continuous tones much better, so computer-generated images can be compressed without having to change to GIF or PNG. The pictures can be decoded at different resolutions, and progressive display is now possible. Different pixel/bit ratios can be preserved, up to 16 bits per colour channel (current jpeg is fixed at 8 bits per channel). And colour space is defined as RGB, unlike conventional jpg where it is undefined (Minolta cameras don't use RGB, although you might not notice this!).

So what does JPEG 2000 look like? I had some difficulty finding images - the standard test images have copyrights that prevent them being published. Most software is still sold at commercial rates, so freebies are hard to find (this will have to change if the format is to become accepted). However some picture viewers have facilities, such as Irfanview, which can display JPEG 2000 at any size, although it will compress only smallish images. However for the images in this article I used Luratechs SmartCompress application, which also codes and decodes in their own wavelet format, Lurawave. There are two other free programs I found, Slowview and Xnview, see the links page for the URL. These both load and save many modern image types - it's worth trying them out too.

much compression

The above shows sections of 2272x1704 images compressed to about 1:55, about 207k in size (disregard the confusing window titles!). Note that the right hand jpeg image shows artefacts around the lettering, especially the postcode. The JPEG 2000 image on the left is much clearer. These images are shown at 2x magnification.

The images below are sections of the same photograph, this time the original TIF file was compressed to 1:132, about 86k size. The jpeg on the right is showing serious degradation, while the JPEG 2000 has degraded more gently. These images are shown without any magnification.

more compression

The most striking thing I found was the ability to compress down to 1000:1 and lower, something that jpeg just cannot do. I compressed some 2272 x 1704 images from my camera down from around 12 megs to about 10k, and although these obviously had lost a lot in the process, the pictures were still intact and useable (for some purposes). I was unable to compress the same bitmap down to the same size with the jpeg tools I have, they all bottomed out at about 65k with different horrible effects.

maximum compression

The above images started out as a 2272x1704 TIF. The left-hand JPEG 2000 version has been compressed to 1:1134, size about 10k, and the right hand jpeg has been compressed as much as I could achieve, down to a 64k file. The pictures have been reduced to one sixth full size to display here.

It's probably worth noting that you can get better results from jpeg at high compression ratios if you downsample before creating the jpeg. This creates a smaller image, which can be upsampled to the original size when displayed. I've not made any specific tests on this process, because most display software will not handle this process. Although recent versions of Internet Explorer (and probably other browsers) will enlarge (upsample) if the display size is stated in the html code, there's no accepted way of embedding upsample instructions within the jpeg file itself.

So where will JPEG 2000 be useful? Certainly where there is a great constraint in bandwidth, such as web pages and the like, perhaps especially when delivered to mobile devices where users are charged for the capacity used. It probably will be useful for storing and transmitting images that need to reduced in size with no damage to their integrity. The lossless images it can produce show a size reduction of about 4:1, and may be useful for medical photography, legal photography, engineering, and so on.

Will it be suitable for digital cameras? This is not a simple answer, as digital cameras usually use minimal compression anyway. My camera produces images with three compression rates, the 12 Mb of picture data can be reduced to about 2.2 Mb, about 1.1 Mb and about 500kb, ratios of about 5.5:1, 10:1 and 20:1. These are standard jpeg images. Only the latter images show any noticeable artefacts, and then you have to look closely and magnify the images. JPEG 2000 at 20:1 may have less artefacts, but may introduce other changes - the Luratech compressor seems to start to smooth images at higher compression ratios, and may lose detail that is preserved in a normal jpeg. It's also worth noting that many digital cameras save more colour data than conventional jpegs can store, but more of this later.

The ability to save lossless JPEG 2000 images may be useful, and my 12 Mb test image compressed to around 3.3 Mb. This may be a good alternative to TIFF. But some cameras have another alternative.

RAW files

Besides storing jpeg images, some digital cameras (and other instruments) also are able to save images in a form that avoids any data loss due to compression. Many use the TIFF format, but this produces rather large files that soon fill up flash cards. Now some Canon, Minolta and Nikon cameras can save RAW data, which basically means that they dump the image sensor output into a file with minimal processing. I've been unable to find out much about the workings of this, but it seems that the files are much smaller than TIFF files. My camera produces RAW files of around 2.8 Mb in size. Interestingly, in my camera, the information comes in four channels, CMYG, instead of the usual RGB used in most jpeg files. 10 bits per channel are used (i.e. 40 bits), so how the file size comes to be much smaller than a three channel 24-bit TIFF I can't understand!

When a digital camera writes a jpeg or TIFF to its memory card, it applies many changes, like white balance corrections, contrast adjustments, and tries to enhance the sharpness of the image. This is not the case with the RAW format, so you need to apply these adjustments when processing the images for display or for printing. The camera manufacturers supply a tool to do this, so that these adjustments can be easily made. In my case, the camera settings are saved in the RAW file, so it's just one click to apply these settings in your PC. You can also apply any other settings, and if you had not set up the camera correctly when you took a picture, it doesn't matter anyway, as you can apply the correct settings later.

The RAW files from my camera contain the full range of colours, in this case 10 bits for each of the four colours. Now whether this is useful or not, I don't know, but the RAW conversion tool allows me to save the images as 8 bits per colour, or 16 bits per colour. I know I can't see the difference, but maybe this is useful if the images are to undergo much processing before they are finished. If you are going to adjust brightness and contrast, or change colours, it's better to start with a greater range than you eventually end up with.

At the moment only a few cameras produce RAW files, so many of the popular image browsers understand how to display them. For example BreezeBrowser can display Canon RAW files, and convert them to, say, JPEG 2000, applying the same corrections as the Canon RAW file tool does, under your control.

So if you use a 1 Gb Microdrive in your digital camera, you can save maybe 350 RAW images before the drive fills, not far short of the big 35mm film backs that press photographers use.

Camera storage

When I was in Italy, there was so much I wanted to photograph, that I had taken abot 70Mb of images by the start of the third day. I had taken about 208 Mb storage with me, so it was obvious that I would run out if I didn't do something. As it was, I didn't need to do anything because my camera was stolen! But it did raise the question - how to cope when away from home. With a film camera, you just buy more film, but flash memory cards are more difficult to obtain in holiday areas.

There are a few ways of addressing this. One way is to take a laptop so that you can copy the files off the flash cards. I don't have a laptop, and despite being called 'notebooks' these days, they are still large delicate things you don't want to lug about with you. I did take my Psion, so I could have stuck the cameras flash card into the Series 5 and emailed the images back home via my mobile phone. However at about 9600 baud this is hardly practical (GPRS roaming is probably non-existant!).

There are some useful devices around which contain a hard drive and a flash card socket. Designed mostly for storing mp3 files, they do an excellent job of copying your flash card to the hard drive. The problem is that they are rather expensive, about £500 for a 20 Gb model. And they take up more of your baggage allowance.

One gig CF card Flash cards are getting bigger and cheaper. So you could just buy a lot of these. The Compact Flash range now goes up to 1 Gb, although rather expensive. You can find 128 Mb cards for less than £50 if you look around the internet. Other types are catching up, although Sony users still find the Memory Sticks much more costly than anything else.

One gig microdrive CF card The Compact Flash user may also consider Microdrives. These are type II cards (thicker than standard CF) and come in three sizes: 340 Mb, 512 Mb and 1 Gb. Currently only made by IBM, these are miniature hard drives in a CF package. Of course they are costly, but cheaper than the flash equivalent. Larger capacity cards are on the way, from other manufacturers. The IBM drives will not fit every camera, however.

An alterntive may be to ditch in-camera storage altogether. Sanyo have recently announced details of a camera with a Wi-Fi (IEEE 802.11b) CF card and a TCP/IP stack. This camera can send the images straight across a radio-connected network to your storage computer! See the links page for more details.

Having lost all my photos on the 128 Mb card inside my camera, it might be sensible to use a lot of 32Mb cards. As they are filled up, you can leave them in a safe place, so when your camera gets nicked, you still have most of your photos. Probably one card for each day may be enough. you could even post them home each day if you are worried about the hotel burning down.

I'll think about this in time for my next holiday...


      Home Page Previous Next Links

Copyright and Technical Stuff.

This issue is Copyright Burnham Beeches Radio Club 2002.

Any opinions inside this issue of BeechLog are those of the authors, and must not be assumed to be also of the BBRC.

BeechLog is written in XHTML version 1.0 and contains a few differences from the last issues. However different browsers handle XMTML and the associated style sheets in different ways, so there is the possibility that you may not see BeechLog as I intended! If there is anything that seems amiss, please let me know:
Roger GØHZK, Editor