Skip to content

ImageJ macro algorithm for determining overlap of grains modelled as ellipses

Notifications You must be signed in to change notification settings

MurphysLab/onasch_grains

Repository files navigation

Onasch Grains

This is an ImageJ macro for determining features of grain boundary interfaces, wherein the grains are modelled by ellipses which represent a reconstruction of the original grain boundaries.

Using the intersections of these reconstructed grain boundaries, i.e. the grain-fitting ellipses, a straight-line compromise boundary is determined. From this, the width of the compressed region as well as the total width are determined along the line perpendicular to the midpoint of the compromise boundary.

The process, including its purpose and technical significance, is described in Onasch (1993); Pierson (2014) is an open-access thesis with a description of the method.

Original figure from Onasch (1993)

This process has been adapted using ImageJ to solve the analysis of overlapping ellipses:

Figure outlining process, adapted from Onasch (1993)

Method

The method used by this algorithm determines the points at which two ellipses intersect using the polygonal approximation of the ROI in ImageJ. Typically ImageJ's makeEllipse function produces 72-sided polygons when rendered as regions of interest (ROIs). In practice, this means that the method is an approximation compared to analytic calculations of ellipse intersections. However this is sufficinetly accurate for the intended purpose and has the added benefit that it can be extended to any other pair of convex polygons.

Files

  • ellipse_intersections.ijm : The "Ellipse Intersections" macro provides a simple demonstration of the method which requires no additional data input. Simply open with ImageJ (or FIJI) and click Run to execute and see the results.
  • onasch_grains.ijm : The "Onasch Grain Overlaps" macro is designed for processing multiple ellipses for a given image, with the ellipse data loaded as a CSV file into ImageJ's Results Table. The output results will be recorded in a new table.

The algorithm:

  1. For all ellipses:
    1. Make ellipse ROI
    2. Rotate, translate, and make the intervals regular
    3. add to ROI manager.
  2. Loop through, comparing all pairs of ellipses
    1. Get the ROIs
    2. Check for intersections
    3. If they intersect, determine the line between the intersection points
    4. Find midpoint; calculate line perpendicular (L).
    5. Find points where L intersects the two ellipses.
    6. Calculate the min and max distances from those intersections
    7. Record distances.
    8. Draw the lines

In step 2.2, checking for intersections, check is performed, utilizing the nature of ellipses, to determine whether the distance between two ellipse centres is greater than the sum of the semi-major axes of the ellipses. This provides time-savings relative to the process to determine where and if two polygons intersect for all pairs of polygons.

Input Data

The CSV is a data file containing coordinates for the ellipses drawn using EllipseFit. The output file may require editing to remove prefatory lines in order for ImageJ to recognize it (i.e. There should be no lines preceeding the column labels.)

The CSV file is expected to be organized with the following columns:

ID,X,Y,Max,Min,Area,R,Phi

  • ID : id number for each ellipse
  • x : centre x coordinate (px)
  • y : centre y coordinate (px)
  • max : semi-major axis of the ellipse (px)
  • min : semi-minor axis of the ellipse (px)
  • R : ellipse ratio ( max / min)
  • Phi : orientation of the long axis of ellipse

The image input is typically a TIF of a thin section of geological material under a petrographic microscope. The desired ellipses may already be drawn on it, however this is not a data input. The image file is unnecessary, however it provides a check for the data.

Two sample data files have been provided by Marques Hatfield.

User Inputs

Colours and line widths of the overlays plotted with the Onasch_Grains tool can be modified by changing the input values at the top of the macro file. Hex codes are used for colour.

It is important to note that the ellipse measurements (coordinates and axes) are given in pixel units.

Output Data

Ellipses drawn with and without lines drawn to measure shortening perpendicular to the compromise boundary:

Numbered ellipses on a blank canvas using input data. Numbered ellipses on a blank canvas with compromise boundaries and compression axes drawn.

To quickly visualize the results from this, the data points can be plotted on circle relative to angle and percent shortening.

  • quick_orientation_plot.ijm : The macro offers two methods to choose from. (A) Points are plotted with (100-percent_shortening)/100 × plot_radius. (B) Points are plotted with (percent_shorting / max_percent_shortening) × plot_radius.
A B

References:

  1. Charles M. Onasch, "Determination of pressure solution shortening in sandstones", Tectonophysics, 1993, 227, pp. 145-159. DOI: 10.1016/0040-1951(93)90092-X
  2. Nichole Pierson, "Assessing Layer Parallel Shortening in the Easter Colorado Front Range Using Tin Section Analysis and Analog Sandbox Models". MSc Thesis, University of Nebraska - Lincoln, Department of Earth and Atmospheric Sciences, 2014. URL: http://digitalcommons.unl.edu/geoscidiss/51

About

ImageJ macro algorithm for determining overlap of grains modelled as ellipses

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published