function n = nlevels(x, y, WIDTH)
% computes number of gaussian pyramid levels we need for problem 2 d

sx = x/WIDTH; sy = y/WIDTH;

e = atan(0.5*sqrt(sx^2+sy^2));
a = 0.23 * e*(180/pi) + 1.4; % 0.7?
dview = sqrt(sx^2 + sy^2 + 4);
%WIDTH * dview * tan (a/60 * pi/180)
n = log2(WIDTH * dview * tan (a/60 * pi/180));
