Add generate_vignetting.py

This commit is contained in:
Benjamin Loison 2024-05-22 21:36:25 +02:00
parent 92026d7134
commit 6a2b6386c9
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8

View File

@ -0,0 +1,28 @@
import numpy as np
import matplotlib.pyplot as plt
A = -1.076923838846692e-06
B = 0.0010539307456559996
C = 31.8
SHAPE = (2_000, 3_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
return d
def vignetting(y, x):
d = getDistance(y, x)
return A * (d ** 2) + B * (d ** 2) + C
for y in range(SHAPE[0]):
for x in range(SHAPE[1]):
image[y, x] = vignetting(y, x)
print(image[np.array(SHAPE) / 2])
plt.imshow(image)
plt.show()