@@ -92,6 +92,45 @@ function XYZ_to_lin_P3(XYZ) {
9292 return math . multiply ( M , XYZ ) . valueOf ( ) ;
9393}
9494
95+ // ProPhotoRGB functions
96+
97+ function lin_ProPhoto ( RGB ) {
98+ // convert an array of ProPhotoRGB values in the range 0.0 - 1.0
99+ // to linear light (un-companded) form.
100+ return RGB . map ( function ( val ) {
101+ return Math . pow ( val , 1.8 ) ;
102+ } ) ;
103+ }
104+
105+ function gam_ProPhoto ( RGB ) {
106+ // convert an array of linear-light ProPhotoRGB in the range 0.0-1.0
107+ // to gamma corrected form
108+ return RGB . map ( function ( val ) {
109+ return Math . pow ( val , 1 / 1.8 ) ;
110+ } ) ;
111+ }
112+
113+ function lin_ProPhoto_to_XYZ ( rgb ) {
114+ // convert an array of linear-light ProPhotoRGB values to CIE XYZ
115+ // using D50 (so no chromatic adaptation needed afterwards)
116+ // http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
117+ var M = Math . matrix ( [
118+ [ 0.7977604896723027 , 0.13518583717574031 , 0.0313493495815248 ] ,
119+ [ 0.2880711282292934 , 0.7118432178101014 , 0.00008565396060525902 ] ,
120+ [ 0.0 , 0.0 , 0.8251046025104601 ]
121+ ] ) ;
122+
123+ return Math . multiply ( M , rgb ) . valueOf ( ) ;
124+ }
125+
126+ function XYZ_to_lin_ProPhoto ( XYZ ) {
127+ // convert XYZ to linear-light ProPhotoRGB
128+ var M = Math . matrix ( [
129+ [ 1.3457989731028281 , - 0.25558010007997534 , - 0.05110628506753401 ] ,
130+ [ - 0.5446224939028347 , 1.5082327413132781 , 0.02053603239147973 ] ,
131+ [ 0.0 , 0.0 , 1.2119675456389454 ]
132+
133+
95134//Rec. 2020-related functions
96135
97136function lin_2020 ( RGB ) {
0 commit comments