opencv / opencv

Open Source Computer Vision Library
https://opencv.org
Apache License 2.0
79.39k stars 55.86k forks source link

Unexpected numerical problem in cv::warpAffine #5819

Open hauke76 opened 8 years ago

hauke76 commented 8 years ago

Hi, we have encountered a small numerical problem in warpAffine which leads to intensity differences of up to 5 pixels, where 0 is expected (and almost everywhere visible).

Normally, I would not mention such an issue, since some problems/differences are to be expected but in this specific case, the error looks systematic.

The issue can be reproduced with OpenCV 3.0.0 (I think we use PPL for parallelization but I would need to double check) and the attached code below:

main.txt (the main.cpp for reproducing this issue)

Regards, Hauke

alalek commented 8 years ago

I believe reason is here : fixed point arithmetic is used. Also linear interpolation is not bit-exact (any value from range [low_intensity; high_intensity] is acceptable, in your case it is up to [0; 255]).

cc @vpisarev

hauke76 commented 8 years ago

I am aware of the fixed point arithmetic and I mentioned in the initial post that I know that I cannot expect bit-exact results. The example I attached compares a pixel shift in the source image vs. no pixel shift and I only posted the issue because the resulting 'imprecisions' looks too systematic and lead me to the assumption that there might be a bug hidden. The result is almost everywhere exact. Having that said, I do of course trust the implementers and maintainers, if they tell me otherwise. Thanks again for looking into the issue.