[Python] Fitting curves in an image and finding intersection points

Discussão em 'Python' iniciado por Stack, Março 29, 2025.

  1. Stack

    Stack Membro Participativo

    I am working on some images to extract two curves and find their intersection points.

    Doing a sobel and then applying canny edge filter pops them out.

    How do I fit curves to them and find the two intersection points (which they will have for sure)?

    import cv2
    import numpy as np

    img = cv2.imread('image6.jpg')
    grad_x = cv2.Sobel(img, cv2.CV_64F, 1, 0, 3)
    grad_y = cv2.Sobel(img, cv2.CV_64F, 0, 1, 3)
    grad = np.sqrt(grad_x**2 + grad_y**2)
    grad_norm = (grad * 255 / grad.max()).astype(np.uint8)
    grad_norm = cv2.blur(grad_norm,(3,3))
    cv2.imshow('Blur', grad_norm)
    cv2.waitKey(0)
    # Canny Edge Detection
    edges = cv2.Canny(image=grad_norm, threshold1=100, threshold2=200) # Canny Edge Detection
    # Display Canny Edge Detection Image
    cv2.imshow('Canny Edge Detection', edges)
    cv2.waitKey(0)


    Original
    [​IMG]

    End result
    [​IMG]
    I am looking to get the red points shown above.

    Continue reading...

Compartilhe esta Página