diff --git a/modules/imgproc/src/demosaicing.cpp b/modules/imgproc/src/demosaicing.cpp index e02104d222..03bc781046 100644 --- a/modules/imgproc/src/demosaicing.cpp +++ b/modules/imgproc/src/demosaicing.cpp @@ -1566,9 +1566,9 @@ public: int x = 1; if (start_with_green) { - D[blue<<1] = (S[-sstep] + S[sstep]) >> 1; + D[blue<<1] = (S[-sstep] + S[sstep] + 1) >> 1; D[1] = S[0]; - D[2-(blue<<1)] = (S[-1] + S[1]) >> 1; + D[2-(blue<<1)] = (S[-1] + S[1] + 1) >> 1; D += dcn; ++S; ++x; @@ -1584,7 +1584,7 @@ public: { D[0] = S[0]; D[1] = (std::abs(S[-1] - S[1]) > std::abs(S[sstep] - S[-sstep]) ? (S[sstep] + S[-sstep] + 1) : (S[-1] + S[1] + 1)) >> 1; - D[2] = (S[-sstep-1] + S[-sstep+1] + S[sstep-1] + S[sstep+1]) >> 2; + D[2] = (S[-sstep-1] + S[-sstep+1] + S[sstep-1] + S[sstep+1] + 2) >> 2; D[3] = (S[0] + S[2] + 1) >> 1; D[4] = S[1];