@@ -899,24 +899,42 @@ void CV_ColorHLSTest::convert_row_abc2bgr_32f_c3( const float* src_row, float* d
899
899
}
900
900
}
901
901
902
-
903
- static const double RGB2XYZ[] =
904
- {
905
- 0.412453 , 0.357580 , 0.180423 ,
906
- 0.212671 , 0.715160 , 0.072169 ,
907
- 0.019334 , 0.119193 , 0.950227
902
+ // 0.412453, 0.357580, 0.180423,
903
+ // 0.212671, 0.715160, 0.072169,
904
+ // 0.019334, 0.119193, 0.950227
905
+ static const softdouble RGB2XYZ[] =
906
+ {
907
+ softdouble::fromRaw (0x3fda65a14488c60d ),
908
+ softdouble::fromRaw (0x3fd6e297396d0918 ),
909
+ softdouble::fromRaw (0x3fc71819d2391d58 ),
910
+ softdouble::fromRaw (0x3fcb38cda6e75ff6 ),
911
+ softdouble::fromRaw (0x3fe6e297396d0918 ),
912
+ softdouble::fromRaw (0x3fb279aae6c8f755 ),
913
+ softdouble::fromRaw (0x3f93cc4ac6cdaf4b ),
914
+ softdouble::fromRaw (0x3fbe836eb4e98138 ),
915
+ softdouble::fromRaw (0x3fee68427418d691 )
908
916
};
909
917
910
-
911
- static const double XYZ2RGB[] =
912
- {
913
- 3.240479 , -1.53715 , -0.498535 ,
914
- -0.969256 , 1.875991 , 0.041556 ,
915
- 0.055648 , -0.204043 , 1.057311
918
+ // 3.240479, -1.53715, -0.498535,
919
+ // -0.969256, 1.875991, 0.041556,
920
+ // 0.055648, -0.204043, 1.057311
921
+ static const softdouble XYZ2RGB[] =
922
+ {
923
+ softdouble::fromRaw (0x4009ec804102ff8f ),
924
+ softdouble::fromRaw (0xbff8982a9930be0e ),
925
+ softdouble::fromRaw (0xbfdfe7ff583a53b9 ),
926
+ softdouble::fromRaw (0xbfef042528ae74f3 ),
927
+ softdouble::fromRaw (0x3ffe040f23897204 ),
928
+ softdouble::fromRaw (0x3fa546d3f9e7b80b ),
929
+ softdouble::fromRaw (0x3fac7de5082cf52c ),
930
+ softdouble::fromRaw (0xbfca1e14bdfd2631 ),
931
+ softdouble::fromRaw (0x3ff0eabef06b3786 )
916
932
};
917
933
918
- static const float Xn = 0 .950456f ;
919
- static const float Zn = 1 .088754f ;
934
+ // 0.950456
935
+ static const softdouble Xn = softdouble::fromRaw(0x3fee6a22b3892ee8 );
936
+ // 1.088754
937
+ static const softdouble Zn = softdouble::fromRaw(0x3ff16b8950763a19 );
920
938
921
939
922
940
// // rgb <=> xyz
@@ -959,12 +977,13 @@ double CV_ColorXYZTest::get_success_error_level( int /*test_case_idx*/, int i, i
959
977
void CV_ColorXYZTest::convert_row_bgr2abc_32f_c3 ( const float * src_row, float * dst_row, int n )
960
978
{
961
979
int depth = test_mat[INPUT][0 ].depth ();
962
- double scale = depth == CV_8U ? 255 : depth == CV_16U ? 65535 : 1 ;
980
+ softdouble scale (depth == CV_8U ? 255 :
981
+ depth == CV_16U ? 65535 : 1 );
963
982
964
983
double M[9 ];
965
984
int j;
966
985
for ( j = 0 ; j < 9 ; j++ )
967
- M[j] = RGB2XYZ[j]*scale;
986
+ M[j] = ( double )( RGB2XYZ[j]*scale) ;
968
987
969
988
for ( j = 0 ; j < n*3 ; j += 3 )
970
989
{
@@ -984,12 +1003,13 @@ void CV_ColorXYZTest::convert_row_bgr2abc_32f_c3( const float* src_row, float* d
984
1003
void CV_ColorXYZTest::convert_row_abc2bgr_32f_c3 ( const float * src_row, float * dst_row, int n )
985
1004
{
986
1005
int depth = test_mat[INPUT][0 ].depth ();
987
- double scale = depth == CV_8U ? 1 ./255 : depth == CV_16U ? 1 ./65535 : 1 ;
1006
+ softdouble scale (depth == CV_8U ? 1 ./255 :
1007
+ depth == CV_16U ? 1 ./65535 : 1 );
988
1008
989
1009
double M[9 ];
990
1010
int j;
991
1011
for ( j = 0 ; j < 9 ; j++ )
992
- M[j] = XYZ2RGB[j]*scale;
1012
+ M[j] = ( double )( XYZ2RGB[j]*scale) ;
993
1013
994
1014
for ( j = 0 ; j < n*3 ; j += 3 )
995
1015
{
@@ -1082,6 +1102,7 @@ void CV_ColorLabTest::convert_row_bgr2abc_32f_c3(const float* src_row, float* ds
1082
1102
for (int j = 0 ; j < 9 ; j++ )
1083
1103
M[j] = (float )RGB2XYZ[j];
1084
1104
1105
+ float xn = (float )Xn, zn = (float )Zn;
1085
1106
for (int x = 0 ; x < n*3 ; x += 3 )
1086
1107
{
1087
1108
float R = src_row[x + 2 ];
@@ -1098,9 +1119,9 @@ void CV_ColorLabTest::convert_row_bgr2abc_32f_c3(const float* src_row, float* ds
1098
1119
B = applyGamma (B);
1099
1120
}
1100
1121
1101
- float X = (R * M[0 ] + G * M[1 ] + B * M[2 ]) / Xn ;
1122
+ float X = (R * M[0 ] + G * M[1 ] + B * M[2 ]) / xn ;
1102
1123
float Y = R * M[3 ] + G * M[4 ] + B * M[5 ];
1103
- float Z = (R * M[6 ] + G * M[7 ] + B * M[8 ]) / Zn ;
1124
+ float Z = (R * M[6 ] + G * M[7 ] + B * M[8 ]) / zn ;
1104
1125
1105
1126
float fX = X > lthresh ? cubeRoot (X) : (lowScale * X + f16of116);
1106
1127
float fY = Y > lthresh ? cubeRoot (Y) : (lowScale * Y + f16of116);
@@ -1136,6 +1157,7 @@ void CV_ColorLabTest::convert_row_abc2bgr_32f_c3( const float* src_row, float* d
1136
1157
// 903.3 = (29/3)^3
1137
1158
static const float yscale = 29 .f *29 .f *29 .f /27 .f ;
1138
1159
1160
+ float xn = (float )Xn, zn = (float )Zn;
1139
1161
for (int x = 0 , end = n * 3 ; x < end; x += 3 )
1140
1162
{
1141
1163
float L = src_row[x] * Lscale;
@@ -1165,8 +1187,8 @@ void CV_ColorLabTest::convert_row_abc2bgr_32f_c3( const float* src_row, float* d
1165
1187
else
1166
1188
FXZ[k] = FXZ[k] * FXZ[k] * FXZ[k];
1167
1189
}
1168
- float X = FXZ[0 ] * Xn ;
1169
- float Z = FXZ[1 ] * Zn ;
1190
+ float X = FXZ[0 ] * xn ;
1191
+ float Z = FXZ[1 ] * zn ;
1170
1192
1171
1193
float R = M[0 ] * X + M[1 ] * Y + M[2 ] * Z;
1172
1194
float G = M[3 ] * X + M[4 ] * Y + M[5 ] * Z;
@@ -1246,8 +1268,9 @@ void CV_ColorLuvTest::convert_row_bgr2abc_32f_c3( const float* src_row, float* d
1246
1268
1247
1269
float M[9 ];
1248
1270
// Yn == 1
1249
- float dd = Xn + 15 .f *1 .f + 3 .f *Zn;
1250
- float un = 4 .f *13 .f *Xn/dd;
1271
+ float xn = (float )Xn, zn = (float )Zn;
1272
+ float dd = xn + 15 .f *1 .f + 3 .f *zn;
1273
+ float un = 4 .f *13 .f *xn/dd;
1251
1274
float vn = 9 .f *13 .f /dd;
1252
1275
1253
1276
float u_scale = 1 .f , u_bias = 0 .f ;
@@ -1322,8 +1345,9 @@ void CV_ColorLuvTest::convert_row_abc2bgr_32f_c3( const float* src_row, float* d
1322
1345
int j;
1323
1346
float M[9 ];
1324
1347
// Yn == 1
1325
- float dd = Xn + 15 .f *1 .f + 3 .f *Zn;
1326
- float un = 4 *13 .f *Xn/dd;
1348
+ float xn = (float )Xn, zn = (float )Zn;
1349
+ float dd = xn + 15 .f *1 .f + 3 .f *zn;
1350
+ float un = 4 *13 .f *xn/dd;
1327
1351
float vn = 9 *13 .f *1 .f /dd;
1328
1352
1329
1353
float u_scale = 1 .f , u_bias = 0 .f ;
0 commit comments