Rename rmsdiff
to rmsDiffPil
This commit is contained in:
parent
8b0b58953d
commit
7c7cbad0ef
@ -3,7 +3,7 @@ import math
|
||||
import operator
|
||||
import functools
|
||||
|
||||
def rmsdiff(im1, im2):
|
||||
def rmsDiffPil(im1, im2):
|
||||
"Calculate the root-mean-square difference between two images"
|
||||
|
||||
h = ImageChops.difference(im1, im2).histogram()
|
||||
@ -12,3 +12,4 @@ def rmsdiff(im1, im2):
|
||||
return math.sqrt(functools.reduce(operator.add,
|
||||
map(lambda h, i: h*(i**2), h, range(256))
|
||||
) / (float(im1.size[0]) * im1.size[1]))
|
||||
|
@ -5,7 +5,7 @@ import sys
|
||||
|
||||
sys.path.insert(0, '../../algorithms/distance/')
|
||||
|
||||
from rmsdiff import rmsdiff
|
||||
from rms_diff import rmsDiffPil
|
||||
|
||||
sys.path.insert(0, '../../algorithms/context_adaptive_interpolator/')
|
||||
|
||||
@ -56,7 +56,7 @@ axs[1].imshow(imagesWithPrnu[0][0])
|
||||
|
||||
imagesWithPrnuPil = [[toPilImage(imageWithPrnu) for imageWithPrnu in imagesWithPrnu[phoneIndex]] for phoneIndex in range(NUMBER_OF_PHONES)]
|
||||
#showImageWithMatplotlib(imagesWithPrnu[0][0])
|
||||
axs[2].set_title(f'First image with PRNU (RMS with image without PRNU: {rmsdiff(toPilImage(imagesWithPrnu[0][0]), toPilImage(imagesWithPrnu[0][0]))})')
|
||||
axs[2].set_title(f'First image with PRNU (RMS with image without PRNU: {rmsDiffPil(toPilImage(imagesWithPrnu[0][0]), toPilImage(imagesWithoutPrnu[0][0]))})')
|
||||
axs[2].imshow(imagesWithPrnu[0][0])
|
||||
|
||||
imagesWithPrnuPil0Mean = np.array(imagesWithPrnuPil[0]).mean(axis = 0)
|
||||
@ -77,7 +77,7 @@ def getPhoneIndexByNearestPrnu(estimatedPrnu):
|
||||
nearestPrnuRmsDiff = None
|
||||
nearestPrnuPhoneIndex = None
|
||||
for phoneIndex, prnu in enumerate(prnusPil):
|
||||
prnuRmsDiff = rmsdiff(estimatedPrnu, prnu)
|
||||
prnuRmsDiff = rmsDiffPil(estimatedPrnu, prnu)
|
||||
if nearestPrnuRmsDiff is None or prnuRmsDiff < nearestPrnuRmsDiff:
|
||||
nearestPrnuRmsDiff = prnuRmsDiff
|
||||
nearestPrnuPhoneIndex = phoneIndex
|
||||
@ -99,9 +99,9 @@ for phoneIndex in range(NUMBER_OF_PHONES):
|
||||
|
||||
phonePrnu = prnusPil[phoneIndex]
|
||||
|
||||
print('RMS diff with mean image =', rmsdiff(phoneImagesMean, phonePrnu))
|
||||
print('RMS diff with mean CAI images =', rmsdiff(caiImagesMean, phonePrnu))
|
||||
print('RMS diff with CAI images mean =', rmsdiff(caiOverPhoneImagesMean, phonePrnu))
|
||||
print('RMS diff with mean image =', rmsDiffPil(phoneImagesMean, phonePrnu))
|
||||
print('RMS diff with mean CAI images =', rmsDiffPil(caiImagesMean, phonePrnu))
|
||||
print('RMS diff with CAI images mean =', rmsDiffPil(caiOverPhoneImagesMean, phonePrnu))
|
||||
|
||||
guessedPhoneIndexByMeanImages = getPhoneIndexByNearestPrnu(phoneImagesMean)
|
||||
guessedPhoneIndexByMeanCAIImages = getPhoneIndexByNearestPrnu(caiImagesMean)
|
||||
|
Loading…
x
Reference in New Issue
Block a user