Type: | Package |
Title: | Rapid Digital Image Analysis of Leaf Area |
Version: | 0.1.8 |
Date: | 2019-07-03 |
Author: | Masatoshi Katabuchi <mattocci27@gmail.com> |
Maintainer: | Masatoshi Katabuchi <mattocci27@gmail.com> |
Description: | An interface for the image processing program 'ImageJ', which allows a rapid digital image analysis for particle sizes. This package includes function to write an 'ImageJ' macro which is optimized for a leaf area analysis by default. |
Depends: | R (≥ 3.0.0) |
Imports: | stats, utils |
SystemRequirements: | ImageJ (>=1.48), ij.jar (see http://imagej.nih.gov/ij/), Java (>=1.6.0) |
License: | GPL-2 |
BugReports: | https://github.com/mattocci27/LeafArea/issues |
URL: | https://github.com/mattocci27/LeafArea |
RoxygenNote: | 6.1.1 |
NeedsCompilation: | no |
Packaged: | 2019-07-03 08:33:49 UTC; mattocci |
Repository: | CRAN |
Date/Publication: | 2019-07-03 09:01:43 UTC |
LeafArea: Rapid digital image analysis of leaf area
Description
The package LeafArea allows one to conveniently run ImageJ software within R. The package provides a user-friendly, automated tool for measuring leaf area from digital images. For more information on ImageJ, see the ImageJ User Guide, which is available http://imagej.nih.gov/ij/.
Details
The key function in this package is run.ij
, which analyzes multiple leaf images in the target directory and generates multiple data frame objects that include leaf area from each leaf image, and then processes and combines these data frame objects into a single data frame object that is convenient for subsequent analyses.
If ImageJ fails to recognize leaf images, users can manually guide the image analysis for particular images through ImageJ GUI (See the ImageJ user guide 30.1 Measure...[m], http://imagej.nih.gov/ij/docs/guide/user-guide.pdf). The results for these manually-analyzed images will still be handled by the file management function resmerge.ij
.
Author(s)
Maintainer: Masatoshi Katabuchi mattocci27@gmail.com
References
Rasband, W.S., ImageJ, U. S. National Institutes of Health, Bethesda, Maryland, USA, http://imagej.nih.gov/ij/, 1997-2014.
Schneider, C.A., Rasband, W.S., Eliceiri, K.W. "NIH Image to ImageJ: 25 years of image analysis". Nature Methods 9, 671-675, 2012.
Abramoff, M.D., Magalhaes, P.J., Ram, S.J. "Image Processing with ImageJ". Biophotonics International, volume 11, issue 7, pp. 36-42, 2004. (This article is available https://www.researchgate.net/publication/228334776_Image_Processing_with_Image.) #'
See Also
Useful links:
Utility function
Description
Exports sample image files to R temporary directory and returns a path to the sample image files. This function is only used in the example of run.ij
.
Usage
eximg()
Value
Jpeg files to the R temporary directory and a path to the sample image files.
Author(s)
Masatoshi Katabuchi mattocci27@gmail.com
See Also
run.ij
which this function wraps
Checking a path to ImageJ
Description
Check if ImageJ is installed in the correct directory.
Usage
find.ij(ostype = .Platform$OS.type)
Arguments
ostype |
the Operating system types. |
Details
When ImageJ, including ij.jar and Java, is not installed in the common location, users need to specify the path to ImageJ in run.ij
.
Value
A path for ImageJ application. On unix this will always be "/Applications/ImageJ/". On Windows this will always be "C:\Program Files\ImageJ\".
Author(s)
Masatoshi Katabuchi mattocci27@gmail.com
LeafArea default data
Description
Analyzed leaf area data for example
Usage
leafdata
Format
A list with six data frames, A1-01.jpeg.txt, A1-02.jpeg.txt, A123-01.jpeg.txt, A123-02.jpeg.txt, A2.jpeg.txt and A300-1.jpeg.txt. The first column is the identity of image, the second column is the area of the image (cm2) and the thrid column is the perimeter of the image (cm).
File management
Description
Read multiple tab-delimited text files with a leaf area and perimeter value (one text file for each original JPEG image file) generated by ImageJ.
Usage
readtext.ij(path)
Arguments
path |
Path to the target directory |
Value
A list of data frame of leaf area for each image
area |
Leaf area of the image (cm2) |
Author(s)
Masatoshi Katabuchi mattocci27@gmail.com
See Also
Examples
#prepare example files
data(leafdata)
tf <- paste(tempdir(), "/", sep = "")
for (i in 1:7){
write.table(leafdata[[i]],paste(tf,names(leafdata)[i],sep=""),sep="\t")
}
#list of files
list.files(tf)
readtext.ij(tf)
unlink(list.files(tf))
File management
Description
File management function. The output file contains sample names in the first column and total leaf area (cm2) of the sample (e.g., one individual plant or one ramet) in the second column.
Usage
resmerge.ij(path, prefix = "\\.|-")
Arguments
path |
Path to the target directory |
prefix |
Regular expression to manage file names |
Value
A data frame of total leaf area for each sample
sample |
Name of sample |
total.leaf.area |
Total leaf area of the sample (cm2) |
Author(s)
Masatoshi Katabuchi mattocci27@gmail.com
Examples
#prepare example files
data(leafdata)
tf <- paste(tempdir(),"/",sep="")
for (i in 1:7){
write.table(leafdata[[i]],paste(tf,names(leafdata)[i],sep=""),sep="\t")
}
#list of files
list.files(tf)
#combine multiple tab-delimited text files with a leaf area value
#(one text file for each original JPEG image file) that share the same
#filename 'prefix', defined as the part of the filename preceding the first
#hyphen (-) or period (.).
resmerge.ij(tf)
#combine multiple tab-delimited text files with a leaf area value
#(one text file for each original JPEG image file) that share the same
#filename 'prefix', defined as the part of the filename preceding the first
#'.txt'.
resmerge.ij(tf, prefix = ".txt")
unlink(list.files(tf))
Automated leaf area analysis
Description
Analyzes leaf area in the target directory automatically, and returns a data frame that contains sample names in the first column and total leaf area (cm2) of the sample (e.g., one individual plant or one ramet) in the second column. Note that 'run.ij' does not count the number of leaves in each image; therefore if the user requires the number of leaves per image, the user must record these values.
Usage
run.ij(path.imagej = NULL, set.memory = 4, set.directory,
distance.pixel = 826, known.distance = 21, trim.pixel = 20,
low.circ = 0, upper.circ = 1, low.size = 0.7,
upper.size = "Infinity", prefix = "\\.|-", log = F,
check.image = F, save.image = F)
Arguments
path.imagej |
Path to ImageJ. Default uses C:/Program Files/ImageJ for Windows, and /Applications/ImageJ for Mac. Linux always needs to specify the path to ImageJ |
set.memory |
Set memory (GB) for image analysis (default = 4). |
set.directory |
Set directory that contains leaf images. For example, when the directory named 'leaf_data' is on desktop of Mac, the path can be specified as: set.directory = '~/Desktop/leaf_data'. For Windows: set.directory = 'C:/Users/<users name>/Desktop/leaf_data'. No default. The path to the target directory that contains leaf images should always be specified. Note that spaces in file or directory names are not allowed. |
distance.pixel |
Number of pixels for the known distance. When leaf images were captured in A4 image size with 100 ppi, the pixel density is roughly equal to 826 pixels per 21 cm. In this case, the calibration scale can be specified as distance.pixel = 826, known.distance = 21. |
known.distance |
Known distance (cm). See distance.pixel. |
trim.pixel |
Number of pixels removed from edges in the analysis. The edges of images are often shaded, which can affect image analysis (i.e., ImageJ may recognize the shaded area as leaf area). The edges of images can be removed by specifying the number of pixels (default = 20). |
low.circ |
Lower limit for circularity for the image analysis. When the user wants to remove angular objects (e.g., cut petioles, square papers for scale) from the images, the analyzed lower limit of circularity can be increased (default = 0). |
upper.circ |
Upper limit for circularity for the image analysis (default = 1). See low.circ. |
low.size |
Lower limit for size for the image analysis. Leaf images often contain dirt and dust. To prevent dust from affecting the image analysis, the lower limit of analyzed size can be increased (default = 0.7). |
upper.size |
Upper limit for size for the image analysis (default = Infinity'). |
prefix |
Regular expression to manage file names. The 'run.ij' combines the leaf area of all images that share the same filename 'prefix', defined as the part of the filename preceding the first hyphen (-) or period (.) that may occur (no hyphen or period is required). For example, the areas of leaf images named A123-1.jpeg, A123-2.jpeg, and A123-3.jpeg would be combined into a single total leaf area (A123). This feature allows the user to treat multiple images as belonging to a single sample, if desired (default = '\\.|-'). |
log |
Should mean leaf areas of each single image kept? (default = FALSE) |
check.image |
Whether to display analyzed images by using ImageJ software (default = FALSE). When you choose check.image = TRUE, press any keys to close ImageJ. Note that when check.image = TRUE, the analysis would take considerable time. Note this option may only work on R console. |
save.image |
Whether to save analyzed images (default = FALSE). |
Value
A data frame of total leaf area for each sample.
sample |
Name of sample |
total.leaf.area |
Total leaf area of the sample (cm2) |
If you choose log= T, the 'run.ij' function also returns a list of data frames of leaf area for each image.
area |
Area of the sample (cm2) |
Author(s)
Masatoshi Katabuchi mattocci27@gmail.com
See Also
resmerge.ij
, readtext.ij
, eximg
Examples
# As long as ImageJ application, including `ij.jar` and java, is installed
# in the following directory,
# you do not have to specify the path to ImageJ
# /Applications/ImageJ <Mac>
# C:/Program Files/ImageJ <Windows>
# Linux always needs to specify the path to the directory that contains `ij.jar`.
# For example, path = "~/ImageJ"
# prepare the target directory that contains example image files
ex.dir <- eximg()
list.files(ex.dir)
#run automated images analysis
run.ij(set.directory = ex.dir, save.image = TRUE)
# note: in this example, analyzed images are exported to a temporary
# directory, which will be eventually deleted.
# If you choose your home directory as the target directory,
# analyzed images will be exported to it.