Looking for a simple algorithm to scale/resize a matrix, or an image.

1.4k Views Asked by At

I am looking for a simple algorithm to scale a matrix of any size.

Given matrix A of dimensions [w1,h1].

Given a scaling factor (or resizing factor) SF, which is a real number (not necessarily integer).

I am looking for an algorithm to calculate the scaled (resized) matrix B.

The dimensions of matrix B will be [w1 x SF , h1 x SF], or to be more exact [round(w1 x SF) , round(h1 x SF)]

I heard that Bilinear interpolation is the best for this case, but I am not sure how easy it is to implement.

If possible, I will be happy to see the algorithm in a programming code (any language), or pseudo code.