A Python package for efficient decomposition of satellite images in a Quad-Tree structure 🚀
GitHub: https://github.com/IPL-UV/satcompression 🌐
PyPI: https://pypi.org/project/satcompression/ 🛠️
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.
- 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. 🗺️
Install the latest version from PyPI:
pip install satcompression
import satcompression
import rasterio as rio
with rio.open('path/to/image.tif') as src:
image_meta = src.meta
image_data = src.read()
image_data_compress = satcompression.compress_and_encode_image_data(
image_data=image_data, detail_error_threshold=20
)
image_data_decompress = satcompression.reconstruct_image_data(
data=image_data_compress, dtype=image_data.dtype, nchannels=image_data.shape[0]
)
import satcompression
import matplotlib.pyplot as plt
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()
import satcompression
with rio.open('path/to/image.tif') as src:
image_data = src.read()
satcompression.create_classification_map(image_data, detail_error_threshold=20)