Gatan | AMETEKSkip to Main Content
No options found

Find image by ID

Python Script

Example use of FindImage by ID. This script gets the chronologically last image. It works because image IDs are incremented whenever new memory is allocated.

Preview

'''
Example use of FindImage by ID. This script gets the chronologically last image. 
It works, because image IDs are incremented whenever new memory is allocated.
'''
import DigitalMicrograph as DM

maxID = 10000	# Start with ID value exceeding current maximum
img = None

# Get an image and check if it exists.
# Otherwise reduce ID
while ( maxID > 0 and ( img is None )) :
	img = DM.FindImageByID( maxID )
	maxID = maxID - 1

if ( img is None ):
	print( 'No image was found' )
else:
	img.ShowImage()
	img.SetName( 'Found image!' )
	
del img 	# Always explicitly delete Py_Image variables