[Python] Destripe satellite image using FFT in python

Discussão em 'Python' iniciado por Stack, Abril 22, 2025.

  1. Stack

    Stack Membro Participativo

    I am currently in the midst of processing a satellite image, and I've come to a point where I need to remove those faint stripes caused by the sensor, as you can see below:

    [​IMG]

    The image is RGB. I converted it to grayscale and performed FFT to visualise it in the frequency domain. These are the results:

    [​IMG]

    What I've come to realize, mainly from here, is that this cross created represents the stripes I want to remove. I don't know how to remove them though, any help would be appreciated.

    Claude.AI provided me with:

    import numpy as np
    import matplotlib.pyplot as plt
    from PIL import Image
    from scipy.fftpack import fft2, ifft2, fftshift, ifftshift

    # Load the image (replace with your image path)
    image_path = 'input.tiff'
    image = np.array(Image.open(image_path).convert('L'))

    # Apply FFT to transform to frequency domain
    f_transform = fft2(image)
    f_shift = fftshift(f_transform)

    # Create the notch filter
    rows, cols = image.shape
    crow, ccol = rows // 2, cols // 2 # center of the frequency domain

    # Create a mask for the filter - start with all ones (no filtering)
    mask = np.ones((rows, cols), dtype=np.float32)

    # Define the width of the vertical line to filter out
    line_width = 3 # Adjust this based on your image

    # Create a vertical band filter that removes the vertical line in the FFT
    # (which corresponds to horizontal stripes in the image)
    mask[:, ccol-line_width:ccol+line_width+1] = 0
    mask[crow-line_width:crow+line_width+1, :] = 0

    # Apply the filter
    f_shift_filtered = f_shift * mask

    # Inverse FFT to get back to the spatial domain
    f_ishift = ifftshift(f_shift_filtered)
    img_back = np.abs(ifft2(f_ishift))

    # Save the destriped image
    Image.fromarray(img_back.astype(np.uint8)).save('destriped_satellite_image.tiff')


    But it provides me with a result I don't get: [​IMG]

    Continue reading...

Compartilhe esta Página