Skip to content

Commit d3cf0d2

Browse files
dcouwenhmshabunin
authored andcommitted
Bayer VNG Demosaicing Fix #2 (Merge pull request opencv#15086)
* Update demosaicing.cpp Fixed calculation of Bs for non-green pixels. * Fixed cvtColor perf test for bayer VNG
1 parent 5ef7325 commit d3cf0d2

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

modules/imgproc/perf/perf_cvt_color.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ PERF_TEST_P(Size_CvtMode_Bayer, cvtColorBayer8u,
417417

418418
TEST_CYCLE() cvtColor(src, dst, mode, ch.dcn);
419419

420-
SANITY_CHECK(dst, 1);
420+
SANITY_CHECK_NOTHING();
421421
}
422422

423423
typedef tuple<Size, CvtMode2> Size_CvtMode2_t;

modules/imgproc/src/demosaicing.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -1153,14 +1153,14 @@ static void Bayer2RGB_VNG_8u( const Mat& srcmat, Mat& dstmat, int code )
11531153
{
11541154
Rs += srow[-bstep*2-2] + srow[0];
11551155
Gs += brow0[N6-1];
1156-
Bs += srow[-bstep+1]*2;
1156+
Bs += srow[-bstep-1]*2;
11571157
ng++;
11581158
}
11591159
if( gradSE < T )
11601160
{
11611161
Rs += srow[bstep*2+2] + srow[0];
11621162
Gs += brow2[N6+1];
1163-
Bs += srow[-bstep+1]*2;
1163+
Bs += srow[bstep+1]*2;
11641164
ng++;
11651165
}
11661166
R = srow[0];
@@ -1394,8 +1394,8 @@ static void Bayer2RGB_VNG_8u( const Mat& srcmat, Mat& dstmat, int code )
13941394
RGs = _mm_adds_epi16(RGs, _mm_and_si128(_mm_merge_epi16(t1, t0), mask));
13951395
// GRs += {brow2[N6+1]; (srow[1]+srow[bstep*2+1])} * (T>gradSE)
13961396
GRs = _mm_adds_epi16(GRs, _mm_and_si128(_mm_merge_epi16(_mm_loadu_si128((__m128i*)(brow2+N6+1)), _mm_adds_epi16(x7,x10)), mask));
1397-
// Bs += {srow[-bstep+1]*2; (srow[bstep+2]+srow[bstep])} * (T>gradSE)
1398-
Bs = _mm_adds_epi16(Bs, _mm_and_si128(_mm_merge_epi16(_mm_slli_epi16(x5, 1), _mm_adds_epi16(x8,x11)), mask));
1397+
// Bs += {srow[bstep+1]*2; (srow[bstep+2]+srow[bstep])} * (T>gradSE)
1398+
Bs = _mm_adds_epi16(Bs, _mm_and_si128(_mm_merge_epi16(_mm_slli_epi16(x9, 1), _mm_adds_epi16(x8,x11)), mask));
13991399

14001400
// gradS ***********************************************
14011401
mask = _mm_cmpgt_epi16(T, gradS); // mask = T>gradS
@@ -1451,7 +1451,7 @@ static void Bayer2RGB_VNG_8u( const Mat& srcmat, Mat& dstmat, int code )
14511451
// GRs += {brow0[N6-1]; (srow[-bstep*2-1]+srow[-1])} * (T>gradNW)
14521452
GRs = _mm_adds_epi16(GRs, _mm_and_si128(_mm_merge_epi16(_mm_loadu_si128((__m128i*)(brow0+N6-1)), _mm_adds_epi16(x2,x15)), mask));
14531453
// Bs += {srow[-bstep-1]*2; (srow[-bstep]+srow[-bstep-2])} * (T>gradNW)
1454-
Bs = _mm_adds_epi16(Bs, _mm_and_si128(_mm_merge_epi16(_mm_slli_epi16(x5, 1),_mm_adds_epi16(x3,x16)), mask));
1454+
Bs = _mm_adds_epi16(Bs, _mm_and_si128(_mm_merge_epi16(_mm_slli_epi16(x1, 1),_mm_adds_epi16(x3,x16)), mask));
14551455

14561456
__m128 ngf0 = _mm_div_ps(_0_5, _mm_cvtloepi16_ps(ng));
14571457
__m128 ngf1 = _mm_div_ps(_0_5, _mm_cvthiepi16_ps(ng));

0 commit comments

Comments
 (0)