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

intersection_points function in hough.rs has bug if intersection point is in image corner. #533

Closed
alanthinker opened this issue Jul 1, 2023 · 1 comment

Comments

@alanthinker
Copy link

need check two point is not a same point.

should be:

    if right_y >= 0.0 && right_y <= h {
        let right_intersect = (w, right_y);
        if let Some(s) = start {
            if right_intersect != s {
                return Some((s, right_intersect));
            }
        }
        start = Some(right_intersect);
    }

    if left_y >= 0.0 && left_y <= h {
        let left_intersect = (0.0, left_y);
        if let Some(s) = start {
            if left_intersect != s {
                return Some((s, left_intersect));
            }
        }
        start = Some(left_intersect);
    }

    if bottom_x >= 0.0 && bottom_x <= w {
        let bottom_intersect = (bottom_x, h);
        if let Some(s) = start {
            if bottom_intersect != s {
                return Some((s, bottom_intersect));
            }
        }
        start = Some(bottom_intersect);
    }

    if top_x >= 0.0 && top_x <= w {
        let top_intersect = (top_x, 0.0);
        if let Some(s) = start {
            if top_intersect != s {
                return Some((s, top_intersect));
            }
        }
    }
@theotherphil
Copy link
Contributor

theotherphil commented May 19, 2024

With the current behaviour an intersection point at the corner of the image is counted twice. Under your proposal it's not counted at all. The function could be changed to return a list of intersection points and only return one point for a corner intersection but I think the current behaviour is reasonable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants