A Python package to fusion LR and HR imagery 🚀
GitHub: https://github.com/IPL-UV/sathybrid 🌐
PyPI: https://pypi.org/project/sathybrid/ 🛠️
Sathybrid is a Python package designed for fusing low-resolution (LR) and high-resolution (HR) satellite imagery. It allows users to combine spatial and spectral details from different sources, enhancing imagery through methods like Fourier transform fusion and interpolation techniques. The package supports multiple downsampling methods, and it also includes features like image denoising, histogram matching, and kernel-based blurring.
- Image fusion: Combines LR and HR images using Fourier-based interpolation and various resampling techniques (e.g., Lanczos, cubic). 🌍
- Denoising with SwinIR: Utilizes the SwinIR model for efficient image denoising prior to fusion. 🧹
- Custom kernels: Apply customizable kernels such as Lanczos and cubic for image processing. 🎛️
- Fourier filtering: Supports multiple Fourier filters (ideal, Butterworth, Gaussian) for frequency-domain fusion. ⚙️
- Efficient resampling: Resizes images with support for different interpolation methods like Lanczos and cubic. 📐
Install the latest version from PyPI:
pip install sathybrid
import sathybrid
import pathlib
PATH = pathlib.Path("/home/cesar/demo/NA5120_E1186N0724/")
HRfile = PATH / "naip" / "m_3812243_nw_10_060_20220524.tif"
LRfile = PATH / "s2" / "s2_image.tif"
OUTfile = PATH / "fusion.tif"
sathybrid.image_fusion(
hr_file=HRfile,
lr_file=LRfile,
output_file=OUTfile,
scale_factor=8,
hr_bands=[1, 2, 3],
hr_normalization=255,
lr_bands=[3, 2, 1],
lr_normalization=10_000,
upsampling_method="lanczos3",
fourier=True,
fourier_params={"method": "butterworth", "order": 6, "sharpness": 3},
denoise=True,
)
from sathybrid.utils import find_similar_lr
data_stats = find_similar_lr(
hr_file=HRfile,
lr_folder=PATH / "s2",
hr_bands=[1, 2, 3],
lr_bands=[3, 2, 1],
downsampling_method="lanczos3",
method="fft_l1"
)
best_lr_image = data_stats.iloc[0]["lr_img"]
print(f"Most similar LR image: {best_lr_image}")
from sathybrid.blur import apply_kernel_to_image
import torch
image = torch.randn(1, 3, 256, 256).cuda()
smoothed_image = apply_kernel_to_image(image, kernel_size=5, method="triangle")
from sathybrid.main import setup_denoiser, image_denoise
denoiser = setup_denoiser()
image_tensor = torch.randn(1, 3, 256, 256)
denoised_image = image_denoise(image_tensor, denoiser)
from sathybrid.main import image_fusion
HRfile = "/path/to/hr_image.tif"
LRfile = "/path/to/lr_image.tif"
OUTfile = "/path/to/output/fusion.tif"
hybrid_image, error = image_fusion(
hr_file=HRfile,
lr_file=LRfile,
output_file=OUTfile,
scale_factor=4,
fourier=True,
fourier_params={"method": "gaussian", "sharpness": 2.5},
denoise=False,
)
-
Resampling methods:
lanczos3
,lanczos5
,lanczos7
,cubic
,nearest
.
-
Fourier filters:
ideal
,butterworth
,gaussian
,sigmoid