Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matching window in target image is larger than overlap area but further shrinking the matching window is not possible. #56

Open
fucongju opened this issue Nov 23, 2024 · 1 comment
Assignees
Labels
help wanted Extra attention is needed

Comments

@fucongju
Copy link

fucongju commented Nov 23, 2024

  • arosics version: 1.12.0
  • Python version: 3.10.15
  • Operating System: Linux, Ubuntu

Description

There is an offset in the geometric coordinates of the PRISMA satellite and I am trying to correct it using Sentinel-2 as a reference image. Then an error occurred regarding the input parameters:

(GR) congju@congjufu:~/georeferencing$ python AutomaticGeographicRegistration.py
/home/congju/anaconda3/envs/GR/lib/python3.10/site-packages/scipy/__init__.py:146: UserWarning: A NumPy version >=1.17.3 and <1.25.0 is required for this version of SciPy (detected version 1.26.4
  warnings.warn(f"A NumPy version >={np_minversion} and <{np_maxversion}"
Processing tif files:   0%|                                                                       | 0/1 [00:00<?, ?it/s]Processing file #1: /home/congju/georeferencing/PRISMA/20230524101720.tif
Bounds of target TIFF file: BoundingBox(left=12.029533386230469, bottom=45.29204559326172, right=12.502799034118652, top=45.62303924560547)
Bounds of reference file /home/congju/georeferencing/standard/S2_b4_WGS84.tif: BoundingBox(left=11.538706894083058, bottom=44.99756712645166, right=12.999299064947925, top=46.024365385438045)
Reference file for /home/congju/georeferencing/PRISMA/20230524101720.tif is /home/congju/georeferencing/standard/S2_b4_WGS84.tif
Automatically detected nodata value for GeoArray_CoReg 'IN_MEM': 0.0
Calculating footprint polygon and actual data corner coordinates for reference image...
Polygonize progress     |==================================================| 100.0% Complete  => 0:00:00
Bounding box of calculated footprint for reference image:
        (11.538706894083058, 44.99756712645166, 12.999238484236837, 46.024365385438045)
Automatically detected nodata value for GeoArray_CoReg 'IN_MEM': nan
Calculating footprint polygon and actual data corner coordinates for image to be shifted...
Polygonize progress     |==================================================| 100.0% Complete  => 0:00:00
/home/congju/anaconda3/envs/GR/lib/python3.10/site-packages/arosics/CoReg.py:124: UserWarning: The footprint of the image to be shifted contains multiple separate image parts. AROSICS will only process the largest image part.
  warnings.warn('The footprint of the %s contains multiple separate image parts. '
Bounding box of calculated footprint for image to be shifted:
        (12.192810034751892, 45.29204559326172, 12.502799034118652, 45.62303924560547)
Matching window position (X,Y): 12.392802429719932/45.41217173577678
/home/congju/georeferencing/AutomaticGeographicRegistration.py:118: UserWarning:
First attempt to check the functionality of co-registration failed. Check your input data and parameters. The following error occurred:
  auto_adjust_local_coreg(geoArr_reference, geoArr_target, outputfile)
**Failed to coregister /home/congju/georeferencing/PRISMA/20230524101720.tif due to Matching window in target image is larger than overlap area but further shrinking the matching window is not possible.** Check if the footprints of the input data have been computed correctly.
Processing tif files: 100%|███████████████████████████████████████████████████████████████| 1/1 [00:05<00:00,  5.53s/it]

Please should I change any parameters?

What I Did

def auto_adjust_local_coreg(geoArr_reference, geoArr_target, outputfile, initial_grid_res=900, initial_max_shift=900):
        grid_res = initial_grid_res
        max_shift = initial_max_shift
        while True:
            try:
                CR_LOCAL = COREG_LOCAL(
                    geoArr_reference,
                    geoArr_target,
                    grid_res=grid_res,
                    max_shift=max_shift,
                    path_out=outputfile,
                    CPUs=2
                )
                CR_LOCAL.calculate_spatial_shifts()
                CR_LOCAL.correct_shifts()
                break  # if no errors, break the loop
            except RuntimeError as e:
                if 'No match found in the given window' in str(e):
                    # adjust parameters and try again
                    grid_res += 40
                    max_shift += 50
                else:
                    raise e
@danschef
Copy link
Collaborator

danschef commented Dec 3, 2024

Sorry for the delayed reply.

The RunTimeError "No match found in the given window" is an error which may pop up when calling arosics.COREG, i.e., the global co-registration, because it refers to the computation of a single tie-point. In your snippet above, you are calling arosics.COREG_LOCAL, i.e., the local coregistration, which computes a whole grid of tie points. There, this RuntimeError will NOT be raised - it is captured at runtime. So I also see no reason to run COREG_LOCAL within a while-loop. I suggest to set the parameters grid_res and max_shift with reasonable values from the beginning on.

  • grid_res defines the distance between the computed tie-points as the number of pixels of the target image, i.e., if your target image has 1000x1000 pixels and you set grid_res to 100, arosics would try to compute more or less than 100 (10x10) tie points.
  • max_shift is meant to filter out tie points which do make sense at all because the computed shift is just too large. So set this parameter to a shift length which you think is too large to be reasonable (in reference image pixel units)

Please also check the documentation of the COREG_LOCAL parameters here.

@danschef danschef self-assigned this Dec 3, 2024
@danschef danschef added the help wanted Extra attention is needed label Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants