Skip to content

Commit

Permalink
fixed potential colour science bug with D65
Browse files Browse the repository at this point in the history
  • Loading branch information
Russell Newman committed Aug 7, 2024
1 parent 603ce06 commit 72ba11c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Core/Maths/Color/Profile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,15 @@ public readonly Matrix3 CalculateCameraToXYZD50(Vector2? whiteXY = null)

public readonly Matrix3 CalculateCameraToXYZD65(Vector2? whiteXY = null)
{
Debug.Assert(asShotWhiteXY.HasValue);
Debug.Assert(whiteXY != null || asShotWhiteXY.HasValue);
if (!whiteXY.HasValue)
whiteXY = asShotWhiteXY.Value;

// If there are forward matrices use camera to xyz based approach (forward matrices)
var AsShotWhiteXYZ = Temperature.ChromaticityXYtoXYZ(asShotWhiteXY.Value);
var AsShotWhiteXYZ = Temperature.ChromaticityXYtoXYZ(whiteXY.Value);
if (hasForwardMatrix)
{
var ColourTemperature = Temperature.ChromaticityToColourTemperature(asShotWhiteXY.Value);
var ColourTemperature = Temperature.ChromaticityToColourTemperature(whiteXY.Value);
var CameraToXYZMatrix = CameraToXYZ(ColourTemperature);

// Calculate camera neutral
Expand All @@ -258,7 +258,7 @@ public readonly Matrix3 CalculateCameraToXYZD65(Vector2? whiteXY = null)
else
{
// Get color matrix (not forward)
var XYZToCameraMatrix = XYZToCamera(asShotWhiteXY.Value);
var XYZToCameraMatrix = XYZToCamera(whiteXY.Value);

// Create final camera to xyz50 matrix via D50 mapping
return Matrix.BradfordChromaticAdaptationD50toD65(Matrix3.Invert(XYZToCameraMatrix * Matrix.MapWhiteMatrix(Temperature.D50ChromaticityXYZ(), AsShotWhiteXYZ)));
Expand Down

0 comments on commit 72ba11c

Please sign in to comment.