# Bilinear Interpolation Algorithm for up-sampling 2D images

In keras it is possible to use UpSampling2D layer to up-sample an image. You can use Bilinear Interpolation.

Given an image $${h\times w}$$ it is possible to increase its size in $${h*k\times w*l}$$, where $$k$$ and $$l$$ are factors greater than or equal to $$1$$.

I understand the Bilinear Interpolation formula applied to $$4$$ neighbouring pixels ($${2\times 2}$$ sub-matrix). But I just can't figure out how to apply it to perform up-sampling. What is the actual algorithm being implemented? How is Bilinear Interpolation mathematically defined for up-sampling 2D images?

Nowhere have I found the real algorithm, no one explains how to construct the new matrix correctly and consistently. It is always explained in an incomprehensible way, please help me.