-
Notifications
You must be signed in to change notification settings - Fork 34
Description
- arosics version: 1.12.1
- Python version: 3.12.8
- Operating System: Linux, Ubuntu
Issue Description
Hello,
I'm the author of issue #67. I'm still using the AROSICS pipeline to align a collection of nightlights satellite imagery from the SDGSAT-1 satellite. Thanks to your advice—and the GDAL team—the nodata band issue has been resolved. However, I’m now facing another issue on the alignement results of my RGB images.
An SDGSAT product is composed of 2 images :
- A panchromatic image of 10-meters resolution
- A RGB image of 40-meters resolution.
To align both of these images to a common reference, here's the workflow I use:
- Align panchromatic images using AROSICS : I compute GCPs with AROSICS on my reference panchromatic image and use them to align the target panchromatic image.
- Reuse and refine GCPs to align the RGB image : To align the corresponding RGB image, I reuse the GCPs computed during the panchromatic alignment. Since the resolutions differ (10m vs 40m), I scale the pixel coordinates accordingly:
## AROSICS parameters
GRID_RES = 50 # Grid resolution (in pixel)
WINDOW_SIZE = 100 # Window size (in pixel)
TIE_P_FILTER_LEVEL = 1 # Filter tie points used for shift correction
RESAMPLING_ALG = "nearest" # Warp resample method
CPUS = 20 # Number of CPUs
PROGRESS = False
QUIET = True
COMPRESS = ["COMPRESS=LZW", "PREDICTOR=2"]
FMT_OUT = "GTIFF"
NODATA = 0
PAN_RES = 10
RGB_RES = 40
coregister = arosics.COREG_LOCAL(
str(ref["pan"]),
str(target["pan"]),
mask_baddata_ref=ref["pan_snow_mask"], ## retrieve snow mask here !!
mask_baddata_tgt=target["pan_snow_mask"],
grid_res=GRID_RES,
window_size=(WINDOW_SIZE, WINDOW_SIZE),
path_out=register_pan,
r_b4match=1,
s_b4match=1,
tieP_filter_level=TIE_P_FILTER_LEVEL,
resamp_alg_deshift=RESAMPLING_ALG,
resamp_alg_calc="cubic",
fmt_out=FMT_OUT,
CPUs=CPUS,
progress=PROGRESS,
nodata=(NODATA, NODATA),
out_crea_options=COMPRESS,
q=QUIET,
)
coregister.correct_shifts()
res_ratio = PAN_RES / RGB_RES
rgb_coregister = coregister
rgb_coregister.coreg_info["GCPList"] = [
gdal.GCP(
gcp.GCPX,
gcp.GCPY,
0,
gcp.GCPPixel * res_ratio,
gcp.GCPLine * res_ratio,
)
for gcp in coregister.coreg_info["GCPList"]
]
- Use
DESHIFTERto apply shifts on RGB image: Finally, I apply the refined GCPs using the DESHIFTER class:
deshifter = arosics.DESHIFTER(
im2shift=rgb_target_path,
coreg_results=rgb_coregister.coreg_info,
align_grids=False, # True ?
match_gsd=False,
fmt_out=FMT_OUT,
resamp_alg=RESAMPLING_ALG,
out_crea_options=COMPRESS,
path_out=out_path,
CPUs=CPUS,
progress=PROGRESS,
q=QUIET,
)
deshifter.correct_shifts()
While the alignment results on the panchromatic images are visually good, the results on the RGB images are not as accurate. The misalignment is visible and consistent.
I’m wondering:
- Could the way I refine and reuse the GCPs be incorrect?
- Could any of the DESHIFTER arguments be affecting the resulting RGB image ?
I've attached a small test dataset (github_dataset.zip) in case you want to reproduce the issue.
What I Have Tried So Far
I’ve tested changing align_grids in the DESHIFTER call from False to True. This gives me an output RGB image with a 1-pixel difference in width/height compared to the original image, which is undesirable since I need the output to be perfectly consistent in dimensions for compositing purposes.
Additionally, this change does not improve the RGB alignment.
I'm also not entirely sure I understand the purpose and implications of the align_grids parameter in this context.
Thanks in advance for your time and insights!