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


Example: Butterworth Filter
An example script which shows how to create a Butterworth filter - useful for spatial filtering with FFTs.
20070228. v1.0
D. R. G. Mitchell
Filtering is achieved by multiplying the FFT by the Butterworth filter then doing the IFFT. This Butterworth filter removes high frequency information (smooths). If the Butterworth filter is inverted it will remove low frequencies (sharpens).
System Requirements
Should be compatible with all recent versions of DigitalMicrograph.
Known Issues
Included Files
Main script file.
Source Code

// a function to create a Butterworth filter for filtering out high frequencies

// in the FFT.


// D. R. G. Mitchell, (remove the nospam to make this email address work

// version: 20070228

// v1.0, Feb. 2007



image butterworthfilter(number imgsize, number bworthorder, number zeroradius)



// See John Russ's Image Processing Handbook, 2nd Edn, p 316

image butterworthimg=realimage("",4,imgsize, imgsize)




// note the halfpointconst value sets the value of the filter at the halfway point

// ie where the radius = zeroradius. A value of 0.414 sets this value to 0.5

// a value of 1 sets this point to root(2)


number halfpointconst=0.414


return butterworthimg



number butterworthorder=3

number zeroradius=128

number imgsize=1024

image butterworthimg=butterworthfilter(imgsize, butterworthorder, zeroradius)



// To use this filter create an FFT of the image you want to process, multiply the FFT by the

// butterworth image, then compute the inverse FFT. This filter will remove the high frequency

// component from the image - smooth. If you invert the Butterworth filter, it will remove the low frequency

// component - sharpen.