
// Script function: Create an specified image

// Unless named starting with GlobalSino, EM, My, Self, the function commands are defined 
//by Gatan DM, please see at link: http://www.globalsino.com/EM/page2597.html
 
TagGroup GlobalSinoDialog, EMItems

GlobalSinoDialog = DLGCreateDialog( "Create an specified image", EMItems )

EMItems.DLGAddElement( DLGCreateLabel( "Please define the width and height of the image" ) )       

TagGroup MyImageWidth, MyImageHeight

EMItems.DLGAddElement( DLGCreateRealField( "Image Width :", MyImageWidth, 300, 8, 3 ) )       
EMItems.DLGAddElement( DLGCreateRealField( "Image Height :", MyImageHeight, 500, 8, 5 ) )       

TagGroup MyOptions = DLGCreateRadioList( 0 ) // "0" is the default selection, i.e. an image with sine function is default as well.

// Here, the three "DLGAdd*" commands should be together in sequence.

MyOptions.DLGAddRadioItem( "Image with sine function", 0 ) 
MyOptions.DLGAddRadioItem( "Image with random noise", 1 ) 

EMItems.DLGAddElement( DLGCreateLabel( "\n" ) )       

EMItems.DLGAddElement( DLGCreateLabel( "Please select an image you want to create:        " ) )       

EMItems.DLGAddElement( MyOptions )    

if ( !Alloc( UIframe ).Init( GlobalSinoDialog ).Pose() ) exit (0)

number EMImageWidth, EMImageHeight, EMnumber 

EMImageWidth = MyImageWidth.DLGGetValue()
EMImageHeight = MyImageHeight.DLGGetValue()

EMnumber = MyOptions.DLGGetValue()

Image EMImage

if (EMnumber) // if EMnumber is equal to 1.
{
   EMImage := ExprSize(EMImageWidth,EMImageHeight,random() )
}
else 
{
  EMImage :=ExprSize(EMImageWidth,EMImageHeight,sin(0.3*icol)*sin(0.1*irow))                                              
}
 
showimage(EMImage)





