title: Matlab: conformal maps for image distortion with imwarp
body: <p>I am using imtransform to distort images with conformal maps as proposed in <a href="http://de.mathworks.com/help/images/examples/exploring-a-conformal-mapping.html" rel="nofollow noreferrer">exploring a conformal mapping</a>. It works fine but Matlab shows a warning that imtransform is not recommended and imwarp should be used instead but the transfer from imtransform to imwarp is difficult. Could someone transfer the distortion process with intransform [a] in a geometric transformation object for imwarp? </p>
  
  <p>[a] This transforms an RGB image C into T</p>
  
  <pre><code>conformal = maketform('custom', 2, 2, [], @conformalInverse, []);
  T = imtransform(C, conformal, 'bicubic', 'UData', uData,'VData', vData, 'XData', xData,'YData', yData, 'Size', [cm_out_h cm_out_w], 'FillValues', FillValue);
  </code></pre>
  
  <p>with the conformal map formula defined in conformalInverse.m like:</p>
  
  <pre><code>function U = conformalInverse(X, ~)
  %#codegen
  U = [zeros(size(X))];
  Z = complex(X(:,1),X(:,2));
  a = 2; W = (1./(4 * Z.^a - 1));
  U(:,2) = imag(W);
  U(:,1) = real(W);
  </code></pre>
  
  <p>and some parameter value examples like:</p>
  
  <pre><code>uData     = [ -1.25   1.25];  % Bounds for REAL(w)
  vData     = [  0.75  -0.75];  % Bounds for IMAG(w)
  xData     = [ -2.00   2.00];  % Bounds for REAL(z)
  yData     = [  2.00  -2.00];  % Bounds for IMAG(z)
  cm_out_h  = 3000;             % h of output image
  cm_out_w  = 3000;             % w of output image
  FillValue = 0;                % color definition to fill possible empty areas; here 0 == black 
  </code></pre>