Authors: Jingning Shi, Wei Xiang
License: GPL3

TravisCI Build Status AppVeyor Build Status codecov ropensci cran checks Downloads

MtreeRing is a tool for automatically measuring tree-ring width using image processing techniques.


Install the stable version from CRAN


or the development version from GitHub

# install.packages("devtools")

Ring-width measurement

1. Read an image

## Read and plot a tree ring image <- system.file("001.png", package = "MtreeRing")
t1 <- ring_read(img =, dpi = 1200, plot = TRUE)

ring_read supports commonly used image formats, including png, tiff, jpg and bmp.

2. Detect ring borders

After plotting the image, the automatic detection of ring borders can be performed using three alternative methods: (1) watershed algorithm; (2) Canny edge detector; (3) a linear detection algorithm from R package measuRing.

## Split a long core sample into 2 pieces to
## get better display performance and use the
## watershed algorithm to detect ring borders:
t2 <- ring_detect( = t1, seg = 2, method = 'watershed')
Figure 1. The automatic detection of ring borders

3. Calculate ring-width series

If all ring borders are correctly identified, you can generate a ring-width series in data frame format. Use write.rwl to export the ring-width series to an rwl file.

rw.df <- ring_calculate( = t2, seriesID = "940220")
library(dplR) # A dendrochronological analysis package
fn <- tempfile(fileext=".rwl")
write.rwl(rwl.df = rw.df, fname = fn, format = "tucson")

Shiny application

If you are not familiar with R and its command line interface, the shiny-based app is a good alternative.


This command allows to run a Shiny-based application within the system's default web browser. The app provides a beginner-friendly graphical interface and supports more flexible mouse-based interactions, allowing image files to be uploaded up to 150 MB in size.

The dashboard has three components: a header, sidebar and body, like this

A workflow for the Shiny app can be found at Most steps are demonstrated with a gif to make the workflow more understandable.

Ring width correction

If an increment borer is used to extract samples, it is well known that the auger sometimes fails to traverse the pith of the sampled tree but passes through one side of the pith at a certain distance. Tangent lines of rings close to the pith are therefore not perpendicular to the horizontal path, which may lead to considerable errors in ring widths.

Under such conditions, you can create two paths by setting the argument incline = TRUE, or by ticking the checkbox Inclined tree rings. See this example.

The line segment connecting two dots on the same ring should match the tangent of a tree ring border. The corrected ring width is estimated from the distance between adjacent rings and orientation of ring borders.


Any feedback, bug reports or suggestions are welcomed. If you have a comment on MtreeRing, or you find a bug in the released or beta versions, please submit bugs and/or feature requests at Include the package version, OS, and any command-line required to reproduce the problem.

Code of conduct

I will try to add new features based on user feedback. It is hoped that others will contribute additional useful features. Please note that the 'MtreeRing' project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.



A tool for measuring tree-ring width

Mtreering Info

⭐ Stars15
🔗 Source
🕒 Last Updatea year ago
🕒 Created4 years ago
🐞 Open Issues6
➗ Star-Issue Ratio3
😎 Authorropensci