

// Script function: Read, name and display the selected ROI, or create, name and display a rectangle ROI, including the entire image, if there is no ROI
// Requirement: Open an image (and draw a rectangle ROI)

// 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




number EMWidth, EMHeight
ROI GlobalSinoROI

image GlobalSinoImg := GetFrontImage()
imageDisplay EMDisplay = GlobalSinoImg.ImageGetImageDisplay(0)

number MyROICount = ImageDisplayCountROIs(EMDisplay);

// Create a ROI, including the entire image, if there is no ROI 
if (MyROICount == 0) {
GetSize(GlobalSinoImg,EMWidth,EMHeight)
GlobalSinoROI = CreateROI();
ROISetRectangle(GlobalSinoROI,0,0,EMHeight,EMWidth);
ImageDisplayAddROI(EMDisplay,GlobalSinoROI);
}
GlobalSinoROI = EMDisplay.ImageDisplayGetROI(0)
GlobalSinoROI.ROISetLabel("ROI")

ImageDisplay EMImageDisplay=GlobalSinoImg.ImageGetImageDisplay(0)
ROI EMROI=EMImageDisplay.ImageDisplayGetROI(0)
image EMROIImage=GlobalSinoImg[]
ShowImage(EMROIImage)