
// Script function: Set the pixel value in an image to zero if the value is negative.
// Requirement: At least open one 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 GlobalSinoImage
GetOneImage ("Select an image", GlobalSinoImage)

number EMxsize, EMysize, EMx, EMy
getsize(GlobalSinoImage, EMxsize, EMysize)
number EMvalue
for (EMy = 0; EMy < EMysize; EMy++) {
for (EMx = 0; EMx < EMxsize; EMx++) {
EMvalue = getPixel(GlobalSinoImage, EMx, EMy);
if (EMvalue < 0)
EMvalue = 0
else
EMvalue
setPixel(GlobalSinoImage, EMx, EMy, EMvalue)
}
}
 
SetName(GlobalSinoImage,"Negative values are set to 0")
ShowImage(GlobalSinoImage)
 