2D Gaussian fitting in a box