diff --git a/doc/tutorials/imgproc/imgtrans/remap/remap.markdown b/doc/tutorials/imgproc/imgtrans/remap/remap.markdown index 21547b7311..e222bc7a36 100644 --- a/doc/tutorials/imgproc/imgtrans/remap/remap.markdown +++ b/doc/tutorials/imgproc/imgtrans/remap/remap.markdown @@ -38,7 +38,7 @@ Theory - Let's think in a quick example. Imagine that we have an image \f$I\f$ and, say, we want to do a remap such that: - \f[h(x,y) = (I.cols - x, y )\f] + \f[h(x,y) = (I.cols - 1 - x, y )\f] What would happen? It is easily seen that the image would flip in the \f$x\f$ direction. For instance, consider the input image: @@ -157,9 +157,9 @@ Explanation \f[h(i,j) = ( 2 \times i - src.cols/2 + 0.5, 2 \times j - src.rows/2 + 0.5)\f] for all pairs \f$(i,j)\f$ such that: \f$\dfrac{src.cols}{4}(i, j) = (float)j; - map_y.at(i, j) = (float)(map_x.rows - i); + map_y.at(i, j) = (float)(map_x.rows - 1 - i); break; case 2: - map_x.at(i, j) = (float)(map_x.cols - j); + map_x.at(i, j) = (float)(map_x.cols - 1 - j); map_y.at(i, j) = (float)i; break; case 3: - map_x.at(i, j) = (float)(map_x.cols - j); - map_y.at(i, j) = (float)(map_x.rows - i); + map_x.at(i, j) = (float)(map_x.cols - 1 - j); + map_y.at(i, j) = (float)(map_x.rows - 1 - i); break; default: break; diff --git a/samples/java/tutorial_code/ImgTrans/remap/RemapDemo.java b/samples/java/tutorial_code/ImgTrans/remap/RemapDemo.java index e36b232962..c215ad4788 100644 --- a/samples/java/tutorial_code/ImgTrans/remap/RemapDemo.java +++ b/samples/java/tutorial_code/ImgTrans/remap/RemapDemo.java @@ -33,15 +33,15 @@ class Remap { break; case 1: buffX[i*mapX.cols() + j] = j; - buffY[i*mapY.cols() + j] = mapY.rows() - i; + buffY[i*mapY.cols() + j] = mapY.rows() - 1 - i; break; case 2: - buffX[i*mapX.cols() + j] = mapY.cols() - j; + buffX[i*mapX.cols() + j] = mapX.cols() - 1 - j; buffY[i*mapY.cols() + j] = i; break; case 3: - buffX[i*mapX.cols() + j] = mapY.cols() - j; - buffY[i*mapY.cols() + j] = mapY.rows() - i; + buffX[i*mapX.cols() + j] = mapX.cols() - 1 - j; + buffY[i*mapY.cols() + j] = mapY.rows() - 1 - i; break; default: break; diff --git a/samples/python/tutorial_code/ImgTrans/remap/Remap_Demo.py b/samples/python/tutorial_code/ImgTrans/remap/Remap_Demo.py index f50aa36571..9ee5cc1f9c 100644 --- a/samples/python/tutorial_code/ImgTrans/remap/Remap_Demo.py +++ b/samples/python/tutorial_code/ImgTrans/remap/Remap_Demo.py @@ -18,17 +18,17 @@ def update_map(ind, map_x, map_y): for i in range(map_x.shape[0]): map_x[i,:] = [x for x in range(map_x.shape[1])] for j in range(map_y.shape[1]): - map_y[:,j] = [map_y.shape[0]-y for y in range(map_y.shape[0])] + map_y[:,j] = [map_y.shape[0]-1-y for y in range(map_y.shape[0])] elif ind == 2: for i in range(map_x.shape[0]): - map_x[i,:] = [map_x.shape[1]-x for x in range(map_x.shape[1])] + map_x[i,:] = [map_x.shape[1]-1-x for x in range(map_x.shape[1])] for j in range(map_y.shape[1]): map_y[:,j] = [y for y in range(map_y.shape[0])] elif ind == 3: for i in range(map_x.shape[0]): - map_x[i,:] = [map_x.shape[1]-x for x in range(map_x.shape[1])] + map_x[i,:] = [map_x.shape[1]-1-x for x in range(map_x.shape[1])] for j in range(map_y.shape[1]): - map_y[:,j] = [map_y.shape[0]-y for y in range(map_y.shape[0])] + map_y[:,j] = [map_y.shape[0]-1-y for y in range(map_y.shape[0])] ## [Update] parser = argparse.ArgumentParser(description='Code for Remapping tutorial.')