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; McGill et al. 2005; Díaz et al. 2007). 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). 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) and Photoshop CS (Adobe Systems Incorporated, San José, 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; Fortunel et al. 2012; Katabuchi et al. 2012). 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 (Bylesjö et al. 2008; Weight et al. 2008; Maloof et al. 2013; Varma and Osuri 2013). 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), the preferred analytical environment for contemporary ecological research. LeafArea allows one to conveniently run ImageJ (http://imagej.nih.gov/ij/) 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.html). A development version of LeafArea is also available on GitHub (https://github.com/mattocci27/LeafArea).

Description

The function analyzes multiple leaf images captured by a scanner at a fixed resolution from a target directory (Fig. 1). It returns the results in a single data frame, which is a convenient format for subsequent analysis. The workflow is as follows.

Fig. 1
figure 1

The ImageJ function 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 checking:

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 function estimates leaf area from pixel. The 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 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). 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.

Fig. 2
figure 2

The 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, will return the leaf area of each image file; i.e., treating each file as a sample; whereas the command will calculate the leaf areas of the four samples (A1, A123, A2, A300), determined from their file prefixes

Run the main function in R

Multiple leaf images captured by a scanner to a target directory can be analyzed (Fig. 1). To run the main function, the user needs to specify the path to the target directory. In this example, the function specifies the path to the leaf images in the R temporary directory, then, the function analyzes the leaf area(s):

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 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:

For Microsoft Windows, this would be:

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:

The analyzed images can be saved in the directory for error checking:

The above options can be specified in a single command:

There are other options available, displayed by the 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 ; this depends on the operating system being used (Windows, Linux and Mac 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:

In Windows this would be:

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). 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 . 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:

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 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, 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.