% pad_2D pads a 2D array (in both direction). It's based on Matlab's padarray function % Inputs: % **img input image % **outsize size of final image % *optional:* % **padval value to fill padded regions % returns: % ++imout cropped image % Written by YJ function [ imout ] = pad_2D( img, outsize, padval) Nin = size(img); Nout = outsize(1:2); if Nout(1)