Adding poisson noise to an image

后端 未结 5 620
忘了有多久
忘了有多久 2021-01-06 09:55

I have some images that I need to add incremental amounts of Poisson noise to in order to more thoroughly analyze them. I know you can do this in MATLAB, but how do you go a

5条回答
  •  孤城傲影
    2021-01-06 10:22

    From the item 1.4.4 - "Gaussian Approximation of the Poisson Distribution" of Chapter 1 of this book:

    For large mean values, the Poisson distribution is well approximated by a Gaussian distribution with mean and variance equal to the mean of the Poisson random variable:

    P(μ) ≈ N (μ,μ)

    Then, we can generate Poisson noise from a normal distribution N (0,1), scale its standard deviation by the square root of μ and add it to the image which is the μ value:

    # Image size
    M, N = 1000, 1000
    
    # Generate synthetic image
    image = np.tile(np.arange(0,N,dtype='float64'),(M,1)) * 20
    
    # -- sqrt(mu) * normal(0,1) --
    poisson_noise = np.sqrt(image) * np.random.normal(0, 1, image.shape)
    
    # Add the noise to the mu values
    noisy_image = image + poisson_noise
    
    plt.figure(figsize=(10,10))
    plt.subplot(2,2,1)
    plt.title('Image')
    plt.imshow(image,'gray')
    plt.subplot(2,2,2)
    plt.title('Noisy image noise')
    plt.imshow(noisy_image,'gray')  
    plt.subplot(2,2,3)
    plt.title('Image profile')
    plt.plot(image[0,:])
    plt.subplot(2,2,4)
    plt.title('Noisy image profile')
    plt.plot(noisy_image[0,:])
    
    print("Synthetic image mean: {}".format(image[:,1].mean()))
    print("Synthetic image variance: {}".format(image[:,1].var()))    
    print("Noisy image mean: {}".format(noisy_image[:,1].mean()))
    print("Noisy image variance: {}".format(noisy_image[:,1].var()))
    

    As Poisson noise is signal-dependent, as we increase the underlying signal the noise variance also increases, as we can see in this row profiles:

    image

    Output for statistics in a single column:

    Synthetic image mean: 20.0

    Synthetic image variance: 0.0

    Noisy image mean: 19.931120555821597

    Noisy image variance: 19.39456713877459

    Further references: [1][2]

提交回复
热议问题