Comparing noises on images, are there clever distances? #5

Open
opened 2024-03-04 15:26:42 +01:00 by Benjamin_Loison · 1 comment
Owner

Other than L1 or L2? Even among both what distance is the most interesting one.

from PIL import Image
from collections import Counter
import matplotlib.pyplot as plt

def openImage(filePath):
    return Image.open(filePath).convert('L')

im1 = openImage('Wiener_Filtering-001.png')
im1Pixels = im1.load()

im2 = openImage('Wiener_Filtering-002.png')
im2Pixels = im2.load()

differences = []

for m in range(im1.size[0]):
    for n in range(im1.size[1]):
        difference = im1Pixels[m, n] - im2Pixels[m, n]
        differences += [difference]

differencesCounter = Counter(differences)
X = range(min(differencesCounter), max(differencesCounter) + 1)
Y = [differencesCounter.get(x, 0) for x in X]

# Shows a Gaussian centered in 0.
# How to deduce common parameter used to generate this Gaussian? Can verify with the source code in #10 or if the value looks like an integer.
plt.title('Number of occurrences per difference value')
plt.xlabel('Difference value')
plt.ylabel('Number of occurrences')
plt.plot(X, Y)
plt.show()

# Identical result as `rmsdiff`.
print((sum([(difference ** 2) * differencesCounter[difference] for difference in differencesCounter]) / (im1.size[0] * im1.size[1])) ** 0.5)

Figure_1

Related to #10.

Other than L1 or L2? Even among both what distance is the most interesting one. ```py from PIL import Image from collections import Counter import matplotlib.pyplot as plt def openImage(filePath): return Image.open(filePath).convert('L') im1 = openImage('Wiener_Filtering-001.png') im1Pixels = im1.load() im2 = openImage('Wiener_Filtering-002.png') im2Pixels = im2.load() differences = [] for m in range(im1.size[0]): for n in range(im1.size[1]): difference = im1Pixels[m, n] - im2Pixels[m, n] differences += [difference] differencesCounter = Counter(differences) X = range(min(differencesCounter), max(differencesCounter) + 1) Y = [differencesCounter.get(x, 0) for x in X] # Shows a Gaussian centered in 0. # How to deduce common parameter used to generate this Gaussian? Can verify with the source code in #10 or if the value looks like an integer. plt.title('Number of occurrences per difference value') plt.xlabel('Difference value') plt.ylabel('Number of occurrences') plt.plot(X, Y) plt.show() # Identical result as `rmsdiff`. print((sum([(difference ** 2) * differencesCounter[difference] for difference in differencesCounter]) / (im1.size[0] * im1.size[1])) ** 0.5) ``` ![Figure_1](/attachments/3b96fb18-8e1c-4388-a89d-453cb669c069) Related to #10.
Benjamin_Loison added the Context-Adaptive Interpolator label 2024-03-21 10:08:01 +01:00
Benjamin_Loison added the medium label 2024-03-26 02:17:31 +01:00
Author
Owner

If know the PRNU, then can just compute the correlation with the estimated one. Could be investigated in #25 for instance.

If know the PRNU, then can just compute the correlation with the estimated one. Could be investigated in #25 for instance.
Sign in to join this conversation.