/*--------------------------------------------------------------------------------------

Hit ctrl-enter to execute.

Description:

	This simple script generates a one dimensional and a two dimensional Gaussian, 
	and provides an example of overloaded functions in use; i.e. the methods
	have the same name, but are distinguished by their argument lits 

	Copyright © 2001 Gatan Inc.

----------------------------------------------------------------------------------------*/


/* 	This method creates a one dimensional Gaussian image of specified imagewidth, 
	peak position and width.  It is called with image width, peak position and Gaussian width
	arguments.  It returns a 1d image (strictly speaking, 2d but with a height of unity )*/

image MakeGaussian( number imageWidth, number position, number gaussianWidth )
{
	// Create a 4-byte image of the specified width, and reate a Gaussian form, 
	// making use of the icol intrinsic variable 
	image img := RealImage("1D Gaussian", 4, imageWidth, 1 )			
	img = exp(  -((icol-position)/gaussianWidth) ** 2 )	
	
	// Return the Gaussian image				
	return img 																													
}	


/* 	This method creates the two dimensional variant of the above.  Note the extra dimension size argument*/

image MakeGaussian( number imgWidth, number imgHeight, number position, number gaussianWidth )
{
	// Create a 4-byte image of the specified width and height, and create a 2dGaussian form, 
	// using the icol and irow intrinsic variables
	image img := RealImage("2D Gaussian", 4, imgWidth, imgHeight )		
	img = exp( -1 *( ((icol-position)/gaussianWidth) ** 2 +\
							((irow-position)/gaussianWidth) ** 2 ) )
	
	// Return the image			
	return img 															
}	


// Call the 2d MakeGaussian method, displaying the results 
// Likewise, call the 1d MakeGaussian method, displaying the results 
showimage( MakeGaussian( 512, 512, 256, 300 ) )					
showimage( MakeGaussian( 1024, 512, 300 ) )						