remap of remap is not equal to remap
I have two successive remap calls and I'm trying to merge them:
for (int j = 0; j < h; j++)
for (int i = 0; i < w; i++) {
float x, y;
x = mapx2.at<float>(j, i);
y = mapy2.at<float>(j, i);
x = RANGE(x, 0, w - 1);
y = RANGE(y, 0, h - 1);
mapx1_2.at<float>(j, i) = mapx1.at<float>(y, x);
mapy1_2.at<float>(j, i) = mapy1.at<float>(y, x);
}
The overall result looks the same but details are different. Here is an example. The first extract with the two successive remaps shows a smooth line. The second extract with the single merged remap is not smooth.
I tried to cast x and y to int but with the same result.
I understand that "interpolation of interpolation" is not the same as a single merged interpolation. How could I fix the problem?
PS: I asked the question on Stackoverflow but here should be a better place to get an answer I think.