Skip to content

Commit 822d33d

Browse files
committed
Merge pull request opencv#9374 from savuor:test_lab_bit_exact
2 parents 31348f8 + 18ca3d1 commit 822d33d

File tree

3 files changed

+579
-99
lines changed

3 files changed

+579
-99
lines changed

modules/imgproc/src/color.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6771,7 +6771,10 @@ struct Lab2RGBinteger
67716771

67726772
//float fxz[] = { ai / 500.0f + fy, fy - bi / 200.0f };
67736773
int adiv, bdiv;
6774-
adiv = aa*BASE/500 - 128*BASE/500, bdiv = bb*BASE/200 - 128*BASE/200;
6774+
//adiv = aa*BASE/500 - 128*BASE/500, bdiv = bb*BASE/200 - 128*BASE/200;
6775+
//approximations with reasonable precision
6776+
adiv = ((5*aa*53687 + (1 << 7)) >> 13) - 128*BASE/500;
6777+
bdiv = (( bb*41943 + (1 << 4)) >> 9) - 128*BASE/200+1;
67756778

67766779
int ifxz[] = {ify + adiv, ify - bdiv};
67776780

@@ -7104,8 +7107,6 @@ struct Lab2RGB_b
71047107
const float* _whitept, bool _srgb )
71057108
: fcvt(3, _blueIdx, _coeffs, _whitept, _srgb ), icvt(_dstcn, _blueIdx, _coeffs, _whitept, _srgb), dstcn(_dstcn)
71067109
{
7107-
useBitExactness = (!_coeffs && !_whitept && _srgb && enableBitExactness);
7108-
71097110
#if CV_NEON
71107111
v_scale_inv = vdupq_n_f32(100.f/255.f);
71117112
v_scale = vdupq_n_f32(255.f);
@@ -7162,7 +7163,7 @@ struct Lab2RGB_b
71627163

71637164
void operator()(const uchar* src, uchar* dst, int n) const
71647165
{
7165-
if(useBitExactness)
7166+
if(enableBitExactness)
71667167
{
71677168
icvt(src, dst, n);
71687169
return;
@@ -7328,7 +7329,6 @@ struct Lab2RGB_b
73287329
__m128i v_zero;
73297330
bool haveSIMD;
73307331
#endif
7331-
bool useBitExactness;
73327332
int dstcn;
73337333
};
73347334

0 commit comments

Comments
 (0)