You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: polarsback.m
    path of file: ./repos/seamless_face_replacement/carving
    
    the code of the file until where you have to start completion: function arr = polarsback(polar_arr, rmin, rmax)
% LOGSAMPLE  Compute reverse of log-polar transform of image
%     ARRAY = polarsback(polar_arr, RMIN, RMAX) takes an array of samples
%     on a logarithmic grid and resamples to a conventional grid. 
% 
%     polar_arr is an NW x NR log-sampled array, as returned by LOGSAMPLE.
%     The value for ring R, wedge W is stored at LOGARRAY(W+1,R+1).

    
function arr = polarsback(polar_arr, rmin, rmax)
% LOGSAMPLE  Compute reverse of log-polar transform of image
%     ARRAY = polarsback(polar_arr, RMIN, RMAX) takes an array of samples
%     on a logarithmic grid and resamples to a conventional grid. 
% 
%     polar_arr is an NW x NR log-sampled array, as returned by LOGSAMPLE.
%     The value for ring R, wedge W is stored at LOGARRAY(W+1,R+1).
%         
%     RMIN and RMAX are the radii of the innermost and outermost rings of
%     the log-polar sampling pattern, in terms of pixels in the original
%     image. One of these may be the empty array; in this case it will be
%     calculated assuming that the "circular samples" condition (see below)
%     is satisfied.
%
%     ARR returns a conventional image centred on the log-sampled image.
%     The default of bilinear interpolation is used. 
%
% ----------------------
% 
% For reference, the formulae relating positions in the new image to
% positions in the log-polar array are as follows. R and W are ring and
% wedge numbers in the log-polar array and X and Y are column and row
% numbers in the original array, all treated as if they could take
% non-integer values.  For a sample at (X, Y):
% 
%     Radius of sample: P = RMIN * ( R / K )
% 
%         where         K = (NR - 1) / ( RMAX / RMIN )
%
%     Angle of sample:  T = W * 2 * PI / NW
% 
%     Column number:    X = P * cos(T)  +  XC
% 
%     Row number:       Y = P * sin(T)  +  YC
%
% where XC = YC = ceil(RMAX)+1.
%
% The "circular samples" condition is
%
%                       RMAX = RMIN * exp( 2*pi*(NR-1)/NW )
%
% If this is satisfied, the spatial separation of neighbouring pixels in
% the log-polar array is approximately the same along the wedges and round
% the rings.
%
% See also LOGSAMPLE, LOGTFORM

% Copyright David Young 2010
% Edited by Dongni Wang 2016

[nw, nr, ~] = size(polar_arr);
t = fliptform(logtform(rmin, rmax, nr, nw));
xc = ceil(t.tdata.rmax) + 1;
X = 2*xc-1;
Xdata = [1, X] - xc;
Udata = [0, nr-1];
% polar_arr = padarray(polar_arr, [1 0], 'circular');  %wraps round in theta
Vdata = [-1, nw];       % [0 nw-1] before padding
Size = [X, X];
arr = imtransform(polar_arr, t, ...
    'Udata', Udata, 'Vdata', Vdata, ...
    'Xdata', Xdata, 'Ydata', Xdata, 'Size', Size);

end