Scripting Resources for DigitalMicrograph™

banner

Dave Mitchell's DigitalMicrograph™ Scripting Website

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

 

Function: Linear Regression fit of a 2D Plane
Function
Function to carry out a linear regression to calculate the best 2D plane fit to an image.
Version
version:20191021, v1.0
Author
D. R. G. Mitchell
Acknowledgements
-
Comments

This function will calculate the coefficients of the best fitting 2D plane to the passed in image by linear regression. The image passed in is an array of points with x and y coordinates and z intensity values. The function uses the pseudo-inverse matrix method to compute the plane of best fit according to the expression z=ax + by +c - the fit coefficients a, b and c are returned. These can be used to compute the best plane fitting an image. Substraction of this calculcated image from the original image can be used to level contrast variations.

System Requirements
Should be compatible with all recent versions of DigitalMicrograph.
Known Issues
The passed in image must be a 2D image as the pseudo-inverse matrix method will not work with 1D data. A linear regression function to fit 1D data can be found here.
Supported
Yes
Included Files
Main script file.
Source Code

See attached source code.