Scripting Resources for DigitalMicrograph™


Dave Mitchell's DigitalMicrograph™ Scripting Website

Home | Scripts | Examples | Functions | Recent Updates | Tutorials | Resources | Publications | Consulting | Projects | Contact & Bio | Private | Search


Local Neighbourhood Density Threshold and Dilation
Processes x-ray dot maps to eliminate background dots (low density of dots) but retain dots in regions which contain the element of interest (high density of dots) and if necessary - fill in this area by dilation.
version:20150311, v1.2
D. R. G. Mitchell

This script works by assessing the local density of dots within a neighbourhood. If the density is below a threshold - the dot is removed - otherwise it is kept. This is effective at removing dots from background regions which do not contain the element of interest. Once suitable neighbourhood and threshold values have been found, Dilation can be applied to fill in the dotty regions containing the element of interest. This enables dotty x-ray maps to be converted into a binary map for thresholding etc. All processing is done using greyscale maps. Pixel values can be anything - but this must be known as it will affect the threshold values used. The more I use this script the more I like it.

Updated in v1.2 so that it remembers the last set of parameters which were used.

System Requirements
X-ray maps must be greyscale (or binary). This script has been set up to work with Bruker x-ray maps where each dot is actually a cluster of 9 pixels. Other software may create maps with a different sizing - but adjustment of the neighbourhood size should deal with that.
Known Issues
This software will not process RGB (colour) maps, which most software produce. Import the RGB maps into DM and then convert to greyscale with the Edit/Change Data Type function.
Included Files
Main script file.
Source Code

see attached script.