Giter VIP home page Giter VIP logo

mtreering's Introduction

MtreeRing

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.

Installation

Install the stable version from CRAN

install.packages("MtreeRing")

or the development version from GitHub

# install.packages("devtools")
devtools::install_github("ropensci/MtreeRing")

Ring-width measurement

1. Read an image

library(MtreeRing)
## Read and plot a tree ring image
img.name <- system.file("001.png", package = "MtreeRing")
t1 <- ring_read(img = img.name, 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(ring.data = 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(ring.data = 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.

MtreeRing::ring_app_launch()

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 https://ropensci.github.io/MtreeRing/articles/app-MtreeRing.html. 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.

Support

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 https://github.com/ropensci/MtreeRing/issues. 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.

ropensci_footer

mtreering's People

Contributors

jeroen avatar jingningshi avatar maelle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mtreering's Issues

Detection in progress

Hi! As a beginner with this package I've chosen to use the shiny-based application with the command MtreeRing::ring_app_launch().

First I uploaded the image, and cropped it without problems, but after creating path correctly, when I click on the "Ring Detection" then the application gets stuck in "Detection in progress" for hours, without final results, even if the file is in the right format (jpg) and the size is <10MB.
Also I've kept the default setting for the Labels and Detection windows. I tried with different format, or different files, but is always the same.
Thanks for the help.

Screenshot (3)

Feature Requests: Shifting starting point of path and/or crack marker

First, thank you again for this contribution to the dendro community! I am really excited about it.

Due to common imperfections in wood samples (breaks/cracks in the sample, insect damage, branch scars, etc), the ability to shift the path of measurements to a different location on the image (while keeping it continuous) would be really helpful.

Here is a link to the description of this feature in coo recorder: http://www.cybis.se/forfun/dendro/helpcoorecorder7/meacrack/index.htm

In some cases, the user may want to be able to measure across the break/crack and subtract that value from the ring width. It seems like it could be done manually, but a "crack marker" feature might be nice to see eventually.

Apologies if either of these operations are already possible and I missed them in the documentation.

Transect only goes straight, no hover line

When trying to add a transect line, I'm noticing three issues

  1. The hover line where the mouse position is does not show
  2. The transect only goes straight - its not angled if I click somewhere on the sides
  3. If I do click somewhere on the sides, the transect ends at a line that runs perpendicular to the transect itself.

I have a gif here showing the issues

Screen.Recording.2021-07-26.at.4.48.17.PM.mov

Session Info

R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS  10.16

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_NZ.UTF-8/en_NZ.UTF-8/en_NZ.UTF-8/C/en_NZ.UTF-8/en_NZ.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] dplyr_1.0.7          measuRing_0.5        spatstat.geom_2.2-2  spatstat.data_2.1-0 
 [5] dplR_1.7.2           imager_0.42.10       magick_2.7.2         bmp_0.3             
 [9] tiff_0.1-8           jpeg_0.1-8.1         png_0.1-7            magrittr_2.0.1      
[13] testthat_3.0.4       MtreeRing_1.4.5      shinydashboard_0.7.1 shinyWidgets_0.6.0  
[17] shiny_1.6.0         

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.7           lattice_0.20-44      deldir_0.2-10        assertthat_0.2.1    
 [5] digest_0.6.27        utf8_1.2.1           mime_0.11            R6_2.5.0            
 [9] plyr_1.8.6           signal_0.7-7         pillar_1.6.1         rlang_0.4.11        
[13] rstudioapi_0.13      R.utils_2.10.1       R.oo_1.24.0          Matrix_1.3-4        
[17] stringr_1.4.0        polyclip_1.10-0      igraph_1.2.6         tinytex_0.32        
[21] compiler_4.0.2       httpuv_1.6.1         xfun_0.24            pkgconfig_2.0.3     
[25] htmltools_0.5.1.1    readbitmap_0.1.5     tidyselect_1.1.1     tibble_3.1.3        
[29] matrixStats_0.59.0   XML_3.99-0.6         fansi_0.5.0          crayon_1.4.1        
[33] withr_2.4.2          later_1.2.0          MASS_7.3-54          R.methodsS3_1.8.1   
[37] grid_4.0.2           jsonlite_1.7.2       xtable_1.8-4         lifecycle_1.0.0     
[41] DBI_1.1.1            stringi_1.7.3        promises_1.2.0.1     ellipsis_0.3.2      
[45] generics_0.1.0       vctrs_0.3.8          spatstat.utils_2.2-0 boot_1.3-28         
[49] tools_4.0.2          glue_1.4.2           purrr_0.3.4          rsconnect_0.8.18    
[53] fastmap_1.1.0        yaml_2.2.1           pastecs_1.3.21  

Missing articles

The pkgdown navbar configuration refers to three articles but the package contains none, is that expected?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.