Thanks to visit codestin.com
Credit goes to github.com

Skip to content

potentially running too many iterations in Ransac #8251

@aivision2020

Description

@aivision2020

in skimage/measure/fit.py
managing the number of iterations is done with max_trials. This is compared to _dynamic_max_trials which is computed using the largest inlier group found so far. However, this comparison is done only in cases when sample_inlier_num is larger than the biggest group. In cases when a large group is found early (but not large enough to end) the best_inlier_num is updated but the max_trials is not updated and will only be checked next time a larger group is found.

the lines (926) :

            if (
                best_inlier_num >= stop_sample_num
                or best_inlier_residuals_sum <= stop_residuals_sum
                or num_trials
                    >= _dynamic_max_trials(best_inlier_num, num_samples,
                                           min_samples, stop_probability)
            ):
                break

should be

             max_trials = min(max_trials, _dynamic_max_trials(best_inlier_num, num_samples,
                                           min_samples, stop_probability))
            if (
                best_inlier_num >= stop_sample_num
                or best_inlier_residuals_sum <= stop_residuals_sum
                or num_trials > max_trials
            ):
                break 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions