function cwt2 = CWT2(image, scale) 	
%  CWT2 -- 2D Continuous Wavelet Transformation
%  Usage
%    cwt2 = CWT2(image, scale) 
%  Inputs
%    image        2-d signal; length(x) = 2^J x 2^J
%    scale    level 0f 2-d section of a 3-D output
%  Output
%    cwt2     2-D section at level "scale".
%  Description
%    1. 2D Continous Wavelet Transformation Produces 3D object
%       with dimensions  scale, x-translation, y-translation. The output is 
%       2D object.
%  Example: > sticky = Make2DSignal('StickFigure', 256);
%            > imagesc(sticky)
%            > a = CWT2(sticky, 1.7);
%            > imagesc(a)
%
%  Uses: ndgrid, fft2, ifft2
      		   n = length(image);
                   xi = [ (0: (n/2)) (((-n/2)+1):-1) ]  ./n;
                                        omega1 = n .* xi ./ 2^scale;
					omega2 = n .* xi ./ 2^scale;
		   [o1,  o2] = ndgrid(omega1,omega2); 
		   window = 2 .* pi .* (o1.^2 + o2.^2) .* exp(-o1.^2 ./2) .* exp(-o2.^2 ./2);
                   window = window ./ 2^scale;
                   xhat = fft2(image);
	                 what = window .* xhat;
	           w = ifft2(what);
                   cwt2 = real(w);
%
% Copyright (c) 2002  Gatech Wavelet Group. (authors Heejong, Yoo and Vidakovic, B.)
%
