[Python] How to find the center and radius of Earth in grayscale satellite images using OpenCV?

Discussão em 'Python' iniciado por Stack, Maio 16, 2025.

  1. Stack

    Stack Membro Participativo

    [​IMG]

    I have thousands of grayscale satellite images of Earth, and I want to automatically find the center (x, y) and radius of the Earth’s edge in each image.

    I tried using Hough Circle Transform in OpenCV. It doesn't work because of clouds and noise in the image. I have to tune the parameters (like radius, thresholds) for each image, which is not practical for thousands of images.

    # Here’s a sample of what I tried:

    import cv2
    import numpy as np

    img = cv2.imread("earth_image.tif", cv2.IMREAD_GRAYSCALE)
    blurred = cv2.bilateralFilter(img, 9, 75, 75)
    edges = cv2.Canny(blurred, 50, 150)

    circles = cv2.HoughCircles(edges, cv2.HOUGH_GRADIENT, dp=1.2, minDist=100,
    param1=100, param2=60, minRadius=400, maxRadius=0)

    if circles is not None:
    circles = np.uint16(np.around(circles))
    for x, y, r in circles[0, :]:
    print(f"Center: ({x}, {y}), Radius: {r}")


    [​IMG]

    Continue reading...

Compartilhe esta Página