// Script function: Mask out the area except a disk or mask out the disk

// 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


image GlobalSinoImage
GetOneImage ("Select an image", GlobalSinoImage)
 
TagGroup GlobalSino, EMItems
GlobalSino = DLGCreateDialog( "Please confirm or enter your own numbers", EMItems )
 
TagGroup MyNumber1, MyNumber2, MyNumber3
 
EMItems.DLGAddElement( DLGCreateRealField( "X-coordinate of mask center :", MyNumber1, 100, 8, 3 ) )       
EMItems.DLGAddElement( DLGCreateRealField( "X-coordinate of mask center :", MyNumber2, 200, 8, 5 ) )       
EMItems.DLGAddElement( DLGCreateRealField( "Radius of my mask :", MyNumber3, 50, 17, 8 ) )       
 
if ( !Alloc( UIframe ).Init( GlobalSino ).Pose() ) exit (0)
 
number EMx = MyNumber1.DLGGetValue(), EMy = MyNumber2.DLGGetValue(), EMradius = MyNumber3.DLGGetValue()
image EMmasked
EMmasked = ((icol-EMx)/EMradius)**2+((irow-EMy)/EMradius)**2 < 1 ? GlobalSinoImage: 0 // <: mask out the area except a disk; >: mask out the disk
SetName( EMmasked, " Masked image from: " + GetName( GlobalSinoImage ))
ShowImage(EMmasked)
