Commit 5de8577f authored by Laura, Jason R.'s avatar Laura, Jason R.
Browse files

Merge branch 'Shear_Error' into 'main'

Betterish way of dealing with too high of an affine in subpixel registration

See merge request astrogeology/autocnet!694
parents 33f3ff8e dfb911a1
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -44,6 +44,7 @@ release.
- Fixed Errors in `network.py`
- Fixed Errors in `network.py`
- Finding points in polar areas that avoids dividing by zero errors
- Finding points in polar areas that avoids dividing by zero errors
- Small errors in `overlap.py` to get overlap function working.
- Small errors in `overlap.py` to get overlap function working.
- Raise an exception if the shear is too high when trying to find the baseline affine


## [1.1.0]
## [1.1.0]
### Added
### Added
+7 −5
Original line number Original line Diff line number Diff line
@@ -397,13 +397,15 @@ def subpixel_register_point(pointid,
                             size_y=match_kwargs['template_size'][1],
                             size_y=match_kwargs['template_size'][1],
                             buffer=5)
                             buffer=5)


        try:
            baseline_affine = estimate_local_affine(reference_roi, moving_roi)
            baseline_affine = estimate_local_affine(reference_roi, moving_roi)

            # Updated so that the affine used is computed a single time.
            # Updated so that the affine used is computed a single time.
            # Has not scale or shear or rotation.
            # Has not scale or shear or rotation.
            updated_affine, maxcorr, _ = subpixel_template(reference_roi,
            updated_affine, maxcorr, _ = subpixel_template(reference_roi,
                                                        moving_roi,
                                                        moving_roi,
                                                        affine=baseline_affine)
                                                        affine=baseline_affine)
        except:
            updated_affine = None
        
        
        if updated_affine is None:
        if updated_affine is None:
            log.warn('Unable to match with this parameter set.')
            log.warn('Unable to match with this parameter set.')
+1 −1
Original line number Original line Diff line number Diff line
@@ -129,7 +129,7 @@ def estimate_local_affine(reference_roi, moving_roi):
        # with high shear match poorly. The search templates also have reflection (ROI object, x/y_read_length)
        # with high shear match poorly. The search templates also have reflection (ROI object, x/y_read_length)
        # because a high shear affine requires  alot of data to be read in. 
        # because a high shear affine requires  alot of data to be read in. 
        # TODO: Consider handling this differently in the future should nadir to high slew image matching be required.
        # TODO: Consider handling this differently in the future should nadir to high slew image matching be required.
        log.warn(f'Affine shear: {affine_transform.shear} is greater than 1e-2. It is highly unlikely that these images will match.')
        raise Exception(f'Affine shear: {affine_transform.shear} is greater than 1e-2. It is highly unlikely that these images will match, so skipping.')
    # The above coordinate transformation to get the center of the ROI handles translation. 
    # The above coordinate transformation to get the center of the ROI handles translation. 
    # So, we only need to rotate/shear/scale the ROI. Omitting scale, which should be 1 (?) results
    # So, we only need to rotate/shear/scale the ROI. Omitting scale, which should be 1 (?) results
    # in an affine transoformation that does not match the full image affine
    # in an affine transoformation that does not match the full image affine