What is Set Partitioning in Hierarchical Tree(SPIHT) Algorithm & How does it Works in Lossy Compression

Cyber Security : Go from Zero to Hero

Most Popular

60 Lectures 5.5 hours

Master C and Embedded C Programming- Learn as you go

Best Seller

66 Lectures 5.5 hours

C Programming from scratch- Master C Programming

Best Seller

60 Lectures 8 hours

Introduction:

The Set Partitioning in Hierarchical Trees (SPIHT) algorithm is a lossy image compression algorithm, widely used for image and video compression applications. The SPIHT algorithm uses the wavelet transform to decompose an image into a series of subbands, and then applies a bit-plane coding strategy to achieve high compression rates with minimal loss of image quality. The algorithm is capable of achieving very high compression rates, with compression ratios up to 100:1, depending on the complexity of the image and the desired level of quality.

Types of SPIHT Algorithm:

The SPIHT algorithm is classified into two types:

1. 2D-SPIHT:

The 2D-SPIHT algorithm is used for the compression of 2D images. In this algorithm, the wavelet transform is used to decompose the image into subbands, which are then quantized and encoded using bit-plane coding.

2. 3D-SPIHT:

The 3D-SPIHT algorithm is used for the compression of 3D data, such as video sequences. In this algorithm, the wavelet transform is applied to each frame of the video sequence, and then a 3D wavelet transform is used to decompose the data into subbands. The subbands are then quantized and encoded using bit-plane coding.

How does SPIHT Algorithm work?

The SPIHT algorithm works by using a hierarchical tree structure to encode the wavelet coefficients of the image. The tree structure is constructed by dividing the image into smaller subbands using the wavelet transform. The coefficients in each subband are then sorted based on their magnitude and divided into significant and insignificant sets.

The SPIHT algorithm uses a progressive bit-plane coding strategy, where the most significant bits of the wavelet coefficients are encoded first, followed by the less significant bits. The algorithm starts by encoding the most significant bit-plane of the significant set, which contains the largest wavelet coefficients. The bit-plane is encoded using a binary tree structure, where each node represents a group of coefficients with the same value.

The algorithm then proceeds to the next bit-plane, where it encodes the significant coefficients that have not yet been encoded, followed by the insignificant coefficients in the same bit-plane. The algorithm continues this process for all the bit-planes, until all the coefficients have been encoded.

Example

Sure, let me provide an example of the SPIHT algorithm without an image. In this example, we will use a simple array of wavelet coefficients to demonstrate how the algorithm works.

Suppose we have an array of wavelet coefficients:

-2 4 1 2 6 -5 7 0 3 9 -8 -4 5 2 -1 0


To encode this array using the SPIHT algorithm, we need to follow these steps:

1. Divide the coefficients into subbands using the wavelet transform. For simplicity, we will assume that the array is already divided into subbands.

2. Sort the coefficients in each subband based on their magnitude, and divide them into significant and insignificant sets.

For example, let's sort the coefficients in the first subband in descending order:

4 2 1 -2

We can see that the most significant coefficient is 4, followed by 2, 1, and -2.

Now we can divide these coefficients into significant and insignificant sets. Let's assume that we want to encode the first three coefficients as significant, and the last coefficient as insignificant:

Significant: 4 2 1
Insignificant: -2

3. Encode the most significant bit-plane of the significant set. In this example, the most significant bit is the sign bit, so we will encode the signs of the coefficients in the significant set.

We can represent the signs using a binary tree, where each node represents a group of coefficients with the same sign:

               4
/        \
2         1
/   \     /  \
+    -     -   +


In this tree, the plus sign (+) represents positive coefficients, and the minus sign (-) represents negative coefficients. We can encode this tree using a set of labels, where each label represents a group of coefficients:

Labels: 1 0 0 1

In this example, the labels tell us that the first two coefficients (4 and 2) are positive, and the last coefficient (1) is negative.

4. Encode the next bit-plane of the significant set, as well as the insignificant set. We repeat this process for each bit-plane until all the coefficients have been encoded.

In this example, the next bit-plane is the second most significant bit, which represents the magnitude of the coefficients. We can encode the magnitudes using a binary tree, where each node represents a group of coefficients with the same magnitude:

               4
/       \
2         1
/   \     /  \
1    1    0    1


In this tree, the number in each node represents the magnitude of the coefficients. We can encode this tree using a set of labels, where each label represents a group of coefficients:

Labels: 0 0 1 0 1

