Make generate_vignetting.py
ready
This commit is contained in:
parent
6a2b6386c9
commit
0f5b9dcdaf
@ -1,28 +1,35 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from tqdm import tqdm
|
||||
|
||||
A = -1.076923838846692e-06
|
||||
B = 0.0010539307456559996
|
||||
C = 31.8
|
||||
C = 42
|
||||
|
||||
SHAPE = (2_000, 3_000)
|
||||
SHAPE = (4_000, 6_000)
|
||||
CENTER = np.array(SHAPE) // 2
|
||||
|
||||
# `dtype` by default is `float64` as wanted.
|
||||
image = np.empty(SHAPE)
|
||||
|
||||
def getDistance(y, x):
|
||||
d = ((y - (SHAPE[0] / 2)) ** 2 + (x - (SHAPE[1] / 2)) ** 2) ** 0.5
|
||||
d = ((y - CENTER[0]) ** 2 + (x - CENTER[1]) ** 2) ** 0.5
|
||||
return d
|
||||
|
||||
def vignetting(y, x):
|
||||
d = getDistance(y, x)
|
||||
return A * (d ** 2) + B * (d ** 2) + C
|
||||
return A * (d ** 2) + B * d + C
|
||||
|
||||
for y in range(SHAPE[0]):
|
||||
for y in tqdm(range(SHAPE[0])):
|
||||
for x in range(SHAPE[1]):
|
||||
image[y, x] = vignetting(y, x)
|
||||
|
||||
print(image[np.array(SHAPE) / 2])
|
||||
plt.imshow(image)
|
||||
def checkOriginalPoint(point):
|
||||
print(f'distance = {getDistance(*point)} intensity = {image[tuple(point)]}')
|
||||
|
||||
for point in [CENTER, [0, 0], [CENTER[0], int(CENTER[1] + getDistance(0, 0) / 2)]]:
|
||||
checkOriginalPoint(point)
|
||||
|
||||
#plt.imshow(image, cmap = 'grey')
|
||||
plt.imsave('vignetting.png', image * 2.55, cmap = 'grey', vmin = 0, vmax = 255)
|
||||
plt.show()
|
Loading…
x
Reference in New Issue
Block a user