Add RMS computation
This commit is contained in:
parent
f297060f42
commit
3ccec5bbd0
@ -5,7 +5,9 @@ from matplotlib import pyplot as plt
|
||||
def randomGaussianImage(scale, size):
|
||||
return np.random.normal(loc = 0, scale = scale, size = size)
|
||||
|
||||
def showImageWithMatplotlib(npArray):
|
||||
def showImageWithMatplotlib(npArray, title = None):
|
||||
if title is not None:
|
||||
plt.title(title)
|
||||
plt.imshow(npArray)
|
||||
plt.show()
|
||||
|
||||
|
@ -14,6 +14,10 @@ sys.path.insert(0, '../../algorithms/context_adaptive_interpolator/')
|
||||
|
||||
from context_adaptive_interpolator import contextAdaptiveInterpolator
|
||||
|
||||
sys.path.insert(0, '../../algorithms/distance/')
|
||||
|
||||
from rms_diff import rmsDiffNumpy
|
||||
|
||||
from skimage.restoration import denoise_tv_chambolle
|
||||
|
||||
datasetPath = 'no_noise_images'
|
||||
@ -25,7 +29,7 @@ IMAGE_SIZE_SHAPE = (469, 704)
|
||||
np.random.seed(0)
|
||||
|
||||
#prnuNpArray = 255 * randomGaussianImage(scale = PRNU_FACTOR, size = IMAGE_SIZE_SHAPE)
|
||||
prnuPil = Image.open('prnu_4x4.png').convert('F')
|
||||
prnuPil = Image.open('prnu.png').convert('F')
|
||||
prnuNpArray = np.array(prnuPil) * PRNU_FACTOR
|
||||
|
||||
def isIn256Range(x):
|
||||
@ -39,8 +43,8 @@ for imageName in os.listdir(datasetPath):
|
||||
imageWithoutPrnuPil = Image.open(imagePath).convert('F')
|
||||
imageWithoutPrnuNpArray = np.array(imageWithoutPrnuPil)
|
||||
|
||||
m = imageWithoutPrnuNpArray.shape[0] // 4
|
||||
n = imageWithoutPrnuNpArray.shape[1] // 4
|
||||
m = imageWithoutPrnuNpArray.shape[0] // 1
|
||||
n = imageWithoutPrnuNpArray.shape[1] // 1
|
||||
|
||||
imageWithoutPrnuNpArrayTiles = [imageWithoutPrnuNpArray[x : x + m, y : y + n] for x in range(0, imageWithoutPrnuNpArray.shape[0], m) for y in range(0, imageWithoutPrnuNpArray.shape[1], n)]
|
||||
for imageWithoutPrnuNpArrayTile in imageWithoutPrnuNpArrayTiles:
|
||||
@ -53,5 +57,7 @@ for imageName in os.listdir(datasetPath):
|
||||
|
||||
imagesPrnuEstimateNpArray += [imagePrnuEstimateNpArray]
|
||||
|
||||
showImageWithMatplotlib(np.array(imagesPrnuEstimateNpArray).mean(axis = 0))
|
||||
cameraPrnuEstimateNpArray = np.array(imagesPrnuEstimateNpArray).mean(axis = 0)
|
||||
rms = rmsDiffNumpy(cameraPrnuEstimateNpArray, prnuNpArray)
|
||||
showImageWithMatplotlib(cameraPrnuEstimateNpArray, f'Camera PRNU estimate\nRMS with actual one: {rms:.4f}')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user