Gatan | AMETEKSkip to Main Content
No options found

Adding annotations to an image display

Python Script

Example of adding annotation components to an ImageDisplay. The script uses the front-most displayed image. If none is found, it creates and displays one.

Preview

'''
Example of adding annotation components to an ImageDisplay.
The script uses the front-most displayed image. If none is 
found, it creates and displays one.
'''
import DigitalMicrograph as DM
import numpy as np

testImg = 0
if ( 0<DM.CountImageDocuments() ):
	testImg = DM.GetFrontImage()
else:
	testImg = DM.CreateImage( np.arange(120000).reshape(300, 400).copy() )
	testImg.ShowImage()
	
sx = testImg.GetDimensionSize(0)
sy = testImg.GetDimensionSize(1)
img_disp = testImg.GetImageDisplay(0)

img_disp.AddNewComponent(2, sy*3/9, sx*1/5, sy*3/9,sx*4/5) # line
img_disp.AddNewComponent(3, sy*4/9, sx*1/5, sy*5/9,sx*4/5) # arrow
img_disp.AddNewComponent(4, sy*6/9, sx*1/5, sy*6/9,sx*4/5) # double arrow
img_disp.AddNewComponent(5, sy*1/9, sx*1/9, sy*8/9,sx*8/9) # box
img_disp.AddNewComponent(6, sy*1/9, sx*1/9, sy*8/9,sx*8/9) # oval

# Cleanup 
del img_disp
del testImg