// Script function: Sum the mirrored ROIs (in four different images) with the same size and position of a pre-defined ROI in an image of the four

// Requirement: Open four images

 

// 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 GlobalSinoImage0

 

if ( !GetFrontImage( GlobalSinoImage0 ) )

Throw( "Please open an image and draw a rectangle ROI" )


GlobalSinoImage0:=getfrontimage()

 

ImageDisplay EMImage=GlobalSinoImage0.ImageGetImageDisplay(0)

 

if( 1 !=  EMImage.ImageDisplayCountROIs())

Throw( "Please draw a rectangle ROI" )

 

number EMxSize, EMySize, EMxScale, EMyScale

string EMImageName


GetSize(GlobalSinoImage0, EMxSize, EMySize)

GetScale(GlobalSinoImage0, EMxScale, EMyScale)

GetName(GlobalSinoImage0, EMImageName)


number EMTop, EMLeft, EMBottom, EMRight

number EMROIUnitWidth, EMROIUnitHeight


ImageDisplay EMImageDisplay=GlobalSinoImage0.ImageGetImageDisplay(0)

ROI EMROI=EMImageDisplay.ImageDisplayGetROI(0)

ROIGetRectangle(EMROI, EMTop, EMLeft, EMBottom, EMRight)

 

EMImageDisplay.ImageDisplayDeleteROI( EMROI )

 

// =====

number GlobalSinoImage = CountImageDocuments()

imageDocument ForEMImageAA = GetImageDocument( GlobalSinoImage-1 )

image EMImageAA := ImageDocumentGetImage( ForEMImageAA, 0 )

 


imageDocument ForEMImageBB = GetImageDocument( GlobalSinoImage-2 )

image EMImageBB := ImageDocumentGetImage( ForEMImageBB, 0 )

 

imageDocument ForEMImageCC = GetImageDocument( GlobalSinoImage-3 )

image EMImageCC := ImageDocumentGetImage( ForEMImageCC, 0 )

 

imageDocument ForEMImageDD = GetImageDocument( GlobalSinoImage-4 )

image EMImageDD := ImageDocumentGetImage( ForEMImageDD, 0 )

 

 

ROI MyROI = NewROI();

 

ROISetRectangle(MyROI,EMTop, EMLeft, EMBottom, EMRight)

 

MyROI.ROISetVolatile( 1 ) // 0 is for Annotation, 1 is for ROI

if ( TwoButtonDialog( "Add Mirror ROI?", "Mirror ROI", "Cancel" ) )

{

EMImageAA.ImageGetImageDisplay(0).ImageDisplayAddROI( MyROI )

EMImageBB.ImageGetImageDisplay(0).ImageDisplayAddROI( MyROI )

EMImageCC.ImageGetImageDisplay(0).ImageDisplayAddROI( MyROI ) 

 EMImageDD.ImageGetImageDisplay(0).ImageDisplayAddROI( MyROI ) 

 

// The Mirror ROIs can be moved simultaneously

}

 

else

{

Exit(0)

}

 

 

 

result ( "\n" + "\n")

 

// ===

number EMxScaleAA, EMyScaleAA //

GetScale(EMImageAA, EMxScaleAA, EMyScaleAA)

ImageDisplay EMImageDisplayAA=EMImageAA.ImageGetImageDisplay(0)

ROI EMROIAA=EMImageDisplayAA.ImageDisplayGetROI(0)

image EMROIImageAA=EMImageAA[]

 

// ==

// For setting the name:

 

string EMImageNameAA

GetName(EMImageAA, EMImageNameAA)

ImageDisplay EMROIDisplayAA=EMImageAA.ImageGetImageDisplay(0)

EMROIDisplayAA.ApplyDataBar()

string EMImageAAName=EMImageNameAA

SetName(EMImageAA, EMImageAAName)

 

 

// ==

 

// ===

number EMxScaleBB, EMyScaleBB //

GetScale(EMImageBB, EMxScaleBB, EMyScaleBB)

ImageDisplay EMImageDisplayBB=EMImageBB.ImageGetImageDisplay(0)

ROI EMROIBB=EMImageDisplayBB.ImageDisplayGetROI(0)

image EMROIImageBB=EMImageBB[]

 

// ==

// For setting the name:

 

string EMImageNameBB

GetName(EMImageBB, EMImageNameBB)

ImageDisplay EMROIDisplayBB=EMImageBB.ImageGetImageDisplay(0)

EMROIDisplayBB.ApplyDataBar()

string EMImageBBName=EMImageNameBB

SetName(EMImageBB, EMImageBBName)

 

 

// ==

 

 

// ===

number EMxScaleCC, EMyScaleCC //

GetScale(EMImageCC, EMxScaleCC, EMyScaleCC)

ImageDisplay EMImageDisplayCC=EMImageCC.ImageGetImageDisplay(0)

ROI EMROICC=EMImageDisplayCC.ImageDisplayGetROI(0)

image EMROIImageCC=EMImageCC[]

 

// ==

// For setting the name:

 

string EMImageNameCC

GetName(EMImageCC, EMImageNameCC)

ImageDisplay EMROIDisplayCC=EMImageCC.ImageGetImageDisplay(0)

EMROIDisplayCC.ApplyDataBar()

string EMImageCCName=EMImageNameCC

SetName(EMImageCC, EMImageCCName)

 

 

 

 

// ===

number EMxScaleDD, EMyScaleDD //

GetScale(EMImageDD, EMxScaleDD, EMyScaleDD)

ImageDisplay EMImageDisplayDD=EMImageDD.ImageGetImageDisplay(0)

ROI EMROIDD=EMImageDisplayDD.ImageDisplayGetROI(0)

image EMROIImageDD=EMImageDD[]

 

// ==

// For setting the name:

 

string EMImageNameDD

GetName(EMImageDD, EMImageNameDD)

ImageDisplay EMROIDisplayDD=EMImageDD.ImageGetImageDisplay(0)

EMROIDisplayDD.ApplyDataBar()

string EMImageDDName=EMImageNameDD

SetName(EMImageDD, EMImageDDName)

 

 

 

 

// ==

 

result (GetName(EMImageAA) +"\t" + sum (EMROIImageAA)+ "\n")

result (GetName(EMImageBB) +"\t"  + sum(EMROIImageBB) + "\n")

result (GetName(EMImageCC) +"\t"  + sum(EMROIImageCC) + "\n")

result (GetName(EMImageDD) +"\t"  + sum(EMROIImageDD) + "\n")

 