Add an use toPilImage
This commit is contained in:
parent
674025fa62
commit
c287d5f0ef
@ -1,5 +1,6 @@
|
||||
import numpy as np
|
||||
from matplotlib import pyplot as plt
|
||||
from PIL import Image
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, '../../algorithms/distance/')
|
||||
@ -9,16 +10,20 @@ from rmsdiff import rmsdiff
|
||||
IMAGE_SIZE = 64
|
||||
|
||||
def randomImage(scale):
|
||||
# Is `np.clip` necessary?
|
||||
return np.round(np.random.normal(loc = 0, scale = scale, size = (IMAGE_SIZE, IMAGE_SIZE)))
|
||||
# Is `np.clip` necessary? See `toPilImage`.
|
||||
return np.random.normal(loc = 0, scale = scale, size = (IMAGE_SIZE, IMAGE_SIZE))
|
||||
|
||||
prnu = randomImage(scale = 1)
|
||||
|
||||
plt.imshow(prnu)
|
||||
plt.show()
|
||||
|
||||
images = [randomImage(scale = 10) + prnu for _ in range(10)]
|
||||
|
||||
def toPilImage(npArray):
|
||||
nonNegativeArray = npArray - np.min(npArray)
|
||||
nonNegativeArray = np.round(255 * nonNegativeArray / np.max(nonNegativeArray))
|
||||
return Image.fromarray(np.uint8(nonNegativeArray))
|
||||
|
||||
toPilImage(prnu).show()
|
||||
|
||||
for image in images:
|
||||
print(rmsdiff(image, prnu))
|
||||
print(rmsdiff(contextAdaptiveInterpolator(image), prnu))
|
Loading…
x
Reference in New Issue
Block a user