Skip to content

Commit

Permalink
Merge branch 'enhancement/fix_ransac_random_state' into 'main'
Browse files Browse the repository at this point in the history
Enhancement/fix ransac random state

See merge request danschef/arosics!35
  • Loading branch information
Daniel Scheffler committed May 4, 2023
2 parents 9fe4905 + ed66dd5 commit a8ef852
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ History
* Re-implemented interpolation of tie point attributes into space (!23).
Three techniques are now supported: RBF, GPR, and Ordinary Kriging. Added scikit-learn to dependencies.
* Fixed GDAL warning related to PROJ_DATA/PROJ_LIB environment variables (!34).
* Added parameter 'rs_random_state' (RANSAC random state) and set it to 0 by default (!35).


1.8.1 (2023-03-10)
Expand Down
8 changes: 7 additions & 1 deletion arosics/CoReg_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def __init__(self,
min_reliability: float = 60,
rs_max_outlier: float = 10,
rs_tolerance: float = 2.5,
rs_random_state: Optional[int] = 0,
align_grids: bool = True,
match_gsd: bool = False,
out_gsd: float = None,
Expand Down Expand Up @@ -181,6 +182,9 @@ def __init__(self,
:param rs_tolerance:
RANSAC tie point filtering: percentage tolerance for max_outlier_percentage (default: 2.5%)
:param rs_random_state:
RANSAC random state (an integer corresponds to a fixed/pseudo-random state, None randomizes the result)
:param align_grids:
True: align the input coordinate grid to the reference (does not affect the output pixel size as long as
input and output pixel sizes are compatible (5:30 or 10:30 but not 4:30), default = True
Expand Down Expand Up @@ -293,6 +297,7 @@ def __init__(self,
self.min_reliability = min_reliability
self.rs_max_outlier = rs_max_outlier
self.rs_tolerance = rs_tolerance
self.rs_random_state = rs_random_state
self.align_grids = align_grids
self.match_gsd = match_gsd
self.out_gsd = out_gsd
Expand Down Expand Up @@ -475,7 +480,8 @@ def calculate_spatial_shifts(self) -> None:
outlDetect_settings=dict(
min_reliability=self.min_reliability,
rs_max_outlier=self.rs_max_outlier,
rs_tolerance=self.rs_tolerance),
rs_tolerance=self.rs_tolerance,
rs_random_state=self.rs_random_state),
dir_out=self.projectDir,
CPUs=self.CPUs,
progress=self.progress,
Expand Down
9 changes: 7 additions & 2 deletions arosics/Tie_Point_Grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def __init__(self,
:param outlDetect_settings:
a dictionary with the settings to be passed to arosics.TiePointGrid.Tie_Point_Refiner.
Available keys: min_reliability, rs_max_outlier, rs_tolerance, rs_max_iter, rs_exclude_previous_outliers,
rs_timeout, q. See documentation there.
rs_timeout, rs_random_state, q. See documentation there.
:param dir_out:
output directory to be used for all outputs if nothing else is given to the individual methods
Expand Down Expand Up @@ -1000,6 +1000,7 @@ def __init__(self, GDF,
rs_max_iter: int = 15,
rs_exclude_previous_outliers: bool = True,
rs_timeout: float = 20,
rs_random_state: Optional[int] = 0,
q: bool = False):
"""Get an instance of Tie_Point_Refiner.
Expand All @@ -1016,6 +1017,8 @@ def __init__(self, GDF,
:param rs_exclude_previous_outliers: RANSAC: whether to exclude points that have been flagged as
outlier by earlier filtering (default:True)
:param rs_timeout: RANSAC: timeout for iteration loop in seconds (default: 20)
:param rs_random_state: RANSAC random state (an integer corresponds to a fixed/pseudo-random
state, None randomizes the result)
:param q:
"""
Expand All @@ -1026,6 +1029,7 @@ def __init__(self, GDF,
self.rs_max_iter = rs_max_iter
self.rs_exclude_previous_outliers = rs_exclude_previous_outliers
self.rs_timeout = rs_timeout
self.rs_random_state = rs_random_state
self.q = q
self.new_cols = []
self.ransac_model_robust = None
Expand Down Expand Up @@ -1198,7 +1202,8 @@ def _RANSAC_outlier_detection(self, inGDF):
),
stop_residuals_sum=int(
(self.rs_max_outlier_percentage - self.rs_tolerance) /
100 * src_coords.shape[0])
100 * src_coords.shape[0]),
random_state=self.rs_random_state
)
else:
warnings.warn('RANSAC filtering could not be applied '
Expand Down

0 comments on commit a8ef852

Please sign in to comment.