|
1
|
import numpy as np
|
|
2
|
import matplotlib.pyplot as plt
|
|
3
|
|
|
4
|
|
|
5
|
def generate_individual_graphs():
|
|
6
|
# Input gradient (0 to 1)
|
|
7
|
x = np.linspace(0, 1, 500)
|
|
8
|
|
|
9
|
# The three specified Gamma values
|
|
10
|
gamma_values = [0.5, 3, 50]
|
|
11
|
|
|
12
|
for gamma in gamma_values:
|
|
13
|
plt.figure(figsize=(8, 6))
|
|
14
|
|
|
15
|
# 1. Reference Line (Linear - No Correction)
|
|
16
|
# This is the 'Reference Curve'. It shows the output without blending/correction.
|
|
17
|
plt.plot(x, x, 'k--', label='Linear Reference (No Correction)', alpha=0.5)
|
|
18
|
|
|
19
|
# 2. Gamma Correction Curve
|
|
20
|
# Logic: y = x^(1/gamma)
|
|
21
|
y = np.power(x, 1.0 / gamma)
|
|
22
|
|
|
23
|
# Plotting the curve
|
|
24
|
plt.plot(x, y, color='blue', linewidth=3, label=f'Gamma Correction (γ={gamma})')
|
|
25
|
|
|
26
|
# Decoration
|
|
27
|
plt.title(f'Gamma Correction Curve: γ = {gamma}', fontsize=14)
|
|
28
|
plt.xlabel('Input Pixel Intensity (0 to 1)', fontsize=12)
|
|
29
|
plt.ylabel('Corrected Output Intensity', fontsize=12)
|
|
30
|
plt.legend(loc='best')
|
|
31
|
plt.grid(True, alpha=0.3)
|
|
32
|
plt.xlim(0, 1.0)
|
|
33
|
plt.ylim(0, 1.05)
|
|
34
|
|
|
35
|
# Saving separate files for each gamma
|
|
36
|
filename = f"gamma_curve_{gamma}.png"
|
|
37
|
plt.savefig(filename)
|
|
38
|
print(f"Generated graph: {filename}")
|
|
39
|
|
|
40
|
# Close plot to start fresh for next gamma
|
|
41
|
plt.close()
|
|
42
|
|
|
43
|
|
|
44
|
if __name__ == "__main__":
|
|
45
|
generate_individual_graphs()
|