Skip to content

Producing images of Plant leaves in R

3 messages · Eric Doucette, Philippi, Tom, Sarah Goslee

#
Hello, does anyone know of a package(s) or methods to reproduce the shapes
of plant leaves in R? I have a large dataset (over 7500) of individual
plant leaves for which I have the following measurements: leaf length, leaf
width, leaf width at 1/10 of the overall length below the apex, and leaf
width at 1/10 of the overall length above the base. I am looking for a way
to code to get a visual representation of these lengths. They do not have
to actually be the same as the "real" measurements as long as the ratio of
measurements is correct. Thanks for any advice you can provide,
Eric
#
Eric--
If you don't care about "leaf-like" shape, you have 6 X,Y points defined
plus a pair of points at the maximum width at some undefined distance from
the apex.  Assuming bilateral symmetry, and assuming that the maximum width
is at 50% from apex to base, you have 5 points {0,0, b10width/2,length*.1,
maxW/2,length/2,  b90width/2,length*.9, and 0,length}, so you could
trivially fit a 4th order polynomial to those points, plot it and the
mirror image, and have blobs with those specific measurements.

I suspect that those blobs will not really look like your leaves.  Looking
at  https://en.wikipedia.org/wiki/Glossary_of_leaf_morphology , maybe
acute, obtuse, perforate, & oblanceolate might have max width at 50% of
length.  You _might_ be able to guess a position along the base-apex axis
for the maximum width (e.g., 35%) and get more reasonable shapes.  But I
suspect you need more measurements to characterize most leaf shapes.

Alternatively, if you only have one shape of leaves, you might be able to
take that shape, then scale & warp it to your truss of points.

Tom

On Tue, Jun 11, 2019 at 1:09 PM Eric Doucette <eric.t.doucette at gmail.com>
wrote:

  
  
#
Hi Eric,

I didn't look for an existing tool (you might try rseek.org) but
here's a quick and dirty leaf sketch tool that might give you an idea
for making your own.

leaf <- function(leafheight, width10, width50, width90, origin = c(0,
0), add = TRUE, main = "Leaf sketches", scaleheight, ...) {

# draws a schematic leaf based on height and three widths
# if add = FALSE, creates a blank plot
# places leaf base at origin point
# takes additional parameters to polygon such as col
# if scaleheight is missing, scales measurements so leafheight == 1

if(missing(scaleheight))
scaleheight <- leafheight

width10 <- (width10 / scaleheight) / 2
width50 <- (width50 / scaleheight) / 2
width90 <- (width90 / scaleheight) / 2
leafheight <- leafheight / scaleheight

maxwidth <- max(c(width10, width50, width90))

if(!add)
plot(c(-maxwidth, maxwidth), c(0, 1), xaxt = "n", yaxt = "n", xlab =
"", ylab = "", type = "n", main = main)

x <- c(0, width10, width50, width90, 0, -width90, -width50, -width10, 0)
y <- c(0, .1, .5, .9, 1, .9, .5, .1, 0) * leafheight
polygon(x, y, ...)

invisible()
}




###

leaf(50, 60, 30, 10, add = FALSE, main = "Leaf sketches")
leaf(20, 5, 8, 2, scaleheight = 50, border = "green", lwd = 3)
leaf(50, 2, 10, 15, scaleheight = 50, border = "red")
On Tue, Jun 11, 2019 at 4:08 PM Eric Doucette <eric.t.doucette at gmail.com> wrote: