First PRNU distance test
This commit is contained in:
@@ -7,11 +7,14 @@ sys.path.insert(0, '../../algorithms/distance/')
|
||||
|
||||
from rmsdiff import rmsdiff
|
||||
|
||||
sys.path.insert(0, '../../algorithms/context_adaptive_interpolator/')
|
||||
|
||||
from context_adaptive_interpolator import contextAdaptiveInterpolator
|
||||
|
||||
IMAGE_SIZE = 64
|
||||
|
||||
def randomImage(scale):
|
||||
# Is `np.clip` necessary? See `toPilImage`.
|
||||
return np.random.normal(loc = 0, scale = scale, size = (IMAGE_SIZE, IMAGE_SIZE))
|
||||
return np.maximum(np.random.normal(loc = 0, scale = scale, size = (IMAGE_SIZE, IMAGE_SIZE)), 0)
|
||||
|
||||
prnu = randomImage(scale = 1)
|
||||
|
||||
@@ -19,12 +22,16 @@ images = [randomImage(scale = 10) + prnu for _ in range(10)]
|
||||
allImages = [prnu] + images
|
||||
|
||||
def toPilImage(npArray):
|
||||
nonNegativeArray = npArray - np.min(allImages)
|
||||
nonNegativeArray = np.round(255 * nonNegativeArray / np.max(allImages))
|
||||
return Image.fromarray(np.uint8(nonNegativeArray))
|
||||
npArray = np.round(255 * npArray / np.max(allImages))
|
||||
return Image.fromarray(np.uint8(npArray))
|
||||
|
||||
toPilImage(prnu).show()
|
||||
prnu = toPilImage(prnu)
|
||||
#prnu.show()
|
||||
|
||||
images = [toPilImage(image) for image in images]
|
||||
#images[0].show()
|
||||
|
||||
for image in images:
|
||||
print(rmsdiff(image, prnu))
|
||||
print(rmsdiff(contextAdaptiveInterpolator(image), prnu))
|
||||
initialRmsDiff = rmsdiff(image, prnu)
|
||||
caiRmsDiff = rmsdiff(contextAdaptiveInterpolator(image.load(), image), prnu)
|
||||
print(f'{initialRmsDiff=} {caiRmsDiff=}')
|
Reference in New Issue
Block a user