1. Medical, Biophysical & Optical Overview
Human visual perception is fundamentally trichromatic, mediated by three distinct classes of retinal photoreceptor cone cells housed within the fovea centralis. Each cone class expresses a specific visual opsin photopigment coupled with an 11-cis-retinal chromophore: Long-wavelength sensitive (L-cones, erythrolabe, peak absorption $\lambda_{\max} \approx 560\text{ nm}$), Middle-wavelength sensitive (M-cones, chlorolabe, peak absorption $\lambda_{\max} \approx 530\text{ nm}$), and Short-wavelength sensitive (S-cones, cyanolabe, peak absorption $\lambda_{\max} \approx 420\text{ nm}$). Color vision deficiency (CVD) arises primarily from genetic mutations in the opsin gene array situated on the Xq28 (for L/M opsins) and 7q32 (for S opsin) chromosomal loci.
When a single cone class is completely absent or dysfunctional, the visual condition is classified as dichromacy. The three primary forms include Protanopia (complete absence of functional L-opsin, yielding loss of red sensitivity and steep luminosity darkening at long wavelengths), Deuteranopia (complete absence of functional M-opsin, causing severe green-red chromatic confusion along neutral isochromatic lines), and Tritanopia (absence of S-opsin, destroying short-wavelength discrimination and creating blue-yellow confusion). When opsin genes undergo unequal crossing over, hybrid photopigments are transcribed with shifted spectral sensitivity profiles ($\Delta \lambda_{\max}$), producing anomalous trichromacy (Protanomaly, Deuteranomaly, and Tritanomaly).
In rare congenital circumstances such as complete Achromatopsia (rod monochromacy), all three cone pathways are defective due to mutations in CNGA3, CNGB3, or GNAT2 cGMP-gated cation channel genes. Individuals navigate the visual world solely utilizing rhodopsin-driven rod photoreceptors, which saturate under photopic daylight, requiring high-density spectral sunglasses. Conversely, in theoretical Tetrachromacy, heterozygous females possessing four distinct cone opsin populations (typically L, M, S, and an anomalous mutant $L'$ or $M'$) obtain an extra dimension of post-receptoral chromatic processing ($4\text{D}$ color space), enabling discrimination among metamers that appear identical to normal trichromats.
3. Mathematical Transformation Architecture & Biophysical Modeling
Color vision simulation requires multi-stage linear and non-linear transformations converting linear sRGB coordinates to Hunt-Pointer-Estevez (HPE) or Stockman-Sharpe $LMS$ cone excitation space, executing projective dimension reduction, and transforming back to display sRGB.
Standard gamma-corrected input color coordinates $C_{\text{sRGB}} \in [0, 255]$ are first linearized to display tristimulus values $C_{\text{lin}} \in [0, 1]$ via inverse sRGB electro-optical transfer functions (EOTF):
$$C_{\text{lin}} = \begin{cases} \frac{C_{\text{sRGB}}}{12.92}, & \text{if } C_{\text{sRGB}} \le 0.04045 \\ \left(\frac{C_{\text{sRGB}} + 0.055}{1.055}\right)^{2.4}, & \text{if } C_{\text{sRGB}} > 0.04045 \end{cases}$$
Linear RGB vectors are mapped into physiological $LMS$ cone excitation space via the forward Stockman-Sharpe transformation matrix $M_{\text{RGB}\to\text{LMS}}$:
$$\begin{bmatrix} L \\ M \\ S \end{bmatrix} = \begin{bmatrix} 0.313990 & 0.639513 & 0.046497 \\ 0.155372 & 0.757894 & 0.086701 \\ 0.017752 & 0.109442 & 0.872570 \end{bmatrix} \begin{bmatrix} R_{\text{lin}} \\ G_{\text{lin}} \\ B_{\text{lin}} \end{bmatrix}$$
In dichromatic vision, the missing cone response is estimated as a planar projection along the missing axis toward the achromatic white point $(L_w, M_w, S_w)$. For instance, in Deuteranopia (loss of $M$-cone response), the projected $M'$ cone value is calculated using the Brettel-Viénot-Mollon algorithm:
$$M' = \frac{L \cdot S_w - S \cdot L_w + S \cdot M_E - L \cdot M_E}{S_w - L_w}$$
To support continuous severity scaling $\alpha \in [0, 1]$ and anomalous trichromatic spectral shifts, the unified Machado-Oliveira-Fernandes projection matrix $T_{\text{CVD}}(\alpha)$ is applied:
$$\begin{bmatrix} R' \\ G' \\ B' \end{bmatrix}_{\text{lin}} = \left( (1 - \alpha)\mathbf{I} + \alpha \, M_{\text{LMS}\to\text{RGB}} \, P_{\text{CVD}} \, M_{\text{RGB}\to\text{LMS}} \right) \begin{bmatrix} R \\ G \\ B \end{bmatrix}_{\text{lin}}$$
When Daltonization is engaged, the visual error vector $E = C_{\text{lin}} - C'_{\text{lin}}$ representing the discarded chromatic information is dynamically shifted into surviving color receptors via the Daltonization redistribution operator:
$$\begin{bmatrix} R_{\text{dalt}} \\ G_{\text{dalt}} \\ B_{\text{dalt}} \end{bmatrix} = \begin{bmatrix} R \\ G \\ B \end{bmatrix}_{\text{lin}} + \begin{bmatrix} 0 & 0 & 0 \\ 0.7 & 1.0 & 0 \\ 0.7 & 0 & 1.0 \end{bmatrix} \begin{bmatrix} E_R \\ E_G \\ E_B \end{bmatrix}$$
Finally, the corrected values are clamped to the unit interval $[0, 1]$ and re-encoded using the forward sRGB opto-electronic transfer function (OETF). Audio feedback utilizes the Web Audio API to synthesize microtonal frequency shifts ($f = 220 \cdot 2^{(H / 120)}$) proportional to dominant visual hues when interacting with specific regions of the canvas.