Add clipping
This commit is contained in:
parent
a17ec28cc3
commit
6f961a46cf
@ -30,12 +30,15 @@ def getPrnuShownAsSuch(size, gaussianNoise = 0):
|
||||
break
|
||||
# Center vertically, especially in the case `HEIGHT` > `WIDTH`.
|
||||
draw.text((0, HEIGHT // 2 - fontSize // 2), TEXT, 255, font = font)
|
||||
imageNpArray = np.array(imagePil)
|
||||
imageNpArray = np.array(imagePil, dtype = np.float64)
|
||||
#print(imageNpArray.dtype)
|
||||
#exit(1)
|
||||
gaussianNoiseNpArray = randomGaussianImage(gaussianNoise, size[::-1])
|
||||
#prnuShownAsSuch = imageNpArray + gaussianNoiseNpArray
|
||||
prnuShownAsSuch = imageNpArray
|
||||
for y in range(HEIGHT):
|
||||
for x in range(WIDTH):
|
||||
if prnuShownAsSuch[y, x] != 0:
|
||||
prnuShownAsSuch[y, x] += gaussianNoiseNpArray[y, x]
|
||||
#print(prnuShownAsSuch[y, x])
|
||||
prnuShownAsSuch[y, x] = gaussianNoiseNpArray[y, x]
|
||||
return prnuShownAsSuch
|
@ -74,14 +74,17 @@ for splitNXNIndex, splitNXN in enumerate(SPLIT_N_X_N_S):
|
||||
axis[0].set_title('First image without noise')
|
||||
axisImShow(axis[0], imageWithoutPrnuNpArrayTile)
|
||||
|
||||
axis[1].set_title('Actual Gaussian noised PRNU')
|
||||
axisImShow(axis[1], prnuNpArray)
|
||||
axis[1].set_title('First image Gaussian noise')
|
||||
axisImShow(axis[1], imageNoise)
|
||||
|
||||
axis[2].set_title('F. i. with G. n.')
|
||||
axisImShow(axis[2], imageWithoutPrnuNpArray + imageNoise)
|
||||
axis[2].set_title('First image with Gaussian noise')
|
||||
axisImShow(axis[2], np.clip(imageWithoutPrnuNpArray + imageNoise, 0, 255))
|
||||
|
||||
axis[3].set_title('F. i. with G. n. and PRNU')
|
||||
axisImShow(axis[3], imageWithoutPrnuNpArray + prnuNpArray + imageNoise)
|
||||
axis[3].set_title('Actual Gaussian noised PRNU')
|
||||
axisImShow(axis[3], prnuNpArray)
|
||||
|
||||
axes[1][0].set_title('First image with Gaussian noise and PRNU')
|
||||
axisImShow(axes[1][0], np.clip(imageWithoutPrnuNpArray + prnuNpArray + imageNoise, 0, 255))
|
||||
isFirstImage = False
|
||||
|
||||
#assert all([isIn256Range(extreme) for extreme in [imageWithPrnuNpArray.max(), imageWithPrnuNpArray.min()]]), 'Adding the PRNU resulted in out of 256 bounds image'
|
||||
@ -96,10 +99,8 @@ for splitNXNIndex, splitNXN in enumerate(SPLIT_N_X_N_S):
|
||||
rms = rmsDiffNumpy(cameraPrnuEstimateNpArray, prnuNpArray, True)
|
||||
title = f'RMS with actual PRNU: {rmsDiffNumpy(cameraPrnuEstimateNpArray, prnuNpArray):.4f}\n(normalized RMS: {rmsDiffNumpy(cameraPrnuEstimateNpArray, prnuNpArray, True):.4f})'
|
||||
axis = axes[1]
|
||||
axis[splitNXNIndex].set_title(f'Number of images: {len(imagesPrnuEstimateNpArray)}\n{title}')
|
||||
axis[splitNXNIndex].imshow(cameraPrnuEstimateNpArray)
|
||||
|
||||
axes[1][3].axis('off')
|
||||
axis[splitNXNIndex + 1].set_title(f'PRNU estimation\nwith {len(imagesPrnuEstimateNpArray)} images')#\n{title}
|
||||
axisImShow(axis[splitNXNIndex + 1], cameraPrnuEstimateNpArray)
|
||||
|
||||
plt.tight_layout()
|
||||
plt.show()
|
Loading…
x
Reference in New Issue
Block a user