In this example, the labels tell us that the first two coefficients (4 and 2) have magnitude 1, the third coefficient (1) has magnitude 0, and the last coefficient (-2) has magnitude 1.

We can continue this process for each bit-plane until all the coefficients have been encoded.

5. Finally, we can decode the coefficients by reversing the encoding process. We start by decoding the most significant bit-plane of the significant set, and continue decoding each bit-plane until all the coefficients have been decoded.

To decode the coefficients, we use the same binary trees and labels that we used to encode them. We start by decoding the most significant bit-plane of the significant set, which in this example is the sign bit-plane. We use the labels to reconstruct the binary tree, and then use the tree to determine the signs of the coefficients.

Labels: 1 0 0 1 

We can reconstruct the binary tree using the labels:

               4
/        \
2         1
/   \     /  \
+    -     -   +


From this tree, we can determine that the first two coefficients (4 and 2) are positive, and the last coefficient (1) is negative.

Next, we decode the second most significant bit-plane of the significant set, as well as the insignificant set. We use the labels to reconstruct the binary tree for the magnitude bit-plane:

                4
/         \
2         1
/   \      /   \
1     1    0    1


From this tree, we can determine that the first two coefficients (4 and 2) have magnitude 1, the third coefficient (1) has magnitude 0, and the last coefficient (-2) has magnitude 1.

We continue this process for each bit-plane until all the coefficients have been decoded.

6. Finally, we use the inverse wavelet transform to reconstruct the original image from the wavelet coefficients.

This example demonstrates how the SPIHT algorithm encodes and decodes wavelet coefficients using a hierarchical tree structure and a progressive bit-plane coding strategy. By encoding the most significant bit-planes first and using a hierarchical tree structure to represent the coefficients, the algorithm can achieve high compression ratios while maintaining good image quality. The algorithm can also be used for real-time compression of images and video, as it allows for a rough preview of the image even before the entire image has been fully encoded.

1. High Compression Ratio:
The SPIHT algorithm is capable of achieving very high compression ratios, with minimal loss of image quality. This makes it an ideal algorithm for applications where storage space is limited, such as mobile devices or online media streaming.

2. Good Image Quality:
The SPIHT algorithm provides good image quality, even at high compression ratios. This is because the algorithm preserves the most significant wavelet coefficients, which contain the majority of the image details.

3. Progressive Encoding:
The SPIHT algorithm uses a progressive encoding strategy, where the image is encoded bit by bit. This allows the algorithm to provide a rough image preview even before the entire image has been fully encoded.

4. Simple Implementation:
The SPIHT algorithm is relatively simple to implement, and does not require a large amount of computational resources. This makes it an ideal algorithm for use in real-time image and video compression applications.

1. Sensitivity to Noise:
The SPIHT algorithm is sensitive to noise, which can cause the algorithm to produce artifacts or distortions in the compressed image. This can be a problem in applications where image quality is critical, such as medical imaging or satellite imagery.

2. High Computational Complexity: The SPIHT algorithm requires a significant amount of computation to perform the sorting and encoding operations. This can be a problem for real-time applications that require fast compression and decompression.

3. Memory Requirements: The SPIHT algorithm requires a significant amount of memory to store the hierarchical tree structure and the encoded bit-stream. This can be a problem for systems with limited memory resources.

4. Complexity of Implementation: The SPIHT algorithm is complex to implement, requiring a good understanding of wavelet transform and tree-based coding. This can be a problem for developers who are not familiar with these concepts.

Conclusion:

The SPIHT algorithm is a powerful image compression algorithm that provides high compression ratios with minimal loss of image quality. It achieves this by using a hierarchical tree structure and a progressive bit-plane coding strategy to encode the wavelet coefficients of the image. The algorithm is relatively simple to implement and provides good image quality even at high compression ratios. However, it is computationally complex and can be sensitive to noise.

The SPIHT algorithm has a wide range of applications, including mobile devices, online media streaming, and medical imaging. Its high compression ratios make it ideal for applications where storage space is limited, while its good image quality makes it suitable for applications where image quality is critical. The algorithm's progressive encoding strategy allows for a rough image preview even before the entire image has been fully encoded, making it ideal for real-time image and video compression applications.

In conclusion, the SPIHT algorithm is a powerful image compression algorithm that provides a balance between high compression ratios and good image quality. While it has some limitations, it remains a popular algorithm for a wide range of applications and is an important tool for image and video compression.