Update demosaicing.cpp#18590
Conversation
|
fixes #18558 |
alalek
left a comment
There was a problem hiding this comment.
As a "bugfix" this patch should go into 3.4 branch first.
We will merge changes from 3.4 into master regularly (weekly/bi-weekly).
| 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; |
There was a problem hiding this comment.
To make all code consistent please fix these lines too:
- 1569
- 1571
Also need to check SIMDInterpolator implementation.
modules/imgproc/src/demosaicing.cpp
Outdated
| D[blue<<1] = (S[-sstep] + S[sstep] + 2) >> 1; | ||
| D[1] = S[0]; | ||
| D[2-(blue<<1)] = (S[-1] + S[1]) >> 1; | ||
| D[2-(blue<<1)] = (S[-1] + S[1] + 2) >> 1; |
There was a problem hiding this comment.
I did not get you as i am not totally familiar with the code base being a new contributor. Can you elaborate on what you mean by +1 ?
There was a problem hiding this comment.
You should follow the rounding rules. https://en.wikipedia.org/wiki/Rounding
>> 1 means * 0.5 (optimized version)
>> 2 means * 0.25 (optimized version)
You are switching from Rounding towards zero to Round half up.
In the second case you adding 0.5 <==> (x + 2) >> 2
In the first case you should add 0.5 too ==> (x + 1) >> 1
There was a problem hiding this comment.
oh ok thanks will make the required changes
|
so do i have to make further changes? or will the PR be merged to 3.4 after clearing all checks? |
fixes #18558
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.