title: "MtreeRing: Measuring Tree Ring Width in R" author: "Jingning Shi" date: "2019-03-01" output: html_document: toc: true number_sections: true vignette: > %\VignetteIndexEntry{introduction} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8}
MtreeRing
is a tool for automatically measuring tree-ring width using image processing techniques.
Install the stable version from CRAN
install.packages("MtreeRing")
or the development version from GitHub
# install.packages("devtools")
devtools::install_github("JingningShi/MtreeRing")
library(magick)
## Read and plot a tree ring image
img.name <- system.file("001.png", package = "MtreeRing")
t1 <- imgInput(img = img.name, dpi = 1200)
imgInput
supports commonly used image formats and returns a magick image object.
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.
If auto.path = TRUE
, the function will create a path at the center of the image. In the current version, the path is a horizontal dashed line. Detected ring borders are placed along the path, and are tagged with years and border numbers.
## Split a long core sample into 2 pieces to
## get better display performance and use the
## watershed algorithm to detect ring borders:
t2 <- autoDetect(ring.data = t1, auto.path = TRUE, seg = 2, method = 'watershed')
For increment cores with inclined rings, you can create two paths by setting incline = TRUE
. The distance between adjacent rings and orientation of ring borders are used to correct the ring-width series.
t3 <- autoDetect(ring.data = t1, incline = TRUE, method = 'watershed')
When ring borders are added to the image, you can generate a ring-width series in dataframe format. Use write.rwl
(from R package dplR
) to export this dataframe in rwl format.
rw.df <- calcRingWidth(ring.data = t2, seriesID = "940220")
If you are not familiar with R and its command line interface, use the shiny-based app. A workflow for the Shiny app can be found in the README file of this package. Here is a link: https://github.com/JingningShi/MtreeRing.
launchMtRApp()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.