Update remove_period_patterns.py

This commit is contained in:
Benjamin Loison 2024-05-14 11:40:56 +02:00
parent 337a6eca84
commit 7dcd1f3331
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8

View File

@ -22,8 +22,9 @@ singleColorChannelImages = {color: getImageByColor(color) for color in Color}
multipleColorsImage = mergeSingleColorChannelImagesAccordingToBayerFilter(singleColorChannelImages)
image = multipleColorsImage
fft1 = abs(fftpack.fft2(image))
fft1 = fftpack.fftshift(fftpack.fft2(image))
originalFft1 = fft1.copy()
fft1 = abs(fft1)
# This example is intended to demonstrate how astropy.convolve and
# scipy.convolve handle missing data, so we start by setting the brightest
@ -47,9 +48,26 @@ fixedImage = interpolate_replace_nans(fft1, kernel)
figure, axes = plt.subplots(1, 2, sharex = True, sharey = True)
plt.suptitle('Attenuating FFT significant lines')
axes[0].set_title('Original FFT')
axes[0].imshow(np.log10(originalFft1))
axes[0].imshow(np.log10(abs(originalFft1)))
axes[1].set_title('FFT with significant lines attenuated')
axes[1].imshow(np.log10(fixedImage))
plt.tight_layout()
plt.show()
#plt.imsave('fft.png', np.log10(fixedImage))
#plt.imsave('fft.png', np.log10(fixedImage))
figure, axes = plt.subplots(1, 2, sharex = True, sharey = True)
def inverseFft(fft):
ifft2 = np.real(fftpack.ifft2(fftpack.ifftshift(fft)))
#ifft2 = np.maximum(0, np.minimum(ifft2, 255)) #* 255# / 255
return ifft2
plt.suptitle('Rafael 23/04/24 PRNU mean denoiser with periodic patterns attenuated')
axes[0].set_title('Original PRNU')
axes[0].imshow(inverseFft(originalFft1))
axes[1].set_title('PRNU with periodic patterns attenuated')
axes[0].imshow(inverseFft(fixedImage))
plt.tight_layout()
plt.show()