From 2d31ced3184c653b37c40cf615209ce7d3aa6279 Mon Sep 17 00:00:00 2001 From: Narcon Nicolas <nicolas.narcon@inrae.fr> Date: Tue, 2 Aug 2022 17:15:59 +0200 Subject: [PATCH] Use RCS algo for rasterio example --- functions_for_rasterio.py | 22 ++++++++++++++++++---- with_rasterio.py | 4 ++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/functions_for_rasterio.py b/functions_for_rasterio.py index 2c76300..563e42b 100644 --- a/functions_for_rasterio.py +++ b/functions_for_rasterio.py @@ -1,8 +1,21 @@ -import numpy as np -from skimage.transform import rescale -import skimage.color as color +from scipy import ndimage +def rcs_pansharpen(xs, pan): + """ + Implemented by me + cf https://www.sfpt.fr/hyperspectral/wp-content/uploads/2018/01/May_panorama_pansharpening.pdf + """ + + xs_zoom = ndimage.zoom(xs, zoom=4) + pan_low_pass = ndimage.gaussian_filter(pan, sigma=1) + + pansharpened = xs_zoom * (pan / pan_low_pass) + return pansharpened + + +## NOT USED ANYMORE (can not compare speed with OTB) +""" # functions def stretch(bands, lower_percent=2, higher_percent=98): out = np.zeros_like(bands) @@ -96,4 +109,5 @@ def pansharpen(m, pan, method='browley', W=0.1, all_data=False): if all_data: return rgbn_scaled, image, I else: - return image \ No newline at end of file + return image +""" \ No newline at end of file diff --git a/with_rasterio.py b/with_rasterio.py index 01dfbd9..c363b62 100644 --- a/with_rasterio.py +++ b/with_rasterio.py @@ -1,5 +1,5 @@ import rasterio -from functions_for_rasterio import pansharpen +from functions_for_rasterio import rcs_pansharpen xs_path = 'xs.tif' pan_path = 'pan.vrt' @@ -17,5 +17,5 @@ print(xs.shape) print(pan.shape) # Pansharpening -pxs = pansharpen(xs, pan) +pxs = rcs_pansharpen(xs, pan) -- GitLab