GFZ / arosics

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

CRL.correct_shifts() after COREG_LOCAL reports: ValueError: The length of the given lists must be equal to the number of bands. Received a list with 3 items for 'STATISTICS_APPROXIMATE'. #55

Closed MarioTro closed 1 month ago

MarioTro commented 1 month ago

Description

I would like to register an RGB 1cm GSD geotif and a multispectral (4 band) 2cm GSD orthophoto. The images were produces by WebODM, raw data was collected with a DJI Mavic 3M.

I am able to run COREG_LOCAL with various settings. However, when I am running

CRL.correct_shifts()

I get this error: ValueError: The length of the given lists must be equal to the number of bands. Received a list with 3 items for 'STATISTICS_APPROXIMATE'.

(global coregistration via arosics.COREG works fine!)

What I Did

CRL = COREG_LOCAL(
    im_ref = im_reference,
    im_tgt = im_target,
    grid_res = 200,
    window_size = (64,64),
    path_out = output_file,
    projectDir = os.path.dirname(output_file),
    v = True, # verbose
    max_shift = 50,
    align_grids = True,
    match_gsd = True,
    r_b4match = 2,
    s_b4match = 2,
)

CRL.correct_shifts()

The full error message:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mario/Documents/Python/Arosics_based_image_registration/arosics_env/lib/python3.12/site-packages/arosics/CoReg_local.py", line 788, in correct_shifts
    self.calculate_spatial_shifts()
  File "/home/mario/Documents/Python/Arosics_based_image_registration/arosics_env/lib/python3.12/site-packages/arosics/CoReg_local.py", line 459, in calculate_spatial_shifts
    self._tiepoint_grid.get_CoRegPoints_table()
  File "/home/mario/Documents/Python/Arosics_based_image_registration/arosics_env/lib/python3.12/site-packages/arosics/Tie_Point_Grid.py", line 351, in get_CoRegPoints_table
    for i, res in enumerate(
  File "/home/mario/Documents/Python/Arosics_based_image_registration/arosics_env/lib/python3.12/site-packages/joblib/parallel.py", line 1650, in _get_outputs
    yield from self._retrieve()
  File "/home/mario/Documents/Python/Arosics_based_image_registration/arosics_env/lib/python3.12/site-packages/joblib/parallel.py", line 1754, in _retrieve
    self._raise_error_fast()
  File "/home/mario/Documents/Python/Arosics_based_image_registration/arosics_env/lib/python3.12/site-packages/joblib/parallel.py", line 1789, in _raise_error_fast
    error_job.get_result(self.timeout)
  File "/home/mario/Documents/Python/Arosics_based_image_registration/arosics_env/lib/python3.12/site-packages/joblib/parallel.py", line 745, in get_result
    return self._return_or_raise()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mario/Documents/Python/Arosics_based_image_registration/arosics_env/lib/python3.12/site-packages/joblib/parallel.py", line 763, in _return_or_raise
    raise self._result
ValueError: The length of the given lists must be equal to the number of bands. Received a list with 3 items for 'STATISTICS_APPROXIMATE'.
MarioTro commented 1 month ago

UPDATE: It now works for some settings of grid_res (2000) and window_size (64,64). But the result is not great. How can I estimate good values for these parameters? (e.g. given a very high resolution (1cm GSD) orthophoto and local mismatches)

danschef commented 1 month ago

For the ValueError above, please refer to https://github.com/GFZ/arosics/issues/29.

It now works for some settings of grid_res (2000) and window_size (64,64). But the result is not great.

For this, please open another issue (as it is not related to the ValueError above) and include screenshots of input images. Note that the accuracy of the derived shifts improves with larger window sizes. The default is (256, 256) and with very high resolution data, you should rather enlarge the window size than reducing it. Also make sure that the maximum possible shift should be covered by the window size (the expected shift should be smaller than half of the window size).

MarioTro commented 1 month ago

Many thanks. I will do some testing with various parameters to see if the quality problem persists. Maybe the problem sits in front of the computer or it is in the dataset. ;) Anyway, many thanks for creating and maintaining this package! It is very useful and saves me a lot of work! =)