Closed‐form solution for the reconstruction problem in porous media