number  pi = 3.1415926, spacingX = 15, spacingY = 20	
 
number width, height								
GetNumber("Please enter image width:", 512, width)						
GetNumber("Please enter image height:", width, height)	

number SNR, xRays								
GetNumber("Please enter signal-to-noise ratio:", 1, SNR)
GetNumber("Please enter number of X-rays:", 0, xRays)

image crystal := RealImage("HRTEM image", 8, width, height)
			
crystal = 150*(1 + 1*( sin(2*pi*icol/SpacingX) \
							*sin(2*pi*irow/spacingY) + Random()/(SNR*2000))) 	
crystal += (Random() < xRays/(width*height)) ? 2000 : 0 

SetSurveyTechnique(crystal, 1)									
ShowImage(crystal)												
