Image compression can be divided into two categories – lossy and lossless compression.
Lossy compression reduces file size by permanently eliminating certain information, especially redundant information (even though the user may not notice it). JPEG is an example of a format using lossy compression.
However, lossless compression retains raster values during compression and file size is also reduced. For example, LZ77 is a lossless compression file type.
Let’s compare both image compression methods and their potential uses in GIS.
When should you use lossy and lossless compression?
In GIS, lossy compression data is good for background images because it has faster loading speeds with lower compression ratios. You should not choose lossy compression if you want to perform further analysis on the data.
Lossy compression algorithms often result in greater reductions of file size. It’s often the case that the human eye cannot distinguish between lossless and lossy compression. Lossy image compression offers the best compression ratios with good enough approximations.
On the other hand, lossless GIS compression reduces file size but redundant information will be retained after compression. LZ77 is an example of a lossless compression.
Lossless compression is good if there will be new analysis on the data. This is because none of the original values will be changed. It’s good for discrete data or the raster image is already lossy compressed.
JPEG Compression Example
JPEG stands for Joint Photographic Experts Group, which is the group that created the standard. It has an extension of .JPG and .JPEG and is the most common image format used by digital cameras and on the World Wide Web.
It’s a lossy compression type for digital images. Lossy image compression reduces file size but redundant information will be lost (even though the user may not notice it). The user decides how much loss to introduce with a trade-off storage size and quality. The compression quality is a range from 1 to 100. A lower value compresses the raster image, but also reduces the quality more than a higher value.
JPEG 2000 (JP2) is the newest version of JPEG. It slightly improves image compression performance over JPEG using two different wavelet transforms. Users can choose low to high levels of compression.
LZ77 Compression Example
LZ77 compression is a lossless image compression meaning it maintains raster values during compression. It was introduced by Abraham Lempel and Jacob Ziv in 1977 and is still used today. Combining the first letter from both last names (LZ) and the year it was invented (1977), this is how the acronym (LZ77) was created.
It uses the same commission algorithm as PNG (Portable network graphic). It’s the default raster GIS compression used in ArcGIS.
The theory behind LZ77 image compression is that repeat values seen in a raster image are stored according to their position and length. Instead of storing single values for each cell, LZ77 simply stores where the value was found and how long the string of values are.
MrSID vs ECW
JPEG 2000 can achieve a compression ratio of 20:1 which is similar to MrSID and ECW format.
LizardTech’s proprietary MrSID (Multiresolution Seamless Image Database) format is commonly used for orthoimages in need of compression. MrSID images have an extension of SID and are accompanied with a world file with the file extension SDW.
MrSIDs have impressive compression ratios. Color images can be compressed at a ratio of over 20:1. LizardTech’s GeoExpress is the software package capable of reading and writing MrSID format.
ECW (Enhanced Commission Wavelet) is a compressed image format typically for aerial and satellite imagery. This GIS file type is known for its high compression ratios while still maintaining quality contrast in images.
ECW format was developed by ER Mapper, but it’s now owned by Hexagon Geospatial.
Lossless compression retains values and manages to lower file size.
However, lossy compression reduces file size by eliminating redundant information.
JPEG is an example of a lossy compression. While LZ77 is an example of a lossless compression.
Depending on your intended uses, you have to choose lossy or lossless compression appropriately.