
// Script function: Mask all pixel with intensity below the mean value in the image
// Requirement to run the script: Open an 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


image imgInitial, imgMask, ProducedImg

if ( !GetFrontImage( imgInitial ) )
 Throw( "No image loaded." )

imgMask := ( imgInitial < mean( imgInitial ) ) ? 1 : 0                

ProducedImg := imgMask ? imgInitial : 0

SetName( ProducedImg, " masked from '"  + GetName( imgInitial ) + "'")
ShowImage( ProducedImg ) 
