// Script function: Particle analysis
// Requirement to run the script: Open a most-front image with particles


// 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 := GetFrontImage()
number EMx, EMy
getsize( GlobalSinoImage, EMx, EMy )
 
image GlobalSinoMask := BinaryImage( "Binary Mask", EMx, EMy )
Image EMParticlesImage := BinaryImage( "Extracted EM Particles", EMx, EMy )
   
GlobalSinoMask = GlobalSinoImage > 0.5*max(GlobalSinoImage) ? 1 : 0 
 
// Measurement strings: A measurement field for particle analysis
// Cannot have spaces in "".
 
string MyFields = "Area,FilledArea,CenterX,CenterY,ConvexArea,Eccentricity,Solidity"      // Specify analysis results


Number EMMinParticleSize = 18                     // Limit accepted
Number EMLabel = 0                              // Add labeled mask to inputImage (GlobalSinoImage) True/False


imageDocument EMResultsDoc = FindParticles(GlobalSinoImage, GlobalSinoMask, MyFields, EMMinParticleSize, EMLabel, EMParticlesImage)

ImageDocumentShow( EMResultsDoc )
 
Showimage( GlobalSinoMask )
ShowImage( EMParticlesImage )