Check out example codes for "matlab resize image by scale". It will help you in understanding the concepts better.

Code Example 1

% MATLAB
% scale any input image by defined factors
img = imread('yourimg');

% your scaling factors [row col]
scale[2 2];

mxn = size(img);
% compute new image dimensions
pxq = max(floor(scale.*mxn(1:2)),1);

% compute p and q values via Nearest neighbor interpolation.
p = min(round(((1:pxq(1))-0.5)./scale(1)+0.5),mxn(1));
q = min(round(((1:pxq(2))-0.5)./scale(2)+0.5),mxn(2));

% retain dimension perspective with : as the third param
outImg = originalImg(p,q,:);

imshow(img)

Learn ReactJs, React Native from akashmittal.com