Skip to content

A Python package for efficient decomposition of satellite images in a Quad-Tree structure πŸš€

PyPI License Black isort


GitHub: https://github.com/IPL-UV/satcompression 🌐

PyPI: https://pypi.org/project/satcompression/ πŸ› οΈ


Overview πŸ“Š

satcompression is a Python package designed for efficient compression and decompression of satellite images using a Quad-Tree structure. The package provides a structured way to partition satellite images into hierarchical blocks, enabling efficient image storage, analysis, and pseudo-MTF (Modulation Transfer Function) calculations based on the compression.

Key features ✨

  • Quad-Tree compression: Efficiently compress satellite images by recursively subdividing the image into smaller blocks based on pixel variability. πŸ–ΌοΈ
  • Image reconstruction: Restore compressed images to their original state from the Quad-Tree structure. πŸ“‚
  • Pseudo-MTF calculation: Obtain pseudo-MTF values from the quadtree structure to assess the impact of compression on image sharpness. πŸ“ˆ
  • Classification map: Generate a classification map of the nodes in the Quad-Tree structure based on compression detail thresholds. πŸ—ΊοΈ

Installation βš™οΈ

Install the latest version from PyPI:

pip install satcompression

How to use πŸ› οΈ

Compression and decompression of satellite images πŸ›°οΈ

Load libraries

import satcompression
import rasterio as rio

Load an image

with rio.open('path/to/image.tif') as src:
    image_meta = src.meta
    image_data = src.read()

Compress the image

image_data_compress = satcompression.compress_and_encode_image_data(
    image_data=image_data, detail_error_threshold=20
)

Decompress the image

image_data_decompress = satcompression.reconstruct_image_data(
    data=image_data_compress, dtype=image_data.dtype, nchannels=image_data.shape[0]
)

Calculate pseudo-MTF from Quad-Tree decomposition πŸ“Š

Load libraries

import satcompression
import matplotlib.pyplot as plt

Obtain pseudo-MTF values

with rio.open('path/to/image.tif') as src:    
    image_data = src.read()

# Calculate pseudo-MTF with different detail error thresholds
mtf_values1, x_axis1 = satcompression.quadtree_mtf(image_data, 10, detail_error_threshold=20)
mtf_values2, x_axis2 = satcompression.quadtree_mtf(image_data, 10, detail_error_threshold=10)
mtf_values3, x_axis3 = satcompression.quadtree_mtf(image_data, 10, detail_error_threshold=5)

# Plot the pseudo-MTF results
plt.plot(x_axis1, mtf_values1, label="Detail Error Threshold: 20")
plt.plot(x_axis2, mtf_values2, label="Detail Error Threshold: 10")
plt.plot(x_axis3, mtf_values3, label="Detail Error Threshold: 5")
plt.legend()
plt.ylim(0, 1.2)
plt.title("Pseudo-MTF obtained from the quadtree decomposition")
plt.show()

Create a classification map from the Quad-Tree nodes πŸ—ΊοΈ

Load libraries

import satcompression

Generate classification map from Quad-Tree compression

with rio.open('path/to/image.tif') as src:    
    image_data = src.read()

satcompression.create_classification_map(image_data, detail_error_threshold=20)

Back to top