GFZ / arosics

AROSICS - Automated and Robust Open-Source Image Co-Registration Software
https://git.gfz-potsdam.de/danschef/arosics
Apache License 2.0
137 stars 26 forks source link

Failed in level 3 filtering (RANSAC). #24

Closed rubikube2237 closed 1 year ago

rubikube2237 commented 1 year ago

Description

I tried to geometric correct an Aster image based on a Landsat-8 image (only Band 8 is used) using arosics. However, after level 2 filtering (SSIM), level 3 filtering (RANSAC) didn't appear, and it ended with "killed". Below is the output.

image

What I Did

Because there's some wrong with the jupyter lab, I wrote the codes in a .py file. Below are the codes.

import arosics from geoarray import GeoArray from osgeo import gdal, osr import matplotlib.pyplot as plt import os

path = r'../arosics/sample' im_reference = os.path.join(path, 'reference.tif') im_target = os.path.join(path, 'target.tif') res = os.path.join(path, 'result.tif')

ref_geoArr, tgt_geoArr = GeoArray(im_reference), GeoArray(im_target)

ref_ndarray, tgt_ndarray = ref_geoArr[:], tgt_geoArr[:] ref_gt, tgt_gt = ref_geoArr.geotransform, tgt_geoArr.geotransform ref_prj, tgt_prj = ref_geoArr.projection, tgt_geoArr.projection

geoArr_reference = GeoArray(ref_ndarray, ref_gt, ref_prj) geoArr_target = GeoArray(tgt_ndarray, tgt_gt, tgt_prj)

CR = arosics.CoReg_local.COREG_LOCAL(geoArr_reference, geoArr_target, grid_res=15.0, window_size=(256, 256), path_out=res, fmt_out="GTIFF", CPUs=24)

CR.calculate_spatial_shifts()

CR.correct_shifts()

danschef commented 1 year ago

You may have a look at your memory resources while running the co-registration, I guess your machine is simply running out of memory. Just reduce the grid resolution (which defines the spatial density of the computed tie points. To achieve a good co-registration result, I would tune it in a way that it computes around 1000 tie points. With grid_res=15, you compute 79032 tie points which is computationally expensive and needs a lot of memory.

rubikube2237 commented 1 year ago

You may have a look at your memory resources while running the co-registration, I guess your machine is simply running out of memory. Just reduce the grid resolution (which defines the spatial density of the computed tie points. To achieve a good co-registration result, I would tune it in a way that it computes around 1000 tie points. With grid_res=15, you compute 79032 tie points which is computationally expensive and needs a lot of memory.

Thank you! But the resolution of the image is 15m, if I adjust the resolution to a larger size, will the accuracy of the results be affected?

rubikube2237 commented 1 year ago

You may have a look at your memory resources while running the co-registration, I guess your machine is simply running out of memory. Just reduce the grid resolution (which defines the spatial density of the computed tie points. To achieve a good co-registration result, I would tune it in a way that it computes around 1000 tie points. With grid_res=15, you compute 79032 tie points which is computationally expensive and needs a lot of memory.

And, I guess this doesn't have anything to do with the grid resolution. I changed to another reference image, but the target image and the codes are the same as before. This also compute 79032 tie points with grid_res=15, but it got a result sucessfully. So are there any other possibilities for the error? Thank you in advance!

1

danschef commented 1 year ago

The resolution of the image is automatically read from the image metadata, you don´t need to specify it.

The grid resolution defines the distance between the computed tie points. A grid resolution of 1 means that AROSICS will compute a tie point on each pixel of the target image, which is absolutely not needed and may also cause warping artifacts in the output in case false-positives are not properly filtered. grid_res=15 will compute tie points for each 15th pixel. However, the misregistration pattern between the reference and target image is usually not very complex and you don´t need a very dense grid of tie points to get a good co-registration result. You can also see from the above log, that at the moment, not more than 7000 tie points are respected for computing the co-registered result, so it really makes no sense to compute 80000 tie points. Just reduce the grid resolution (e.g., to grid_res=50)and try the first case again.

rubikube2237 commented 1 year ago

The resolution of the image is automatically read from the image metadata, you don´t need to specify it.

The grid resolution defines the distance between the computed tie points. A grid resolution of 1 means that AROSICS will compute a tie point on each pixel of the target image, which is absolutely not needed and may also cause warping artifacts in the output in case false-positives are not properly filtered. grid_res=15 will compute tie points for each 15th pixel. However, the misregistration pattern between the reference and target image is usually not very complex and you don´t need a very dense grid of tie points to get a good co-registration result. You can also see from the above log, that at the moment, not more than 7000 tie points are respected for computing the co-registered result, so it really makes no sense to compute 80000 tie points. Just reduce the grid resolution (e.g., to grid_res=50)and try the first case again.

Thank you! I tried to change the grid_res, and it worked! Thank you so much!