Use v{min,max}
for enforcing matplotlib colormap
If it proceeds linearly to *covers the complete value range of the supplied data* then doing so is unnecessary and even if it is another not very different scale transformation then it is still fine for my goal.
This commit is contained in:
parent
5fa61f7ff8
commit
b375acbb3a
@ -5,10 +5,11 @@ from matplotlib import pyplot as plt
|
||||
def randomGaussianImage(scale, size):
|
||||
return np.random.normal(loc = 0, scale = scale, size = size)
|
||||
|
||||
def showImageWithMatplotlib(npArray, title = None):
|
||||
# `cmap` source: https://matplotlib.org/3.8.0/api/_as_gen/matplotlib.pyplot.imshow.html
|
||||
def showImageWithMatplotlib(npArray, title = None, cmap = 'viridis'):
|
||||
if title is not None:
|
||||
plt.title(title)
|
||||
plt.imshow(npArray)
|
||||
plt.imshow(npArray, cmap = cmap)
|
||||
plt.show()
|
||||
|
||||
def toPilImage(npArray):
|
||||
|
@ -62,5 +62,12 @@ for imageName in os.listdir(datasetPath):
|
||||
|
||||
cameraPrnuEstimateNpArray = np.array(imagesPrnuEstimateNpArray).mean(axis = 0)
|
||||
rms = rmsDiffNumpy(cameraPrnuEstimateNpArray, prnuNpArray, True)
|
||||
showImageWithMatplotlib(cameraPrnuEstimateNpArray, f'Camera PRNU estimate\nRMS with actual one: {rmsDiffNumpy(cameraPrnuEstimateNpArray, prnuNpArray):.4f} (normalized RMS: {rmsDiffNumpy(cameraPrnuEstimateNpArray, prnuNpArray, True):.4f})')
|
||||
title = f'Camera PRNU estimate\nRMS with actual one: {rmsDiffNumpy(cameraPrnuEstimateNpArray, prnuNpArray):.4f} (normalized RMS: {rmsDiffNumpy(cameraPrnuEstimateNpArray, prnuNpArray, True):.4f})'
|
||||
showImageWithMatplotlib(cameraPrnuEstimateNpArray, title)
|
||||
|
||||
_256RangeCameraPrnuEstimateNpArray = cameraPrnuEstimateNpArray - cameraPrnuEstimateNpArray.min()
|
||||
_256RangeCameraPrnuEstimateNpArray *= 255 / _256RangeCameraPrnuEstimateNpArray.max()
|
||||
|
||||
#showImageWithMatplotlib(_256RangeCameraPrnuEstimateNpArray, title, 'gray')
|
||||
plt.imshow(_256RangeCameraPrnuEstimateNpArray, cmap = 'gray', vmin = 0, vmax = 255)
|
||||
plt.show()
|
Loading…
x
Reference in New Issue
Block a user