Skip to content

Efficient decomposition of satellite images in a Quad-Tree structure

License

Notifications You must be signed in to change notification settings

IPL-UV/satcompression

Folders and files

NameName
Last commit message
Last commit date

Latest commit

d507353 ยท Sep 16, 2024

History

8 Commits
Sep 7, 2024
Sep 16, 2024
Jul 13, 2024
Jul 12, 2024
Jul 13, 2024
Sep 16, 2024
Sep 7, 2024
Sep 16, 2024
Jul 12, 2024
Jul 12, 2024
Sep 16, 2024
Jul 12, 2024
Jul 12, 2024
Sep 16, 2024
Jul 12, 2024
Jul 12, 2024
Jul 12, 2024
Sep 7, 2024
Jul 12, 2024

Repository files navigation

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)