---
category: literaturenote
citekey: katabuchileafareapackagerapiddigital2015
title: "LeafArea: an R package for rapid digital image analysis of leaf area"
authors: "Katabuchi, Masatoshi"
year: 2015
date: 2015-00-09 09 2015
doi: 10.1007/s11284-015-1307-x
publication: Ecological Research
zotero_key: 2XTL9IMU
zotero_storage: SY3AMANV
collections: R
folder: Liiklussageduse kaudne hindamine/04_Tehniline
firstAuthor: "Katabuchi, Masatoshi"
status: converted
---
# [LeafArea: an R package for rapid digital image analysis of leaf area](https://www.researchgate.net/publication/282839869_LeafArea_an_R_package_for_rapid_digital_image_analysis_of_leaf_area?enrichId=rgreq-5bebd561bee14f2546bd03686e96ea81-XXX&enrichSource=Y292ZXJQYWdlOzI4MjgzOTg2OTtBUzozOTE3NDczNDQ1ODQ3MDdAMTQ3MDQxMTI1MzMyOA%3D%3D&el=1_x_3&_esc=publicationCoverPdf)
| Article in Ecological Research · September 2015 | | | |
|---------------------------------------------------|---------------------------------|-------|--|
| DOI: 10.1007/s11284-015-1307-x | | | |
| | | | |
| | | | |
| CITATIONS | | READS | |
| 16 | | 2,513 | |
| | | | |
| 1 author: | | | |
| | | | |
| | Masatoshi Katabuchi | | |
| | University of Florida | | |
| | 57 PUBLICATIONS 772 CITATIONS | | |
| | SEE PROFILE | | |
### TECHNICAL REPORT

