Learn R Programming

RootscanR (version 0.0.1)

kimuraLength: Computation of the Kimura length

Description

kimuraLength - Computes the Kimura length according to the specified formula to estimate the root length shown in a skeletonized black & white image of a root.
Optionally, a masking layer can be specified that indicates which pixels of the image should be considered.

Usage

kimuraLength(
  skel_img,
  formula = 6,
  mask = NULL,
  strict_mask = TRUE,
  show_messages = TRUE
)

Value

kimuraLength Numeric value (root length estimation).

Arguments

skel_img

Skeleton image (provided by the RootDetector). Can be a PNG, i.e., an array with 3 dimensions (3 layers each containing a 2-dim. numeric matrix with values between 0 and 1), or a 2-dim. matrix.

formula

Integer value specifying the formula to be used (by default 6) based on Kimura et al., 1999 (see references). Available are the following formulas, where \(N_o\) denotes the number of orthogonal and \(N_d\) the number of diagonal connections (between white pixels), and \(N_{whitepx}\) the number of white pixels in the image. Furthermore, there are three additional formulas to simply count white, or black, or red pixels.

  • Formula 1: \(1.1107 \cdot (N_d + N_o)\),

  • Formula 2: \(\sqrt{2} \cdot N_d + N_o\),

  • Formula 3: \(0.948 \cdot (\sqrt{2} \cdot N_d + N_o)\),

  • Formula 4: \(\sqrt{N_d^2+ (N_d+N_o)^2}\),

  • Formula 6: \(\sqrt{N_d^2+ (N_d+N_o/2)^2} + N_o/2\),

  • Formula 7: \(1.1107 \cdot N_{whitepx}\).

  • Formula 97: \(N_{whitepx}\).

  • Formula 98: \(N_{blackpx}\).

  • Formula 99: \(N_{redpx}\).

mask

2-dim. true/false-matrix with the same number of rows and columns as skel_img (optional, default = NULL, interpreted as a matrix consisting only of TRUEs, i.e., nothing is "removed" from the image).

strict_mask

Specifies how strictly the mask should be applied. Available are:

  • TRUE (default): Connections between TRUE-pixels and neighboring FALSE-pixels are not counted. As a result, the root length is likely to be underestimated, especially if there are many TRUE-FALSE transitions in the mask.

  • FALSE: Connections between TRUE-pixels and neighboring FALSE-pixels are counted. As a result, the root length is likely to be overestimated, especially if there are many TRUE-FALSE transitions in the mask.

show_messages

Specify if messages about the counts of orthogonal and diagonal connection counts should be depicted (default TRUE).

References

Kimura, K., Kikuchi, S. & Yamasaki, Si. Accurate root length measurement by image analysis. Plant and Soil 216, 117–127 (1999). doi: 10.1023/A:1004778925316

Examples

Run this code
# This is a simple image with 2 diagonal and 1 orthogonal connections.
# With Formula 6 (default):
kimuraLength(matrix(c(
  1, 0, 0, 0,
  0, 1, 0, 0,
  0, 0, 1, 1
), ncol = 4, nrow = 3, byrow = TRUE))
# With Formula 4:
kimuraLength(
  matrix(c(
    1, 0, 0, 0,
    0, 1, 0, 0,
    0, 0, 1, 1
  ), ncol = 4, nrow = 3, byrow = TRUE),
  formula = 4
)
# With Formula 6 and a mask which makes the function ignore the right side
# of the image. If stict_mask = TRUE, only 1 diagonal connection can be
# found. If set to FALSE, i.e., relaxed mask borders, then 2 diagonal
# connections are counted.
kimuraLength(
  skel_img = matrix(c(
    1, 0, 0, 0,
    0, 1, 0, 0,
    0, 0, 1, 1
  ), ncol = 4, nrow = 3, byrow = TRUE),
  mask = matrix(
    c(
      TRUE, TRUE, FALSE, FALSE,
      TRUE, TRUE, FALSE, FALSE,
      TRUE, TRUE, FALSE, FALSE
    ),
    ncol = 4, nrow = 3,
    byrow = TRUE
  ), strict_mask = FALSE
)

Run the code above in your browser using DataLab