     1function [newImg,pre,imgSize,grid_size,v] = MLS(oldImg, type, alpha, p, q, v, imgSize, grid_size, pre)
     2%UNTITLED2 Summary of this function goes hereall(size(a) == [5,2])
     3%   oldImg = img to deform
     4%   type = 'Affine', 'Similarity', 'Rigid'
     5%   alpha = MLS parameter - pass 1
     6%   p = control point position
     7%   q = control point deformed position
     8%   PRECOMPUTED loopback
     9%   v = evaluation points (grid) - pass [stepX,stepY] if you want to
    10%       precompute or pass output of MLS_getPoints
    11%   imgSize = will get overwritten if you pass v as [stepX,stepY] or pass output of MLS_getPoints
    12%   grid_size
    13%   pre - output of MLS_precompute
    14
    15% crete evaluation grid if required
    16if all(size(v) == [1,2]) % [stepX,stepY]
    17   [v,imgSize,grid_size] = MLS_getPoints(oldImg,v(1),v(2));
    18end
    19% precompute if required
    20if all(size(pre)==1)
    21    pre = MLS_precompute(p,q,v,alpha,imgSize,type);
    22end
    23
    24% MLS deformation
    25[f,pre] = MLS_getDeform(p,q,v,alpha,type,pre,imgSize);
    26
    27% Interpolate img
    28newImg = MLS_applyDeform(oldImg,f,v,grid_size);
    29
    30end
    31