title: Converting opencv remap code from c++ to python
body: <p>I am trying to convert c++ opencv cv2.remap code to python. I am not getting any error but result is not as expected.I am getting zoomed image</p>
  
  <p>c++ code</p>
  
  <pre><code>int main()
  {
      Mat img = imread("captcha1.jpg");
      float phase = -0.8 * CV_PI;
      float omega = 2.0 * CV_PI / img.cols;
      float amp = 15;
      Mat_&lt;Vec2f&gt; proj(img.size());
      for (int y=0; y&lt;img.rows; y++) {
          for (int x=0; x&lt;img.cols; x++) {
              float u = 0;
              float v = sin(phase + float(x) * omega) * amp;
              proj(y,x) = Vec2f(float(x) + u, float(y) + v);
          }
      }
      Mat corr;
      cv::remap(img, corr, proj, cv::Mat(), INTER_LINEAR);
      imshow("in",img);
      imshow("out",corr);
      waitKey();
  }
  </code></pre>
  
  <p>python code :</p>
  
  <pre><code>from __future__ import print_function
  import cv2
  import numpy as np
  from past.builtins import xrange
  def update():
     for j in xrange(rows):
          for i in xrange(cols):
  
              phase = -0.8 * np.pi
              omega = 2.0 * np.pi / cols
              amp = 15
              u = -100
              v = np.sin(phase + float(i) * omega) * amp
              value_xy = (float(i) + u) + (float(j) + v)
              map_x.itemset((j, i), value_xy)
              map_y.itemset((j, i), 0)
  
  img = cv2.imread('test.jpg')
  map_x = np.zeros(img.size, np.float32)
  map_y = np.zeros(img.shape[:2], np.float32)
  rows, cols = img.shape[:2]
  update()
  dst = cv2.remap(img, map_x, map_y, cv2.INTER_LINEAR)
  cv2.imshow('dst', dst)
  cv2.waitKey(0)
  cv2.destroyAllWindows()
  </code></pre>
  
  <p>Original image :</p>
  
  <p><a href="https://i.stack.imgur.com/BmBJH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BmBJH.jpg" alt="enter image description here"></a></p>
  
  <p>C++ Result :</p>
  
  <p><a href="https://i.stack.imgur.com/Xe0WX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Xe0WX.png" alt="enter image description here"></a></p>
  
  <p>Python result:</p>
  
  <p><a href="https://i.stack.imgur.com/HYTFx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HYTFx.png" alt="enter image description here"></a></p>