Merge "Add API to ColorSpace to compute chromaticity coordinates from CCT"
This commit is contained in:
committed by
Android (Google) Code Review
commit
37fc6eaaf4
@@ -1778,6 +1778,36 @@ public abstract class ColorSpace {
|
||||
return mul3x3(inverse3x3(matrix), mul3x3Diag(LMS, matrix));
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Computes the chromaticity coordinates of a CIE series D illuminant
|
||||
* from the specified correlated color temperature (CCT). The specified CCT
|
||||
* must be greater than 0. A meaningful CCT range is [4000, 25000].</p>
|
||||
*
|
||||
* <p>The transform is computed using the methods referred to in Kang et
|
||||
* al., <i>Design of Advanced Color - Temperature Control System for HDTV
|
||||
* Applications</i>, Journal of Korean Physical Society 41, 865-871
|
||||
* (2002).</p>
|
||||
*
|
||||
* @param cct The correlated color temperature, in Kelvin
|
||||
* @return Corresponding XYZ values
|
||||
* @throws IllegalArgumentException If cct is invalid
|
||||
*/
|
||||
@NonNull
|
||||
@Size(3)
|
||||
public static float[] cctToIlluminantdXyz(@IntRange(from = 1) int cct) {
|
||||
if (cct < 1) {
|
||||
throw new IllegalArgumentException("Temperature must be greater than 0");
|
||||
}
|
||||
|
||||
final float icct = 1.0f / cct;
|
||||
final float icct2 = icct * icct;
|
||||
final float x = cct <= 7000.0f ?
|
||||
0.244063f + 0.09911e3f * icct + 2.9678e6f * icct2 - 4.6070e9f * icct2 * icct :
|
||||
0.237040f + 0.24748e3f * icct + 1.9018e6f * icct2 - 2.0064e9f * icct2 * icct;
|
||||
final float y = -3.0f * x * x + 2.87f * x - 0.275f;
|
||||
return xyYToXyz(new float[] {x, y});
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Computes the chromatic adaptation transform from the specified
|
||||
* source white point to the specified destination white point.</p>
|
||||
|
||||
Reference in New Issue
Block a user