Masatoshi Katabuchi
# LeafArea: an R package for rapid digital image analysis of leaf area
Received: 7 July 2015 / Accepted: 6 September 2015 / Published online: 30 September 2015 -The Ecological Society of Japan 2015
Abstract Measuring leaf area is essential to quantifying other leaf functional traits. This paper introduces a new R package, LeafArea, which allows one to conveniently run ImageJ () within R. The functions in this package analyze multiple scanned leaf images in the target directory, generate multiple output files containing the leaf area of each leaf image, and then process and combine these files into a single file in a format that is convenient for subsequent analyses. Leaf area data from multiple images from the same sample can be combined automatically. This function allows users to cut large leaves into several pieces during scanning. The package provides a user-friendly, automated tool for measuring leaf area from scanned images.
Keywords Area normalization Æ Leaf size Æ Leaf mass per area (LMA) Æ Plant functional traits Æ Specific leaf area (SLA)
# Introduction
Leaf functional traits have received considerable attention in efforts to characterize the functional differences among species in ecophysiology, community ecology and ecosystem ecology (Wright et al. [2004](#page-5-0); McGill et al. [2005](#page-5-0); Dı´az et al. [2007](#page-4-0)). These traits include maximum rate of net photosynthesis, dark respiration rate, nitrogen content and phosphorus content, which are typically normalized by leaf area (or mass) to account for leaf size when comparing trait values (Osnas et al. [2013\)](#page-5-0).
Electronic supplementary material The online version of this article (doi[:10.1007/s11284-015-1307-x\)](http://dx.doi.org/10.1007/s11284-015-1307-x) contains supplementary material, which is available to authorized users.
M. Katabuchi (&)
E-mail: mattocci27@gmail.com Tel.: +1-352-273-0130
Department of Biology, University of Florida, Gainesville, FL 32611, USA
Therefore, measuring leaf area is essential in quantifying other leaf functional traits.
Measuring leaf area from digital images captured by a scanner involves several steps: (1) processing leaf images to separate the leaf from the image background, (2) setting the scale using a known distance in the image, (3) estimating leaf area from leaf pixel counts and the calibration scale, (4) outputting the leaf area data of each image to data files, and (5) combining the estimated leaf area into a single data file in a format that is convenient for subsequent analyses. Image analysis software, such as ImageJ (National Institutes of Health, Bethesda, MD, USA), GIMP (GNU Image Manipulation Program, [http://www.gimp.org\)](http://www.gimp.org) and Photoshop CS (Adobe Systems Incorporated, San Jose´, CA, USA), provide a straightforward way of measuring leaf area from digital images. These software require manual interaction by the user, making the task labor intensive when there are many leaves. In recent community ecology studies, leaf area was measured in hundreds to thousands of samples (Kraft et al. [2008;](#page-5-0) Fortunel et al. [2012;](#page-4-0) Katabuchi et al. [2012\)](#page-4-0). There are, however, several software packages that automate the extraction of leaves from the image background and the estimation of leaf area using leaf pixel counts (Bylesjo¨ et al. [2008;](#page-4-0) Weight et al. [2008](#page-5-0); Maloof et al. [2013](#page-5-0); Varma and Osuri [2013\)](#page-5-0). Nonetheless, these software cannot combine the leaf area data from several images of the same sample. This limitation prevents the automated processing of large leaves that must be cut into pieces small enough to be scanned by a portable scanner.
This paper introduces a new, open-source software package, LeafArea, which provides an automated method to calculate leaf area data from multiple scanned leaf images in R (R Core Team [2015\)](#page-5-0), the preferred analytical environment for contemporary ecological research. LeafArea allows one to conveniently run ImageJ () within R; ImageJ is written in Java and thus runs on all computer platforms. The LeafArea package can be downloaded and installed from the Comprehensive R Archive Network, CRAN ([http://cran.r-project.org/web/packages/LeafArea/index.](http://cran.r-project.org/web/packages/LeafArea/index.html) [html](http://cran.r-project.org/web/packages/LeafArea/index.html)). A development version of LeafArea is also available on GitHub [\(https://github.com/mattocci27/LeafArea\)](https://github.com/mattocci27/LeafArea).
### Description
The run.ij function analyzes multiple leaf images captured by a scanner at a fixed resolution from a target directory (Fig. [1](#page-3-0)). It returns the results in a single data frame, which is a convenient format for subsequent analysis. The workflow is as follows.
## Image capture
Capture leaf images with a scanner and save them as jpeg or tiff files. Image resolution must be the same in all image files because the run.ij function estimates leaf area from pixel. The run.ij function does not support images from digital cameras in which the scale of images depends on the distance of the camera to the object. Some very thick leaves may cast shadows on the background, which affects the subsequent image analysis. For better results and especially to avoid errors due to leaf shadows on the background, users could scan thick petioles separately. Similarly, leaves with thick mid ribs could be cut and the mid rib processed separately.
The run.ij function combines the leaf area of all images that share the same filename prefix, which is defined as the part of the filename preceding the first hyphen (-) or period (.). For example, the areas of leaf images named A123-1.jpeg, A123-2.jpeg and A123- 3.jpeg would be combined into the single total leaf area A123 (see Fig. [2](#page-4-0)). This feature allows the user to treat multiple images as belonging to a single sample. Note that the functions in the package do not count the number of leaves in each image. For example, when two large leaves from one individual (i.e., one sample) are cut into seven pieces and scanned in four images, if the user requires the number of leaves per image, the user must record these values.
# Run the main function in R
Multiple leaf images captured by a scanner to a target directory can be analyzed (Fig. [1](#page-3-0)). To run the main function, the user needs to specify the path to the target directory. In this example, the eximg function specifies the path to the leaf images in the R temporary directory, then, the run.ij function analyzes the leaf area(s):
```
> ex.dir <- eximg()
> run.ij(set.directory = ex.dir)
```
The above command returns a single data frame object containing sample names in the first column and total leaf area (cm2 ) of the sample in the second column. To run the run.ij function, the path to the target directory that contains the leaf images must be specified. For example, when the target directory named ''leaf data'' is on the desktop in an Apple Macintosh or Linux system, the path can be specified by:
```
> run.ij (set.directory ="~/Desktop/leaf data")
```
For Microsoft Windows, this would be:
```
> run.ij (set.directory="C:/Users//Desktop/leaf data")
```
There are several settings available, according to the leaf image format. When leaf images are captured in A4 image size at 100 ppi, the pixel density is approximately 826 pixels per 21 cm. In this case, the calibration scale can be specified by:
```
> run.ij (distance.pixel = 826, known.distance = 21)
```
The analyzed images can be saved in the directory for error checking:
```
> run.ij(save.image = TRUE)
```
The above options can be specified in a single command:
```
> run.ij (set. directory = "~/Desktop/leaf data",
distance.pixel = 826, known.distance =21,
save.image = TRUE)
```
There are other options available, displayed by the ?run.ij command in R, which are also summarized in Appendix S1.
When ImageJ is not installed in the common install directory, the path to ImageJ needs to be specified in run.ij; this depends on the operating system being used (Windows, Linux andMac are supported). For example, when ImageJ is installed in a directory named ''ImageJ'' on the desktop in Mac or Linux, the path can be specified by typing:
```
> run.ij (path.imagej = "~/Desktop/ImageJ")
```
In Windows this would be:
```
> run.ij (path.imagej = "C:/Users//Desktop/ImageJ")
```
#### Manual measurements by ImageJ (optional)
Users can skip this step if ImageJ succeeds in analyzing the leaf images. If ImageJ fails to recognize leaf images (Fig. S4), however, users can manually guide the image analysis for particular images through the ImageJ graphical user interface (see the ImageJ user guide, Ferreira and Rasband [2012\)](#page-4-0). As long as the names of the output text files have the same prefixes as those of the image files (e.g., A123-1.txt, A123-2.txt, A123-3.txt), the results for these manually analyzed images will still be handled by the file management function resmerge.ij. Multiple tab-delimited text files with a leaf area value (one text file per original JPEG image file) generated by ImageJ can be merged into a single data frame. For example, when the text files are on the desktop of a Mac, the files can be merged:
```
> resmerge.ij("~/Desktop")
```

Fig. 1 The ImageJ function run.ij computes the total area of all leaves (or leaf sections) in each image file in the target directory. Original leaf images are converted to black and white from threshold intensity levels, then leaf area is calculated by using leaf pixel counts and the calibration scale. The user can determine if the analyzed images will be saved for error check-
ing:run.ij (save.image = TRUE) or run.ij (save.image = FALSE)

Fig. 2 The run.ij function combines the leaf areas of all images that share the same filename prefix, defined (by default) as the part of the filename preceding the first hyphen (-) or period (.). In a regular expression, a pattern that contains a period or hyphen can be expressed as "\\.|-". For example, run.ij (prefix="\\.") will return the leaf area of each image file; i.e., treating each file as a sample; whereas the command run.ij (prefix="\\.|-") will calculate the leaf areas of the four samples (A1, A123, A2, A300), determined from their file prefixes
The above command returns a single data frame that contains sample names in the first column and total leaf area (cm2 ) of the sample in the second column. The option ''prefix'' is also available. See R command ?resmerge.ij for a more detailed description.
#### Conclusions
The package LeafArea is a powerful tool to automate leaf area measurements of digital images, which will facilitate research involving leaf functional traits. It offers several novel contributions. First, unlike other leaf image analysis software, LeafArea is called within R, a flexible and open-source computing environment, which facilitates subsequent analyses. Second, the file management function that combines leaf area data across images of the same plant individual is useful for large leaves and compound leaves. Third, the image analysis function implemented in ImageJ is fast because it is written in Java, a compiled language. For example, run.ij can analyze 100 images in approximately 15 s (Mac 10.10.3, Intel Core i7 2 GHz and 8 GB RAM). One limitation is that ImageJ sometimes does not recognize leaves correctly. Nonetheless, the failure rate was very low in the tests performed when developing the automated system. All of the 100 images that were analyzed were successfully recognized by ImageJ (Fig. S5). The LeafArea package can greatly reduce the time and labor needed for leaf area measurement.
Acknowledgments I thank M. Aiba for assistance with the R script. I also thank J. Lichstein, S. Rifai, Y. Onoda and the two anonymous referees for helpful comments on the manuscript. MK was supported by a Postdoctoral Fellowship for Research Abroad from the Japan Society for the Promotion of Science.
### References
Bylesjo¨ M, Segura V, Soolanayakanahally RY, Rae AM, Trygg J, Gustafsson P, Jansson S, Street NR (2008) LAMINA: a tool for rapid quantification of leaf size and shape parameters. BMC Plant Biol 8:82–89. doi[:10.1186/1471-2229-8-82](http://dx.doi.org/10.1186/1471-2229-8-82)
Dı´az S, Lavorel S, de Bello F, Quetier F, Grigulis K, Robson M (2007) Incorporating plant functional diversity effects in ecosystem service assessments. Proc Natl Acad Sci USA 104:20684–20689. doi[:10.1073/pnas.0704716104](http://dx.doi.org/10.1073/pnas.0704716104)
Ferreira T, Rasband WS (2012) ImageJ User Guide—IJ 1.46. [http://imagej.nih.gov/ij/docs/guide/.](http://imagej.nih.gov/ij/docs/guide/) Accesed 24 August 2015 Fortunel C, Fine PV, Baraloto C (2012) Leaf, stem and root tissue strategies across 758 neotropical tree species. Funct Ecol 26:1153–1161. doi[:10.1111/j.1365-2435.2012.02020.x](http://dx.doi.org/10.1111/j.1365-2435.2012.02020.x)
Katabuchi M, Kurokawa H, Davies SJ, Tan S, Nakashizuka T (2012) Soil resource availability shapes community trait structure in a species-rich dipterocarp forest. J Ecol 100:643–651. doi[:10.1111/j.1365-2745.2011.01937.x](http://dx.doi.org/10.1111/j.1365-2745.2011.01937.x)
- Kraft NJB, Valencia R, Ackerly DD (2008) Functional traits and niche-based tree community assembly in an Amazonian forest. Science 322:580–582. doi:[10.1126/science.1160662](http://dx.doi.org/10.1126/science.1160662)
- Maloof JN, Nozue K, Mumbach MR, Palmer CM (2013) LeafJ: an ImageJ plugin for semi-automated leaf shape measurement. JoVE. doi[:10.3791/50028](http://dx.doi.org/10.3791/50028)
- McGill BJ, Hadly E, Maurer B (2005) Community inertia of quaternary small mammal assemblages in North America. Proc Natl Acad Sci USA 102:16701–16706. doi: [10.1073/pnas.0504225102](http://dx.doi.org/10.1073/pnas.0504225102)
- Osnas JLD, Lichstein JW, Reich PB, Pacala SW (2013) Global leaf trait relationships: mass, area, and the leaf economics spectrum. Science 340:741–744. doi:[10.1126/science.1231574](http://dx.doi.org/10.1126/science.1231574)
- R Core Team (2015) R: a language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. . Accessed 24 August 2015
- Varma V, Osuri AM (2013) Black Spot: a platform for automated and rapid estimation of leaf area from scanned images. Plant Ecol 214:1529–1534. doi:[10.1007/s11258-013-0273-z](http://dx.doi.org/10.1007/s11258-013-0273-z)
- Weight C, Parnham D, Waites R (2008) LeafAnalyser: a computational method for rapid and large-scale analyses of leaf shape variation. Plant J 53:578–586. doi: [10.1111/j.1365-313X.2007.03330.x](http://dx.doi.org/10.1111/j.1365-313X.2007.03330.x)
- Wright IJ, Reich PB, Westoby M, Ackerly DD, Baruch Z, Bongers F, Cavender-Bares J, Chapin T, Cornelissen J, Diemer M, Flexas J, Garnier E, Groom PK, Gulias J, Hikosaka K, Lamont BB, Lee T, Lee W, Lusk C, Midgley JJ, Navas ML, Niinemets U, Oleksyn J, Osada N, Poorter H, Poot P, Prior L, Pyankov VI, Roumet C, Thomas SC, Tjoelker MG, Veneklaas EJ, Villar R (2004) The worldwide leaf economics spectrum. Nature 428:821–827. doi[:10.1038/nature02403](http://dx.doi.org/10.1038/nature02403)