# Grain size analysis in ImageJ (SEM, ASTM E112) + grain size number calculator

> Measure grain size from SEM images in ImageJ: closed boundaries, Analyze Particles, then ASTM E112 G from mean area or intercept, with a worked example.

Published 2026-11-06 by LabCanvas team. https://www.labcanvas.com/blog/grain-size-analysis-sem

![ImageJ Analyze Particles on a synthetic SEM image of a perovskite film: 118 whole grains outlined in yellow and numbered, grains cut by the edge left out, the Results table with the area and Feret diameter of each grain, and the Summary row with Count 118 and Average Size 39,344.6 nm²](https://www.labcanvas.com/blog/imagej/grain-size-analysis-sem-cover.webp)

To measure grain size in ImageJ, set the scale, threshold the image so that every grain is a closed region, and run **Analyze › Analyze Particles…** with **Exclude on edges** to get the area of every whole grain. The ASTM E112 grain size number G then follows from the mean grain area \(\bar{A}\) (planimetric method) or from the mean lineal intercept \(\ell\) (intercept method):

- **From the mean area:** \(G = 3.321928 \cdot \log_{10}(N_\mathrm{A}) - 2.954\), where \(N_\mathrm{A} = 1/\bar{A}\) is the number of grains per mm² at 1×.
- **From the mean intercept:** \(G = -6.643856 \cdot \log_{10}(\ell) - 3.288\), with \(\ell\) in mm.

For a nanocrystalline film G comes out above 20, far past the tables in the standard, so report the mean equivalent diameter and its distribution too. The [ASTM E112 grain size calculator](https://www.labcanvas.com/tools/astm-grain-size-calculator) converts mean area or mean intercept to G and back.

## Planimetric or intercept: the two ASTM E112 methods

ASTM E112 (current edition E112-25) describes three ways to estimate the average grain size: comparison with charts, the planimetric (Jeffries) procedure and the intercept (Heyn) procedures. The last two are the ones you can do from an image, and for equiaxed grains they estimate the same G.

| | Planimetric (Jeffries) | Intercept (Heyn) |
|---|---|---|
| What you count | Grains in a known area | Grain boundaries crossed by test lines of known length |
| Counting rule | A grain inside counts 1, a grain cut by the edge ½ | A tangent counts 1, a triple point 1½ |
| What you get | \(N_\mathrm{A}\), grains per mm² at 1×; mean area \(\bar{A} = 1/N_\mathrm{A}\) | Mean lineal intercept \(\ell = L/P\) |
| \(G\) | \(3.321928 \cdot \log_{10}(N_\mathrm{A}) - 2.954\) | \(-6.643856 \cdot \log_{10}(\ell) - 3.288\) (\(\ell\) in mm) |
| Best for | Thresholded images and Analyze Particles; it also gives the size distribution | Hand counts, test grids, and images whose boundaries are too faint to segment |

Behind both is the original definition, \(N = 2^{G-1}\), where \(N\) is the number of grains per square inch at 100×; multiply N by 15.50 to get grains per mm² at 1×. Each step of G halves the mean grain area, and G is usually given to one decimal place. Automatic and semi-automatic image analysis has its own standard, ASTM E1382, and grain size from EBSD maps is covered by ASTM E2627.

## In ImageJ (or Fiji)

These steps work in plain ImageJ 1.x unless a step says Fiji. A worked example with real numbers follows.

### 1. Calibrate and clean the image

1. Open the original SEM TIFF, not a screenshot or a JPEG from a slide. **Image › Properties…** shows whether ImageJ read a pixel size; SEM makers often store it in their own header, which ImageJ may not read.
2. Draw a straight line along the scale bar and open **Analyze › Set Scale…**: type the bar's length in **Known distance** and **nm** in **Unit of length**. Tick **Global** only if every image you open has the same pixel size.
3. Cut off the instrument's data bar: draw a rectangle over the image area and choose **Image › Crop**, so that the bar is not counted as grains.
4. If the file is RGB, convert it with **Image › Type › 8-bit**.
5. Smooth the noise with **Process › Filters › Median…** at a radius of 1–2 pixels; a median keeps thin boundaries sharper than a Gaussian blur.
6. If the brightness drifts across the field (detector position, charging), use **Process › Subtract Background…** with a rolling ball radius larger than the biggest grain, in pixels. Tick **Preview** and check that the boundaries do not fade.

### 2. Threshold so that every boundary stays closed

A grain is only measured correctly if its boundary is a closed line. How you get there depends on how the boundaries look.

**Dark boundaries on bright grains** (grooved boundaries, as in the sample further down):

1. Open **Image › Adjust › Threshold…**, pick a method (Default, Otsu and MaxEntropy are good first tries) and set it so that the red overlay covers the grains, not the boundaries (the **Dark background** box flips this).
2. Zoom to 200–400% and follow the boundaries: wherever one is broken, two grains will be measured as one. Then click **Apply**.
3. Close a few gaps by hand: a line selection across the gap, then **Edit › Draw** (it draws in the colour set in **Edit › Options › Colors…**).
4. Use **Process › Binary › Watershed** only when many boundaries are open. It splits merged round grains, but it also cuts elongated or irregular grains in two; compare the count before and after.

**Bright boundaries** (secondary-electron images often make boundaries and edges glow):

1. Threshold the boundaries themselves, as the bright class, and click **Apply**: the boundary network is now the foreground.
2. **Process › Binary › Close-** bridges small gaps in the network.
3. **Process › Binary › Skeletonize** thins it to one-pixel lines along the middle of each boundary, so each grain gets its share of the boundary area.
4. **Process › Binary › Dilate** once. Analyze Particles traces 8-connected particles, so two grains could otherwise join through a diagonal step in a one-pixel line.
5. **Edit › Invert** makes the grains the foreground. If Analyze Particles later returns one huge particle, the foreground is the wrong way round: check **Process › Binary › Options…** › **Black background**.

When no single threshold separates grains from boundaries, Fiji has two plugins that help: **Trainable Weka Segmentation** (**Plugins › Segmentation › Trainable Weka Segmentation**) learns grain and boundary from a few strokes you draw, and **MorphoLibJ**'s Morphological Segmentation (from the IJPB-plugins update site) runs a watershed on the boundary image itself.

### 3. Measure the grains (planimetric method)

1. In **Analyze › Set Measurements…** tick **Area**, **Shape descriptors**, **Feret's diameter** and **Fit ellipse**, and **Display label**.
2. Run **Analyze › Analyze Particles…**: **Size (nm^2)** from just above the largest speck to Infinity, **Circularity** 0.00–1.00, **Show: Outlines** (or Overlay), and tick **Display results**, **Clear results**, **Summarize**, **Exclude on edges** and **Include holes** (a pinhole inside a grain stays part of the grain).
3. The Summary window gives **Count**, **Total Area** and **Average Size**; Average Size is \(\bar{A}\). Convert it to mm² (1 µm² = 10⁻⁶ mm², 1 nm² = 10⁻¹² mm²), take \(N_\mathrm{A} = 1/\bar{A}\) and work out \(G\).
4. ImageJ has no equivalent-diameter column: compute \(d = 2\sqrt{\mathrm{Area}/\pi}\) for each row in a spreadsheet. **Feret** (the longest calliper distance) and **MinFeret** are in the table already; see [Feret diameter, circularity and solidity](https://www.labcanvas.com/blog/feret-diameter-circularity) for what each means.
5. **Analyze › Distribution…** draws a histogram of any column of the Results table (Area or Feret, for example), with automatic or chosen bins.
6. For the strict Jeffries count, run Analyze Particles again with **Exclude on edges** off: the difference between the two counts is the number of grains cut by the frame, and \(N_\mathrm{A} = (N_\mathrm{inside} + \tfrac{1}{2} \cdot N_\mathrm{cut}) / \text{field area}\).

Every option in that dialog is explained in [Analyze Particles in ImageJ, explained](https://www.labcanvas.com/blog/analyze-particles-imagej).

### 4. The intercept method

1. Start from a mask of the boundaries thinned to one pixel (step 2, bright-boundary route; for dark boundaries, threshold the boundaries instead of the grains and skeletonise them).
2. Overlay test lines with **Analyze › Tools › Grid…** (ImageJ 1.50f and later): **Grid type** Lines or Horizontal Lines, with **Area per point** setting the spacing. The grid is an overlay, so it does not change the pixels.
3. Count the crossings with the **Multi-point** tool: a line tangent to a boundary counts 1, a line through a triple point 1½. For a handful of lines, a quicker check is a straight line selection and **Analyze › Plot Profile**: each boundary it crosses is a peak.
4. Divide the total line length (in calibrated units, converted to mm) by the number of crossings to get \(\ell\), and \(G = -6.643856 \cdot \log_{10}(\ell) - 3.288\).
5. Count several hundred crossings, spread over several fields, for a stable mean.

## Worked example: grain size of a perovskite film in ImageJ

The sample is a top-view SEM image of a perovskite film (synthetic, generated with known grains for these guides): 1024 × 1024 pixels at **2.5 nm per pixel**, 8-bit, bright grains with dark grooved boundaries, a few small bright platelets and some pinholes. In ImageJ 1.54f:

1. **Open the TIFF.** The title bar reads 2560x2560 nm, so the scale came with the file; there is no data bar to crop.
2. **Image › Adjust › Threshold…**: method **MaxEntropy**, **Dark background** ticked (the grains are the bright class). The cut falls at 95 and every boundary stays closed, so no watershed is needed.
3. **Analyze › Set Measurements…**: **Area** and **Feret's diameter**.
4. **Analyze › Analyze Particles…**: **Size** 3000-Infinity nm² (to drop the platelets and specks), **Display results**, **Clear results**, **Summarize**, **Exclude on edges**, **Include holes** and **Overlay**.

![ImageJ Threshold window with the MaxEntropy method over an SEM image of a perovskite film, grains in red](https://www.labcanvas.com/blog/imagej/grain-size-analysis-sem-threshold.webp "ImageJ 1.54f on the synthetic perovskite film: Image › Adjust › Threshold with MaxEntropy and Dark background. The lower threshold is 95 8-bit, the grains are red, and the inset shows that the dark boundaries stay closed between neighbouring grains.")

![ImageJ Analyze Particles result on the perovskite film: 118 grains outlined, Results and Summary tables](https://www.labcanvas.com/blog/imagej/grain-size-analysis-sem-cover.webp "Analyze Particles from 3,000 nm² with Exclude on edges and Include holes: 118 whole grains outlined in yellow, one row per grain in the Results table, and a Summary row with Count 118 and Average Size 39,344.6 nm². Grains cut by the frame have no outline.")

The result: **118 grains** (those cut by the frame left out) and a **mean grain area of 39,344.6 nm²**. The diameter of a circle with that area is **224 nm** (\(2\sqrt{39{,}345/\pi}\)). The mean of each grain's own equivalent diameter is smaller, **210 ± 76 nm** (mean ± SD, n = 118), because small grains weigh as much as large ones in that average; say which one you report.

### The grain size number for this film

From the mean area, step by step:

1. \(\bar{A} = 39{,}345\ \mathrm{nm}^2\) \(= 39{,}345 \times 10^{-12}\ \mathrm{mm}^2\) \(= 3.9345 \times 10^{-8}\ \mathrm{mm}^2\).
2. \(N_\mathrm{A} = 1/\bar{A} = 2.542 \times 10^7\) grains per mm² at 1×.
3. \(\log_{10}(N_\mathrm{A}) = 7.4051\).
4. \(G = 3.321928 \times 7.4051 - 2.954\) \(= 24.600 - 2.954 = \mathbf{21.6}\).

As a check against the original definition: \(N = 2^{G-1} = 2^{20.65} \approx 1.64\) million grains per square inch at 100×, and \(1.64 \times 10^6 \times 15.50 = 2.54 \times 10^7\) grains per mm², as above.

Here \(\bar{A}\) is the mean of the whole grains. For the strict Jeffries count, run Analyze Particles again with **Exclude on edges** off: ImageJ finds 161 grains of at least 3,000 nm², so 43 are cut by the frame. \(N_\mathrm{A} = (118 + \tfrac{1}{2} \times 43)\) \(\div\, 6.5536 \times 10^{-6}\ \mathrm{mm}^2\) (the 2,560 × 2,560 nm field) \(= 2.13 \times 10^7\) grains per mm², and \(G = \mathbf{21.4}\). The two routes differ by 0.2, which is why the counting rule belongs in your methods.

The intercept formula gives the same G = 21.6 for a mean intercept of about 177 nm: the mean intercept is shorter than the equivalent diameter, because most test lines cross a grain away from its centre. Putting the 224 nm equivalent diameter into the intercept formula by mistake would give G = 21.0, more than half a unit off.

### The size distribution in ImageJ

**Analyze › Distribution…** draws a histogram of any column of the Results table, with n, mean and SD. For equivalent diameters, add a column first: open **Plugins › New › Macro**, type the one line below and click **Run**, then choose **D** in Distribution.

> Table.applyMacro("D=2*sqrt(Area/PI)");

**File › Save As…** in the Results window saves the table as CSV for a spreadsheet or a graphing program.

## Why G is not the headline number for a nanocrystalline film

The grain size number was built for metals: \(N = 2^{G-1}\) grains per square inch at 100× in a light microscope, and the tables in E112 end at G 14, a mean grain area of about 7.9 µm² (a mean intercept of about 2.5 µm). The grains of the film above are about 200 times smaller in area, so G = 21.6 sits seven and a half steps past the end of the table. Three more reasons to lead with diameters:

- **Readers think in nanometres.** A reviewer of a thin-film paper can picture 224 nm grains; "G 21.6" means little outside metallurgy.
- **The assumptions don't hold.** E112 was written for metals that are entirely or mainly one phase, with equiaxed grains cut by a random section. A top view of a film shows the surfaces of grains that are often columnar, with pinholes and second phases (the small bright platelets in the sample), and the counting rules assume a section through a bulk solid.
- **One average hides the spread.** Film properties often depend on the distribution (a few large grains, or two populations), and G compresses it into one logarithm.

So report the mean equivalent diameter ± SD with n (grains and images) and show the histogram; add G when a specification or a metals reader asks for it.

## Grain size from SEM is not crystallite size from XRD

The [XRD Scherrer calculator](https://www.labcanvas.com/tools/xrd-scherrer-calculator) gives a crystallite size: the size of the coherently diffracting domains, measured perpendicular to the diffracting planes. In a symmetric θ–2θ scan of a film those planes lie parallel to the surface, so the size is measured through the film's thickness, while a top-view SEM grain size is measured across it. One grain can also hold several domains (twins, subgrains, stacking faults), peak broadening also comes from microstrain and the instrument, and the Scherrer equation loses sensitivity above about 100–200 nm. A Scherrer size well below the SEM grain size is therefore expected, not a contradiction. Report both, each with its method.

## Pitfalls

- **Open boundaries merge grains.** Look at the outlines on the image: a merged pair shows as an outline that crosses a faint boundary, and as a long tail on the right of the histogram.
- **Watershed everywhere cuts grains.** On irregular or elongated grains it adds straight cuts that are not boundaries, and the count rises while the mean falls. Use it where boundaries are open, not by default.
- **Thresholding the grains loses the boundaries' width.** Each grain comes out short by half its boundary width all round; the smaller the grains, the bigger the share. Skeletonised boundaries give grain areas that tile the field.
- **Excluding edge grains favours small grains.** A large grain is more likely to touch the frame, so use fields with hundreds of grains, or the Jeffries half-count.
- **Specks, pinholes and second phases.** A size minimum drops specks; **Include holes** (or **Process › Binary › Fill Holes** on the mask) keeps a pinhole inside its grain. Decide whether a second phase counts as grains or not, and say so.
- **The scale.** Set it from the scale bar of the same image, before cropping the data bar off. An image recorded at a stage tilt is shortened along one direction by the cosine of the tilt angle.
- **Too few grains.** One field of a hundred grains gives a rough mean; measure several fields, ideally from different places on the sample.

The same route measures pores; see [porosity and pore size from SEM images](https://www.labcanvas.com/blog/porosity-pore-size-sem-image).

## Reporting it

A methods sentence to adapt:

> Grain size was measured on top-view secondary-electron SEM images (n images, 2.5 nm per pixel) in ImageJ 1.54f. Grains were segmented with the MaxEntropy threshold (grains brighter than their boundaries), holes inside grains were included, and grains touching the image edge and objects smaller than 3,000 nm² were excluded. Grain areas were converted to equivalent circle diameters, d = 2√(A/π). The ASTM E112 grain size number was calculated from the mean grain area Ā (in mm²) as G = 3.321928 · log₁₀(1/Ā) − 2.954.

Give the threshold method and the value it chose (95 here), the size minimum and how edge grains were handled. Show the result as a histogram of equivalent diameters next to the SEM image with its scale bar (**Analyze › Tools › Scale Bar…**) and the grain outlines (**Image › Overlay › Flatten** makes a copy with both drawn in).

## Grain size on many images: macros and Fiji plugins

Record the steps once with **Plugins › Macros › Record…** and run them on a folder with **Process › Batch › Macro…**: with **Summarize** on, each image adds a row with its count and mean area. Fiji's plugins go further for difficult images (MorphoLibJ, Trainable Weka Segmentation), for 3D stacks from FIB-SEM, and for files in a maker's own format through Bio-Formats.

## An easier way: grain size in LabCanvas

LabCanvas Image Analysis does the planimetric route in the browser, with nothing to install and no plugins: threshold, size filter and edge exclusion sit in one panel, on the raw pixel values.

1. Open the TIFF; the pixel size is read from an ImageJ or OME-TIFF (or set it from the scale bar in **Image › Scale**).
2. In **Count › Count particles**, choose **MaxEntropy** with bright objects, tick **Fill holes** and **Exclude particles on the edges**, leave **Separate touching objects (watershed)** off, and set the smallest size to 3000 nm². With a data bar, draw a rectangle over the image and tick **Only inside the selection**.
3. Click **Count**: every grain is outlined and numbered, with a row each in the Particles table and a Summary row.

![Grain size of a thin film in LabCanvas Image Analysis](https://www.labcanvas.com/analysis-examples/em-grains.webp "Grain size of a thin film: 118 grains of a perovskite film those cut by the frame left out: mean grain area 39,340 nm², an equivalent diameter of 224 nm.")

On the same film LabCanvas counts **118 grains** with a mean area of **39,340 nm²** (MaxEntropy cut at 95, as in ImageJ); ImageJ gave 118 grains and 39,344.6 nm². Both give an equivalent diameter of 224 nm and G = 21.6.

Why it is a good choice for grain size:

- Nothing to install: it runs in the browser on any computer or tablet.
- ImageJ's own names: the sixteen threshold methods, fill holes, exclude on edges, and a Summary row with Count, Total Area and Average Size.
- An image check flags JPEG compression, clipped pixels and uneven brightness before you count.
- Results go straight to Graphs for the histogram, and each table carries a methods sentence with the exact threshold value.
- Free with a LabCanvas account (CSV download is part of Pro); every measurement is checked in [more than 4,000 automated tests](https://www.labcanvas.com/image-analysis-validation).

It has no macro language (**Count › Batch** runs the same settings on many images) and does not read makers' own formats: export a TIFF first. [Open Image Analysis](https://www.labcanvas.com/analysis.html).

ImageJ and Fiji are independent open-source projects; LabCanvas is not affiliated with them.

## References

- ASTM International (2025). *ASTM E112-25: Standard Test Methods for Determining Average Grain Size.* [doi:10.1520/E0112-25](https://doi.org/10.1520/E0112-25)
- ASTM International (2023). *ASTM E1382-97(2023): Standard Test Methods for Determining Average Grain Size Using Semiautomatic and Automatic Image Analysis.* [doi:10.1520/E1382-97R23](https://doi.org/10.1520/E1382-97R23)
- Legland D, Arganda-Carreras I, Andrey P (2016). MorphoLibJ: integrated library and plugins for mathematical morphology with ImageJ. *Bioinformatics* 32(22): 3532–3534. [doi:10.1093/bioinformatics/btw413](https://doi.org/10.1093/bioinformatics/btw413)
- Arganda-Carreras I, Kaynig V, Rueden C, et al. (2017). Trainable Weka Segmentation: a machine learning tool for microscopy pixel classification. *Bioinformatics* 33(15): 2424–2426. [doi:10.1093/bioinformatics/btx180](https://doi.org/10.1093/bioinformatics/btx180)

## Frequently asked questions

### How do you calculate the ASTM grain size number from the mean grain area?

Convert the mean grain area \(\bar{A}\) to mm², take \(N_\mathrm{A} = 1/\bar{A}\) (grains per mm² at 1×) and use \(G = 3.321928 \cdot \log_{10}(N_\mathrm{A}) - 2.954\). For a mean area of 39,345 nm² (\(3.934 \times 10^{-8}\ \mathrm{mm}^2\)), \(N_\mathrm{A} = 2.54 \times 10^7\) grains per mm² and \(G = 21.6\).

### What is the formula for the intercept method?

Lay test lines of known total length \(L\) over the boundaries and count the crossings \(P\). The mean lineal intercept is \(\ell = L/P\), and \(G = -6.643856 \cdot \log_{10}(\ell) - 3.288\) with \(\ell\) in mm (the same as \(6.643856 \cdot \log_{10}(P_\mathrm{L}) - 3.288\) with \(P_\mathrm{L} = P/L\) in mm⁻¹). ASTM E112 counts a line tangent to a boundary as one crossing and a line through a triple point as one and a half.

### Can ImageJ measure grain size from an SEM image?

Yes. Set the scale from the scale bar, threshold the image so that every grain is a closed region, and run Analyze › Analyze Particles with Exclude on edges: you get the area, Feret diameter and shape of every whole grain, and the Summary gives the mean area. ImageJ does not report the ASTM grain size number itself; compute G from the mean area or the mean intercept with the E112 formulas.

### Should I use watershed to separate grains?

Only where boundaries are open. Watershed splits merged round grains, but it also cuts elongated or irregular grains in two, which lowers the mean size. If the boundaries in your image are closed after thresholding, leave it off; if a few are open, close them by hand or use watershed and compare the counts before and after.

### Why is my XRD (Scherrer) crystallite size smaller than the grain size from SEM?

They measure different things. The Scherrer size is the size of coherently diffracting domains, measured perpendicular to the diffracting planes (through the film thickness in a symmetric θ–2θ scan); one grain can hold several domains, peak broadening also comes from strain and the instrument, and the method loses sensitivity above about 100–200 nm. A top-view SEM grain size is the lateral size of each grain at the surface.

### What grain size number does a nanocrystalline thin film have?

A very high one. A mean grain area of 1 µm² is G 17.0, and the 224 nm grains of the sample film here are G 21.6, well past the end of the E112 tables (G 14). For films, report the mean equivalent diameter with its spread and histogram, and give G as well only when a specification asks for it.

## Related links

- [ASTM E112 grain size calculator](https://www.labcanvas.com/tools/astm-grain-size-calculator): Mean grain area or mean intercept to G, and back
- [Analyze Particles in ImageJ, explained](https://www.labcanvas.com/blog/analyze-particles-imagej): Every option in the dialog, with a TEM size distribution
- [Feret diameter, circularity and solidity](https://www.labcanvas.com/blog/feret-diameter-circularity): The shape descriptors in the grain table
- [Porosity and pore size from SEM images](https://www.labcanvas.com/blog/porosity-pore-size-sem-image): The same counting route for pores
- [XRD Scherrer calculator](https://www.labcanvas.com/tools/xrd-scherrer-calculator): Crystallite size from peak width
- [Image Analysis: every tool and setting](https://www.labcanvas.com/blog/image-analysis-complete-guide)
