Scripting Resources for DigitalMicrograph™ |
Ellipse Fitting |
|
Function |
Function which will compute the parameters of an ellipse which best fits a 2D array of points. |
Version |
version:20211012, v1.0 |
Author |
D. R. G. Mitchell and J-A. van den Berg |
Acknowledgements |
|
Comments |
This function will compute the parameters of the ellipse which best fits a 2D array of coordinates which is passed in. Since a circle is just one form of ellipse, this function can be used to fit circular features such as diffraction rings/disks, aperture outlines etc. The function computes the parameters of the ellipse - the coordinates of the centre, the major and minor axes and the angle of the major axis. This function was used in the script Ellipse Fitting Analysis, to measure diffraction patterns and to characterise any elliptical distortion which may be present. The mathematics of the method is described in the following paper. If this function contributes in any meaningful way to a publication, please consider citing that work. Data passed in to the function is in the form of a 2D array of x (top row) and y (bottom row) coordinates of points lying on an ellipse/circle. The function will compute the parameters of the fit and will return a corresponding array of points which is the projection of the original points onto the fitted ellipse. The distance between any given point and its projection onto the ellipse is a measure of the goodness of fit and the square root of the sum of the squares of the differences for all points (rss) can be used to recursively remove the largest outliers to bring the rss below some threshold. In this way, a small number significant outliers, which might otherwise massively skew the fit, can be identified and removed. This is not implemented here. This demonstration script, passes in an array of points, fits the ellipse and computes the projected points onto the ellipse. These are all displayed in a 2D image.
|
System Requirements |
Tested on GMS 2.32, but should work on all versions of GMS. |
Known Issues |
Requires a minimum of four points. |
Supported |
Yes. |
Included Files |
Main script. |
Source Code |
see attached script |