CLean remove_period_patterns.py
and add debugging as unable to find back process to get wanted result
This commit is contained in:
parent
0f5b9dcdaf
commit
81a994ed65
@ -10,7 +10,7 @@ sys.path.insert(0, '../')
|
||||
from utils import Color, mergeSingleColorChannelImagesAccordingToBayerFilter
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
PREFIX = 'mean_rafael_230424_mean_'
|
||||
PREFIX = 'means/mean_rafael_230424_mean_'
|
||||
X_STDDEV = 2
|
||||
|
||||
def getImageByColor(color):
|
||||
@ -45,23 +45,20 @@ def removePeriodicPatterns(fft1Part):
|
||||
kernel = Gaussian2DKernel(x_stddev = X_STDDEV)
|
||||
|
||||
# create a "fixed" image with NaNs replaced by interpolated values
|
||||
fixedImage = interpolate_replace_nans(fft1Part, kernel)
|
||||
return fixedImage
|
||||
fixedImagePart = interpolate_replace_nans(fft1Part, kernel)
|
||||
return fixedImagePart
|
||||
|
||||
'''
|
||||
# TODO: are `.copy()` really necessary?
|
||||
realFixedImage = removePeriodicPatterns(np.real(fft1).copy())
|
||||
imaginaryFixedImage = removePeriodicPatterns(np.imag(fft1).copy())
|
||||
fixedImage = realFixedImage + 1j * imaginaryFixedImage
|
||||
'''
|
||||
fixedImage = removePeriodicPatterns(abs(fft1))
|
||||
fixedImage = imaginaryFixedImage
|
||||
|
||||
figure, axes = plt.subplots(1, 2, sharex = True, sharey = True)
|
||||
|
||||
plt.suptitle('Attenuating FFT significant lines')
|
||||
axes[0].set_title('Original FFT')
|
||||
#originalFft1Abs = abs(originalFft1)
|
||||
#minValue = np.min()
|
||||
firstImage = np.log10(1 + abs(originalFft1))
|
||||
firstImage = np.log10(1 + abs(np.real(originalFft1)))
|
||||
secondImage = np.log10(1 + abs(fixedImage))
|
||||
images = [firstImage, secondImage]
|
||||
vMin = np.min(images)
|
||||
@ -71,20 +68,26 @@ axes[1].set_title('FFT with significant lines attenuated')
|
||||
axes[1].imshow(secondImage, vmin = vMin, vmax = vMax)
|
||||
plt.tight_layout()
|
||||
plt.show()
|
||||
#plt.imsave('fft.png', np.log10(1 + fixedImage))
|
||||
|
||||
figure, axes = plt.subplots(1, 2, sharex = True, sharey = True)
|
||||
figure, axes = plt.subplots(1, 3, 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
|
||||
|
||||
invOriginalFft1 = inverseFft(originalFft1)
|
||||
invFixedImage = inverseFft(fixedImage)
|
||||
images = [invOriginalFft1, invFixedImage]
|
||||
vMin = np.min(images)
|
||||
vMax = np.max(images)
|
||||
plt.suptitle('Rafael 23/04/24 PRNU mean denoiser with periodic patterns attenuated')
|
||||
axes[0].set_title('Original PRNU')
|
||||
invOriginalFft1 = inverseFft(originalFft1)
|
||||
axes[0].imshow(invOriginalFft1)
|
||||
axes[0].imshow(invOriginalFft1, vmin = vMin, vmax = vMax)
|
||||
axes[1].set_title('PRNU with periodic patterns attenuated')
|
||||
axes[1].imshow(inverseFft(fixedImage), vmin = invOriginalFft1.min(), vmax = invOriginalFft1.max())
|
||||
axes[1].imshow(invFixedImage, vmin = vMin, vmax = vMax)
|
||||
axes[2].set_title('Difference between both left images')
|
||||
differenceBetweenBothImages = invOriginalFft1 - invFixedImage
|
||||
# `np.log10(1 + abs(differenceBetweenBothImages))` does not seem more interesting.
|
||||
axes[2].imshow(differenceBetweenBothImages)
|
||||
plt.tight_layout()
|
||||
plt.show()
|
Loading…
x
Reference in New Issue
Block a user