Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

Bug in warpAffine?

$
0
0
I think the following examples shows a bug in warpAffine: Mat x(1,20, CV_32FC1); for (int iCol(0); iCol(0, crop.cols-1) - crop.at(0, 0))/(crop.cols-1); Mat constGrad = crop.clone().setTo(0); for (int iCol(0); iCol1e-4) { cout << "Problem:" << endl; cout << "computed output: " << crop << endl; cout << "expected output: " << constGrad << endl; cout << "difference: " << diff << endl; Mat dxImg; Mat dxFilt(1, 2, CV_32FC1); dxFilt.at(0) = -1.0f; dxFilt.at(1) = 1.0f; filter2D(crop, dxImg, crop.depth(), dxFilt); cout << "x-derivative in computed output: " << dxImg(Rect(1,0,10,1)) << endl; cout << "Note: We expect a constant difference of 1.3" << endl; } Here is the program output: Problem: computed output: [3.5, 4.8125, 6.09375, 7.40625, 8.6875, 10, 11.3125, 12.59375, 13.90625, 15.1875, 16.5] expected output: [3.5, 4.8000002, 6.0999999, 7.4000001, 8.6999998, 10, 11.3, 12.6, 13.9, 15.2, 16.5] difference: [0, 0.012499809, -0.0062499046, 0.0062499046, -0.012499809, 0, 0.012499809, -0.0062503815, 0.0062503815, -0.012499809, 0] x-derivative in computed output: [1.3125, 1.28125, 1.3125, 1.28125, 1.3125, 1.3125, 1.28125, 1.3125, 1.28125, 1.3125] Note: We expect a constant difference of 1.3 I create an image with entries 0, 1, 2, ...n-1, and cut a region around (10,0) with scale 1.3. I also create an expected image constGrad. However, they are not the same. Even more, since the input image has a constant derivative in x-direction and the mapping is affine, I expect also a constant gradient in the resulting image. The problem is not a boundary stuff problem, the same happens at the inner of an image. It's also not related to WARP_INVERSE_MAP. Is this a known issue? any comments on this?

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>