import numpy as np
import matplotlib.pyplot as plt


def generate_individual_graphs():
    # Input gradient (0 to 1)
    x = np.linspace(0, 1, 500)

    # The three specified Gamma values
    gamma_values = [0.5, 3, 50]

    for gamma in gamma_values:
        plt.figure(figsize=(8, 6))

        # 1. Reference Line (Linear - No Correction)
        # This is the 'Reference Curve'. It shows the output without blending/correction.
        plt.plot(x, x, 'k--', label='Linear Reference (No Correction)', alpha=0.5)

        # 2. Gamma Correction Curve
        # Logic: y = x^(1/gamma)
        y = np.power(x, 1.0 / gamma)

        # Plotting the curve
        plt.plot(x, y, color='blue', linewidth=3, label=f'Gamma Correction (γ={gamma})')

        # Decoration
        plt.title(f'Gamma Correction Curve: γ = {gamma}', fontsize=14)
        plt.xlabel('Input Pixel Intensity (0 to 1)', fontsize=12)
        plt.ylabel('Corrected Output Intensity', fontsize=12)
        plt.legend(loc='best')
        plt.grid(True, alpha=0.3)
        plt.xlim(0, 1.0)
        plt.ylim(0, 1.05)

        # Saving separate files for each gamma
        filename = f"gamma_curve_{gamma}.png"
        plt.savefig(filename)
        print(f"Generated graph: {filename}")

        # Close plot to start fresh for next gamma
        plt.close()


if __name__ == "__main__":
    generate_individual_graphs()