Data Compression
Image Compression
Image compression is the process of reducing the size of digital images while attempting to preserve the essential visual information and quality of the image.
It plays a crucial role in various fields, such as digital photography, web design, and multimedia applications, where reducing file sizes is essential for efficient storage and transmission.
There are two types of compression Lossless and lossy.
Calculating image sizes
Let's suppose we have an image that is 4000 x 3000 pixels (12 mega pixels), smaller than the size that most digital cameras take. Let's calculate the number of bits needed to store this image:
1. Calculate the pixels
Pixels = 4000 x 3000 = 12,000,000
2. Multiple by the color depth
Each pixel is represented by 24 bits:
12,000,000 x 24 = 280 Million Bits
3 Convert to bytes
Convert this to bytes
280 / 8 = 36MB
This is a huge size, even though the image resolution is smaller than most modern cameras take. This is no good and so image compression is required.
What is the purpose of image compression algorithms?
Lossless Compression
Lossless compression techniques are used in image compression to reduce the file size without compromising the quality of the image.
Unlike lossy compression, which permanently removes certain image data, lossless compression retains all the original data so that the compressed image can be perfectly reconstructed
Lossless image compression typically achieves 20% to 50% compression, depending on the image data.
What is the main advantage of lossless compression techniques in image compression?
Lossless Compression Techniques
Run-Length Encoding (RLE)
This technique replaces consecutive repeating pixels with a shorter code indicating the repetition count. It is effective for images with long runs of identical pixels.
Huffman Coding
Huffman coding assigns shorter codes to frequently occurring pixels and longer codes to less common pixels. It relies on the statistical properties of the image data.
Lempel-Ziv-Welch (LZW) Compression
LZW compression replaces frequently occurring patterns with shorter codes. It creates a dictionary of patterns and replaces repeated occurrences with dictionary references.
Benefits of Lossless Compression
Lossless compression techniques offer the following advantages:
No loss of image quality
The original image can be fully recovered during decompression.
Preservation of details and sharpness
Lossless compression retains all the fine details and sharpness of the original image.
Precision in editing
Compressed images can be edited without introducing artifacts or further loss of quality.
Drawbacks of lossless compression
Limited Compression Ratios
Lossless compression generally provides lower compression ratios compared to lossy compression methods. This means that the reduction in file size may not be as significant, especially for media files like images and videos.
Complex Algorithms
Lossless compression algorithms tend to be more complex and computationally intensive than their lossy counterparts. This can increase processing time and resource requirements, which may not be practical for real-time applications or devices with limited processing power.
Not Suitable for All Data Types
Lossless compression is highly effective for certain types of data, such as text documents and simple graphics. However, it may not be as efficient for complex multimedia data or data with high entropy, where lossy compression can achieve much higher compression ratios.
What is the main drawback of lossless image compression?
Lossy Image Compression
Lossy image compression is a digital image compression technique that reduces the file size of images by selectively discarding some of the image data, with the goal of achieving higher compression ratios.
Unlike lossless compression, which preserves all image data and quality, lossy compression intentionally sacrifices some image details and quality to achieve smaller file sizes.
Lossy image compression typically achieves compression of between 85% and 95%, depending on how aggressively the data is compressed.
Advantages of lossy compression
Significant Compression Ratios
Lossy compression can achieve substantial reductions in file size, making it highly efficient for storage, transmission, and web use. This is particularly valuable when dealing with large quantities of images.
Smaller File Sizes
Smaller image file sizes lead to reduced storage requirements, which can save disk space and reduce bandwidth usage when transmitting images over the internet or other networks.
Faster Loading
Smaller image files load faster, improving the user experience on websites and mobile applications. Faster loading times are critical for retaining user engagement.
What is the main advantage of lossy compression techniques for image compression?
Image Compression Artifacts
Image compression artifact refers to the degradation in image quality that occurs when an image is compressed using lossy compression algorithms.
These algorithms are designed to reduce the file size of an image by removing certain details that are considered less important to human perception.
However, this process can result in noticeable distortions, which are known as compression artifacts.
Disadvantages of lossy compression
Loss of Image Quality
The most significant drawback of lossy compression is the loss of image quality. As image data is discarded, artifacts such as blurring, blocking, and color inaccuracies can become noticeable, particularly at high compression levels.
Irreversible
Lossy compression is irreversible. Once image data is discarded, it cannot be fully recovered to its original quality, even when the image is decompressed.
Artifacting
Compression artifacts can become more pronounced as the compression level increases. These artifacts can be distracting and reduce the overall visual appeal of the image.
Limited Editing
Images that have undergone lossy compression may not be suitable for extensive post-processing or editing, as further modifications can exacerbate compression artifacts.
Common Compression Artifacts
Blockiness
In block-based compression algorithms like JPEG, images are divided into blocks, and compression is applied to each block individually. This can lead to visible blockiness, especially in areas with sharp edges or high contrast.
Noise
Compression can introduce random noise or graininess, particularly in areas of smooth gradient or subtle texture. This noise can be especially noticeable in areas of uniform color.
Blurring
Lossy compression algorithms may blur fine details or textures in an image, resulting in a loss of sharpness and clarity.
Ring artifacts
These artifacts appear as concentric rings or bands around edges or areas of high contrast, often caused by quantization errors in the compression process.
Color banding
Lossy compression can reduce the number of colors in an image, leading to visible color banding or posterization, especially in areas of gradual color transition.
Which of the following is a potential drawback of using lossy compression techniques for image compression?
Lossless & Lossy Image Compression
- Image Compression
- Calculating image sizes
- Lossless Compression
- Lossless Compression Techniques
- Benefits of Lossless Compression
- Drawbacks of lossless compression
- Lossy Image Compression
- Advantages of lossy compression
- Image Compression Artifacts
- Disadvantages of lossy compression
- Common Compression Artifacts