Gatan | AMETEKSkip to Main Content
No options found

Process all images on a workspace

DigitalMicrograph Script

This automation script applies a processing method to all currently open images. The script is easily modified to perform different tasks on all currently open images.

Preview

void PerformBatchAction( imageDocument doc )
{
	// Modify this method to act on the imageDocument or image 
	
	// Current action: Output the data type and some statistics of first image in document
	image img := doc.ImageDocumentGetImage( 0 ) 
	result( "\t\t Data range [ " + min( img ) + ", " + max( img ) + "] mean = " + mean( img ) + "\n" )
}


if ( TwoButtonDialog( "Perform action on all images...", "across all Workspaces", "on the active Workspace" ) )
{
	number nWS = WorkspaceGetCount()
	for( number w = 0; w < nWS ; w++ )
	{
		number wsID = WorkspaceGetFromIndex( w )
		string wsName = WorkSpaceGetName( wsID )
		number nDocs = CountImageDocuments( nWS )
		result( "\n Performing action on " + nDocs + " documents on '" + wsName + "':\n" )
		for( number i = 0 ; i < nDocs ; i++ )
		{
			imageDocument doc = GetImageDocument( i, nWS )
			PerformBatchAction( doc )
		}
	}
}
else
{
	number nDocs = CountImageDocuments()
	result( "\n Performing action on " + nDocs + " documents:\n" )
	for( number i = 0 ; i < nDocs ; i++ )
	{
		imageDocument doc = GetImageDocument( i )
		PerformBatchAction( doc )
	}
}